Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion 404.html
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@

<body>
<header></header>
<main class="error">
<main id="main-content" class="error">
<div class="section">
<svg viewBox="1 0 38 18" class="error-number">
<text x="0" y="17">404</text>
Expand Down
File renamed without changes
8 changes: 8 additions & 0 deletions blocks-helpers/skipLinks.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export const buildSkipLink = () => {
const skipToContentLink = document.createElement('a');
skipToContentLink.href = "/#main-content";
skipToContentLink.classList.add('util-skip-link');
skipToContentLink.innerText = "Skip to main content";

return skipToContentLink;
}
18 changes: 18 additions & 0 deletions blocks/footer-copyright/footer-copyright.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
.footer-copyright {
background-color: var(--color-background);
padding: 1.5rem var(--spacing-page-gutters) 3rem;

@media (min-width: 48rem) {
padding: 1.125rem var(--spacing-page-gutters);
}

& p {
margin: 0;
padding: 0;
}

& a {
color: var(--color-text-dark);
}
}

12 changes: 12 additions & 0 deletions blocks/footer-copyright/footer-copyright.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
export default function decorate(block) {
block.parentElement.classList.add('footer-copyright');
const copyright = document.createElement('div');

while (block.children[0].children[0].children[0]) {
copyright.append(block.children[0].children[0].children[0]);
}

copyright.classList.add('footer-copyright__content', 'util-detail-s');

block.replaceWith(copyright);
}
11 changes: 11 additions & 0 deletions blocks/footer-copyright/footer-copyright.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
describe('Footer Copyright Block', () => {
beforeAll(async () => {
await page.goto(`${global.BASE_URL}footer`);
});

it('should render the footer copyright block', async () => {
await page.waitForSelector('.footer-copyright');
const footer = await page.$('.footer-copyright');
expect(footer).toExist();
});
});
13 changes: 13 additions & 0 deletions blocks/footer-heading/footer-heading.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
.footer-heading {
& p {
margin: 0;
}
}

.footer-heading__link,
.footer-heading a {
display: block;
max-width: 9.5rem;
color: var(--color-text-dark);
margin-bottom: 1rem;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, covering the case if there were ever no footer-links.

}
27 changes: 27 additions & 0 deletions blocks/footer-heading/footer-heading.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { logoSVG } from './logosvg.js';

export default function decorate(block) {
block.parentElement.classList.add('footer-heading');

// create the homepage link
const headingLink = document.createElement('a');
const headingLinkText = block.children[0].children[0].innerText;
const headingLinkURL = block.children[0].children[1].innerText;

headingLink.innerHTML = `
<span class="util-visually-hidden">${headingLinkText}</span>
${logoSVG}
`;
headingLink.href = headingLinkURL;
headingLink.classList.add('footer-heading__link');

// add the description to a paragraph tag
const headingDescription = document.createElement('p');
const headingDescriptionText = block.children[1].children[0].innerText;;

headingDescription.innerHTML = headingDescriptionText;

// put it all together

block.replaceWith(headingLink, headingDescription);
}
11 changes: 11 additions & 0 deletions blocks/footer-heading/footer-heading.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
describe('Footer Heading Block', () => {
beforeAll(async () => {
await page.goto(`${global.BASE_URL}footer`);
});

it('should render the footer heading block', async () => {
await page.waitForSelector('.footer-heading');
const footer = await page.$('.footer-heading');
expect(footer).toExist();
});
});
2 changes: 2 additions & 0 deletions blocks/footer-heading/logosvg.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions blocks/footer-links/footer-links.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
.footer-links__list {
list-style-type: none;
padding-inline-start: 0;
display: flex;
align-items: center;
justify-content: flex-start;
flex-wrap: wrap;
gap: 0.5rem;

& li {
flex: 1 0 45%;
min-height: 1.5rem;
}

& a {
color: var(--spectrum-gray-700);
}
}

36 changes: 36 additions & 0 deletions blocks/footer-links/footer-links.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { buildSkipLink } from '../../blocks-helpers/skipLinks.js';

const buildFooterLink = ({textContent, url}) => {
const footerLink = document.createElement('a');
const footerLinkText = textContent;
const footerLinkURL = url;

footerLink.innerHTML = footerLinkText;
footerLink.href = footerLinkURL;

return footerLink;
};

