generated from adobe/aem-block-collection
-
Notifications
You must be signed in to change notification settings - Fork 1
feat: footer #51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
feat: footer #51
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); | ||
| } | ||
| } | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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(); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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(); | ||
| }); | ||
| }); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); | ||
| } | ||
| } | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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(); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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.