export default async function decorate(block) {
block.parentElement.classList.add('footer-links');
const footerLinkList = document.createElement('ul');
footerLinkList.classList.add('footer-links__list', 'util-body-xs');

const footerLinksData = [...block.children].map(row => ({
textContent: row.children[0].children[0].innerText,
url: row.children[1].children[0].innerText,
}));

footerLinksData.forEach(row => {
const footerLinkListItem = document.createElement('li');
const footerLink = buildFooterLink(row);

footerLinkListItem.append(footerLink);
footerLinkList.append(footerLinkListItem);
});

const footerLinks = document.createElement('nav');
footerLinks.append(buildSkipLink());
footerLinks.append(footerLinkList);
block.replaceWith(footerLinks);
}
11 changes: 11 additions & 0 deletions blocks/footer-links/footer-links.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
describe('Footer Links Block', () => {
beforeAll(async () => {
await page.goto(`${global.BASE_URL}footer`);
});

it('should render the footer links block', async () => {
await page.waitForSelector('.footer-links');
const footer = await page.$('.footer-links');
expect(footer).toExist();
});
});
101 changes: 89 additions & 12 deletions blocks/footer/footer.css
Original file line number Diff line number Diff line change
@@ -1,22 +1,99 @@
footer {
background-color: var(--spectrum-gray-50);
font-size: var(--spectrum-body-size-xs);
:root {
--color-background-footer: var(--spectrum-white);

&:has(#color-scheme option[value="dark"]:checked) {
--color-background-footer: var(--spectrum-gray-50);
}

@media (prefers-color-scheme: dark) {
&:has(#color-scheme option[value="system"]:checked) {
--color-background-footer: var(--spectrum-gray-50);
}
}
}

.footer-content {
width: 100%;
padding: 0;
background-color: var(--color-background-footer);
color: var(--color-text-dark);
}

footer .footer > div {
margin: auto;
max-width: 1200px;
padding: 40px 24px 24px;
/* padding is on the elements instead of the container so we don't have to add more nested divs */
.footer-heading {
padding: 3rem var(--spacing-page-gutters) 0.5rem;
}

footer .footer p {
margin: 0;
.footer-links {
padding: 0.5rem var(--spacing-page-gutters) 3rem;
}

@media (min-width: 48rem) {
/* !! min-width MQ needs refactor */
@supports (display: grid) {
.footer-content .section {
display: grid;
grid-template-columns: repeat(12, [col] 1fr);
grid-column-gap: 1rem;
grid-row-gap: 1rem;
align-items: stretch;
justify-items: stretch;
}

.footer-heading,
.footer-links {
min-height: 0;
min-width: 0;
}

.footer-heading,
.footer-links {
padding: 4rem var(--spacing-page-gutters) 6rem;
}

.footer-heading {
grid-column: span 7;
display: flex;
flex-direction: column;
justify-content: space-between;
}

.footer-links {
grid-column: 9 / span 5;
}

.footer-copyright {
grid-column: span 12;
width: 100%;
}

.footer-copyright__content {
margin: 0 auto;
max-width: var(--spacing-page-max-width);
}
}
}

@media (min-width: 100rem) {
.footer-content .section {
display: flex;
flex-wrap: wrap;
grid-template-columns: unset;
grid-column-gap: unset;
grid-row-gap: unset;
}

.footer-heading,
.footer-links {
margin: 0;
}

.footer-heading {
width: calc(0.7 * var(--spacing-page-max-width));
margin-inline-start: auto;
}

footer .footer > div {
padding: 2.5rem 2rem 1.5rem;
.footer-links {
width: calc(0.3 * var(--spacing-page-max-width));
margin-inline-end: auto;
}
}
7 changes: 4 additions & 3 deletions blocks/footer/footer.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,17 @@ import { loadFragment } from '../fragment/fragment.js';
* loads and decorates the footer
* @param {Element} block The footer block element
*/

export default async function decorate(block) {
// load footer as fragment
const footerMeta = getMetadata('footer');
const footerPath = footerMeta ? new URL(footerMeta, window.location).pathname : '/footer';
const fragment = await loadFragment(footerPath);

// decorate footer DOM
block.textContent = '';
// create the footer from that fragment
const footer = document.createElement('div');
footer.classList.add('footer-content', 'util-body-s');
while (fragment.firstElementChild) footer.append(fragment.firstElementChild);

block.append(footer);
block.replaceWith(footer);
}
8 changes: 6 additions & 2 deletions blocks/header/header.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { fetchPlaceholders, getMetadata } from '../../scripts/aem.js';
import { loadFragment } from '../fragment/fragment.js';
import { buildSkipLink } from '../../blocks-helpers/skipLinks.js';

// media query match that indicates mobile/tablet width
const isDesktop = window.matchMedia('(min-width: 900px)');
const isDesktop = window.matchMedia('(min-width: 48rem)');

function closeOnEscape(e) {
if (e.code === 'Escape') {
Expand Down Expand Up @@ -183,9 +184,12 @@ export default async function decorate(block) {
block.textContent = '';
const nav = document.createElement('nav');
nav.id = 'nav';

nav.append(buildSkipLink());

while (fragment.firstElementChild) nav.append(fragment.firstElementChild);

const classes = ['brand', 'sections', 'tools'];
const classes = ['skip-link', 'brand', 'sections', 'tools'];
classes.forEach((c, i) => {
const section = nav.children[i];
if (section) section.classList.add(`nav-${c}`);
Expand Down
2 changes: 1 addition & 1 deletion scripts/aem.js
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ function decorateIcon(span, prefix = '', alt = '') {
.substring(5);
const img = document.createElement('img');
img.dataset.iconName = iconName;
img.src = `${window.hlx.codeBasePath}${prefix}/icons/${iconName}.svg`;
img.src = `${window.hlx.codeBasePath}${prefix}/assets/icons/${iconName}.svg`;
img.alt = alt;
img.loading = 'lazy';
span.append(img);
Expand Down
1 change: 1 addition & 0 deletions scripts/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ async function loadEager(doc) {
const main = doc.querySelector('main');
if (main) {
decorateMain(main);
main.id = "main-content";
doc.body.classList.add('appear');
await loadSection(main.querySelector('.section'), waitForFirstImage);
}
Expand Down
15 changes: 15 additions & 0 deletions styles/base.css
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,21 @@
--spectrum-spacing-900: 5rem; /* 80px */
--spectrum-spacing-1000: 6rem; /* 96px */

--spacing-page-max-width: 97.5rem;

/* smallest screens */
--spacing-page-gutters: 1.25rem;

@media (min-width: 22.5rem) {
/* breakpoint small - large */
--spacing-page-gutters: 2rem;
}

@media (min-width: 100rem) {
/* breakpoint-xl, content should max-width */
--spacing-page-gutters: 0;
}

/* ** STATES ** */
--spectrum-focus-indicator-thickness: 2px;
--spectrum-focus-indicator-gap: 0.125rem;
Expand Down
Loading