From 851cc32856f7137043d3bc94f635a46e770683be Mon Sep 17 00:00:00 2001 From: Tomasz Dziezyk Date: Thu, 29 Aug 2024 13:26:39 +0200 Subject: [PATCH 001/159] Add colors and text styles --- styles/styles.css | 219 ++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 183 insertions(+), 36 deletions(-) diff --git a/styles/styles.css b/styles/styles.css index 54f946c..f17c9b9 100644 --- a/styles/styles.css +++ b/styles/styles.css @@ -11,17 +11,8 @@ */ :root { - /* colors */ - --link-color: #f00; - --link-hover-color: #1d1d1b; - --c-primary-white: #fff; - --button-color: #f00; - --light-color: #eee; - --dark-color: #ccc; - --text-color: #1d1d1b; - /* fonts */ - --body-font-family: "Oxygen", sans-serif; + --body-font-family: "Boxed", arial; --heading-font-family: var(--body-font-family); --body-font-size: 16px; @@ -31,11 +22,49 @@ /* section paddings */ --section-y-padding: 40px; --section-x-padding: 15px; + + /* v2 */ + --white: #fff; + --grey-5: #f2f2f2; + --grey-10: #e6e6e6; + --grey-20: #ccc; + --grey-30: #b3b3b3; + --grey-40: #999; + --grey-50: #8080; + --grey-60: #666; + --grey-70: #4d4d4d; + --grey-80: #333; + --grey-90: #1a1a1a; + --black: #000; + --dark-red: #e3423d; + --action-default: #ed1c24; + --action-hover: #ae2d27; + --action-focus: #82221d; + --success: #2d9d78; + --warning: #e68619; + --error: #b81f2d; + + /* old variables */ + --link-color: var(--action-default); + --link-hover-color: var(--action-hover); + --c-primary-white: var(--white); + --button-color: var(--action-default); + --light-color: #eee; + --dark-color: #ccc; + --text-color: #1d1d1b; + +} + +:root .dark { + --action-default: #fff; + --action-hover: #bbb; + --action-focus: #999; } body { font-size: var(--body-font-size); - font-weight: 400; + font-weight: 500; + letter-spacing: 0.44px; margin: 0; font-family: var(--body-font-family); line-height: 1.5; @@ -43,6 +72,7 @@ body { background-color: var(--c-primary-white); display: none; -webkit-font-smoothing: antialiased; + font-feature-settings: 'liga' off, 'clig' off; } body.appear { @@ -53,53 +83,154 @@ header { height: var(--nav-height); } -h1, h2, h3, h4, h5, h6, -.h1, .h2, .h3, .h4, .h5, .h6 { +h1, +h2, +h3, +h4, +h5, +h6, +.h1, +.h2, +.h3, +.h4, +.h5, +.h6 { margin-bottom: 20px; margin-top: 0; } h1, .h1 { - font-size: 1.8063rem; - line-height: 1.2; - font-weight: 400; - text-transform: uppercase; + font-size: 2.25rem; + font-style: normal; + font-weight: 500; + line-height: 140%; + letter-spacing: 0; } h2, .h2 { - font-size: 1.7rem; - line-height: 1.3; - font-weight: 400; + font-size: 2rem; + font-style: normal; + font-weight: 500; + line-height: 140%; + letter-spacing: 0.25; } h3, .h3 { - font-size: 1.5rem; - line-height: 1.4; - font-weight: 400; + font-size: 1.75rem; + font-style: normal; + font-weight: 500; + line-height: 140%; + letter-spacing: 0; } h4, .h4 { font-size: 1.25rem; - line-height: 1.4; - font-weight: 600; + font-style: normal; + font-weight: 500; + line-height: 130%; + letter-spacing: 0.15px; } h5, .h5 { - font-size: 1rem; - line-height: 1.4; - font-weight: 600; + font-size: 1.25rem; + font-style: normal; + font-weight: 500; + line-height: 130%; + letter-spacing: 0.15px; } h6, .h6 { + font-size: 1rem; + font-style: normal; + font-weight: 500; + line-height: 140%; + letter-spacing: 0.15px; +} + +@media (width >= 768px) { + h1, + .h1 { + font-size: 2.5rem; + } + + h2, + .h2 { + font-size: 2.25rem; + } + + h3, + .h3 { + font-size: 2rem; + } + + h4, + .h4 { + font-size: 1.75rem; + } + + h5, + .h5 { + font-size: 1.5rem; + } + + h6, + .h6 { + font-size: 1.25rem; + } +} + +@media (width >= 1024px) { + h1, + .h1 { + font-size: 4.375rem; + letter-spacing: -1.5px; + } + + h2, + .h2 { + font-size: 3rem; + letter-spacing: -0.5px; + } + + h3, + .h3 { + font-size: 2.5rem; + letter-spacing: 0; + } + + h4, + .h4 { + font-size: 2.125rem; + letter-spacing: 0.25px; + } + + h5, + .h5 { + font-size: 1.75rem; + letter-spacing: 0; + } + + h6, + .h6 { + font-size: 1.25rem; + letter-spacing: 0.15px; + } +} + +.font-small { font-size: 0.875rem; - line-height: 1.4; - font-weight: 600; + letter-spacing: 0.25px; +} + +.font-caption { + font-size: 0.75; + letter-spacing: 0.4px; } * + .h1, @@ -117,7 +248,6 @@ h6, margin-top: 40px; } - p, dl, ol, @@ -128,7 +258,14 @@ blockquote { margin-bottom: 1em; } -address, dl, fieldset, figure, ol, p, pre, ul { +address, +dl, +fieldset, +figure, +ol, +p, +pre, +ul { margin: 0 0 20px; } @@ -316,7 +453,7 @@ main .section.highlight { content: ""; display: inline-block; position: relative; - top: calc(-0.1* 1em); + top: calc(-0.1 * 1em); vertical-align: middle; height: calc(4px + 0.7em); margin-right: calc(5px + 0.2em); @@ -372,7 +509,17 @@ main .border-top { } /* styles to override onetrust */ -#onetrust-consent-sdk #onetrust-pc-sdk button:not(#clear-filters-handler, .ot-close-icon, #filter-btn-handler, .ot-remove-objection-handler, .ot-obj-leg-btn-handler, [aria-expanded], .ot-link-btn), +#onetrust-consent-sdk + #onetrust-pc-sdk + button:not( + #clear-filters-handler, + .ot-close-icon, + #filter-btn-handler, + .ot-remove-objection-handler, + .ot-obj-leg-btn-handler, + [aria-expanded], + .ot-link-btn + ), #onetrust-banner-sdk #onetrust-reject-all-handler, #onetrust-consent-sdk #onetrust-accept-btn-handler { background-color: var(--link-color) !important; @@ -385,7 +532,7 @@ main .border-top { line-height: 1.2; color: #333; font-weight: 400; - margin-bottom: 40px + margin-bottom: 40px; } .article em { @@ -394,7 +541,7 @@ main .border-top { @media (width >= 960px) { .article h1 { - font-size:2.625rem + font-size: 2.625rem; } } From c0d30a86780b38f6504a35f7cd153df5a3e5bf89 Mon Sep 17 00:00:00 2001 From: Tomasz Dziezyk Date: Mon, 2 Sep 2024 11:22:48 +0200 Subject: [PATCH 002/159] Update button styles --- styles/styles.css | 190 ++++++++++++++++++++++++++++++++++------------ 1 file changed, 141 insertions(+), 49 deletions(-) diff --git a/styles/styles.css b/styles/styles.css index f17c9b9..d479463 100644 --- a/styles/styles.css +++ b/styles/styles.css @@ -30,7 +30,7 @@ --grey-20: #ccc; --grey-30: #b3b3b3; --grey-40: #999; - --grey-50: #8080; + --grey-50: #808080; --grey-60: #666; --grey-70: #4d4d4d; --grey-80: #333; @@ -52,7 +52,10 @@ --light-color: #eee; --dark-color: #ccc; --text-color: #1d1d1b; +} +.dark { + background-color: var(--black); } :root .dark { @@ -61,6 +64,10 @@ --action-focus: #999; } +* { + box-sizing: border-box; +} + body { font-size: var(--body-font-size); font-weight: 500; @@ -72,7 +79,7 @@ body { background-color: var(--c-primary-white); display: none; -webkit-font-smoothing: antialiased; - font-feature-settings: 'liga' off, 'clig' off; + font-feature-settings: "liga" off, "clig" off; } body.appear { @@ -289,16 +296,6 @@ main pre { white-space: pre; } -/* links */ -a:any-link { - color: var(--link-color); - text-decoration: none; -} - -a:hover { - color: var(--link-hover-color); -} - /* buttons */ a.button:any-link, button { @@ -311,43 +308,151 @@ button { overflow: hidden; text-overflow: ellipsis; margin: 0; - padding: 0 30px; - vertical-align: middle; - font-size: 0.875rem; - line-height: 38px; - text-align: center; - display: inline-block; - transition: 0.1s ease-in-out; - transition-property: color, background-color, background-position, - background-size, border-color, box-shadow; + display: inline-flex; + align-items: center; + justify-content: center; + gap: 8px; + flex-shrink: 0; + background: var(--white); + color: var(--action-default); + font-size: 1rem; + line-height: 150%; font-weight: 600; - text-transform: uppercase; - border-radius: 0; - background-color: var(--button-color); - color: var(--c-primary-white); - border: 1px solid var(--button-color); + border: unset; + padding: 0; + letter-spacing: 0.44px; } -a.button:active { - background-color: #c00; - border-color: transparent; +a.button:hover, +button:hover { + color: var(--action-hover); } -a.button:hover, a.button:focus, -button:hover, button:focus { - background-color: rgb(255 0 0 / 0%); - color: var(--link-hover-color); - border-color: var(--link-hover-color); + color: var(--action-focus); + outline: none; } button:disabled, button:disabled:hover { cursor: not-allowed; + color: var(--grey-50); + border: none; +} + +a.button.primary:any-link, +button.primary, +a.button.secondary:any-link, +button.secondary { + padding: 0 20px; + border-radius: 24px; + height: 48px; +} + +a.button.primary:any-link, +button.primary { + background: var(--action-default); + color: var(--white); + border: solid 1px var(--action-default); +} + +a.button.secondary:any-link, +button.secondary { + background: var(--white); + color: var(--action-default); + border: 1px solid var(--action-default); +} + +a.button.primary:hover, +button.primary:hover, +a.button.secondary:hover, +button.secondary:hover { + color: var(--action-hover); + background: var(--white); + border: 1px solid var(--action-hover); +} + +a.button.primary:focus, +button.primary:focus, +a.button.secondary:focus, +button.secondary:focus { + color: var(--action-focus); + background: var(--white); + border: 1px solid var(--action-focus); + outline: none; +} + +button.primary:disabled, +button.primary:disabled:hover, +button.primary:disabled:focus { + cursor: not-allowed; + background-color: var(--grey-20); + color: var(--grey-50); + border-color: var(--grey-20); +} + +button.secondary:disabled, +button.secondary:disabled:hover { + cursor: not-allowed; + background-color: var(--white); + color: var(--grey-50); + border-color: var(--grey-50); +} + +a.button.small, +button.small, +a.button.primary.small, +button.primary.small, +a.button.secondary.small, +button.secondary.small { + font-size: 0.75rem; + height: auto; +} + +a.button.primary.small, +button.primary.small, +a.button.secondary.small, +button.secondary.small { + padding: 3px 12px; +} + +.dark a.button:any-link, +.dark button { background-color: transparent; - color: #999; - border: 1px solid #e5e5e5; +} + +.dark a.button.primary, +.dark button.primary { + background: var(--white); + color: var(--black); +} + +.dark a.button.primary:hover, +.dark button.primary:hover { + color: #ed1c24; + border-color: #ed1c24; +} + +.dark a.button.primary:focus, +.dark button.primary:focus { + color: #82221D; + border-color: #82221D; + background: var(--action-hover); +} + +.dark .button:disabled, +.dark .button:disabled:focus, +.dark .button:disabled:hover { + color: var(--grey-40); + border-color: var(--grey-40); + background: transparent; +} + +.dark .button.primary:disabled, +.dark .button.primary:disabled:focus, +.dark .button.primary:disabled:hover { + background: var(--grey-70); } main img { @@ -475,19 +580,6 @@ main .border-top { padding-top: 40px; } -.button.secondary:any-link { - background-color: transparent; - border: none; - color: var(--link-color); - font-weight: 400; - font-size: 16px; - text-transform: capitalize; -} - -.button.secondary:any-link:hover { - color: var(--text-color); -} - .section-small { max-width: 900px; margin: auto; From f2939cf49c698a094753682b1c6a3e8a36eaca5e Mon Sep 17 00:00:00 2001 From: Tomasz Dziezyk Date: Mon, 2 Sep 2024 11:28:42 +0200 Subject: [PATCH 003/159] Remove unused code --- styles/styles.css | 31 ------------------------------- 1 file changed, 31 deletions(-) diff --git a/styles/styles.css b/styles/styles.css index d479463..7a9b17c 100644 --- a/styles/styles.css +++ b/styles/styles.css @@ -523,16 +523,6 @@ main .section.padding-bottom-0 { .section > div.full-width { max-width: 100vw; } - - h1, - .h1 { - font-size: 2.125rem; - } - - h2, - .h2 { - font-size: 2rem; - } } /* full width styles */ @@ -617,24 +607,3 @@ main .border-top { background-color: var(--link-color) !important; border-color: transparent !important; } - -/* article styles - start */ -.article h1 { - font-size: 2.2313rem; - line-height: 1.2; - color: #333; - font-weight: 400; - margin-bottom: 40px; -} - -.article em { - color: rgb(240 80 110); -} - -@media (width >= 960px) { - .article h1 { - font-size: 2.625rem; - } -} - -/* article styles - end */ From 7ef8216fb663884d17e47784a468f02cbb85e383 Mon Sep 17 00:00:00 2001 From: Tomasz Dziezyk Date: Mon, 2 Sep 2024 11:32:05 +0200 Subject: [PATCH 004/159] Fix styles of links inside the text --- styles/styles.css | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/styles/styles.css b/styles/styles.css index 7a9b17c..2694907 100644 --- a/styles/styles.css +++ b/styles/styles.css @@ -297,7 +297,7 @@ main pre { } /* buttons */ -a.button:any-link, +a:any-link, button { font-family: var(--body-font-family); box-sizing: border-box; @@ -323,12 +323,12 @@ button { letter-spacing: 0.44px; } -a.button:hover, +a:hover, button:hover { color: var(--action-hover); } -a.button:focus, +a:focus, button:focus { color: var(--action-focus); outline: none; @@ -417,7 +417,7 @@ button.secondary.small { padding: 3px 12px; } -.dark a.button:any-link, +.dark a:any-link, .dark button { background-color: transparent; } From 651e1577d9ce9b20eb6b477c987469d768a37e17 Mon Sep 17 00:00:00 2001 From: Tomasz Dziezyk Date: Mon, 2 Sep 2024 11:33:31 +0200 Subject: [PATCH 005/159] Fix background color for link --- styles/styles.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/styles/styles.css b/styles/styles.css index 2694907..19b3eca 100644 --- a/styles/styles.css +++ b/styles/styles.css @@ -313,7 +313,7 @@ button { justify-content: center; gap: 8px; flex-shrink: 0; - background: var(--white); + background: transparent; color: var(--action-default); font-size: 1rem; line-height: 150%; From 1adee4f30fd1ab33ead06caf3cc2442295c98c24 Mon Sep 17 00:00:00 2001 From: Tomasz Dziezyk Date: Mon, 2 Sep 2024 12:35:33 +0200 Subject: [PATCH 006/159] Fix buttons's secondary style for dark background --- styles/styles.css | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/styles/styles.css b/styles/styles.css index 19b3eca..7d4b85c 100644 --- a/styles/styles.css +++ b/styles/styles.css @@ -428,6 +428,11 @@ button.secondary.small { color: var(--black); } +.dark a.button.secondary:any-link, +.dark button.secondary { + background-color: transparent; +} + .dark a.button.primary:hover, .dark button.primary:hover { color: #ed1c24; From 3d067f02ff88a23fc86a95410bdc85e9d9244684 Mon Sep 17 00:00:00 2001 From: Ioana Iordache Date: Wed, 4 Sep 2024 12:18:51 +0200 Subject: [PATCH 007/159] KAW-7905: add new footer design v2 --- blocks/footer/footer.css | 115 ++++++++++++++++++++------------------- blocks/footer/footer.js | 58 ++++++++++---------- icons/facebook.svg | 4 +- icons/instagram.svg | 3 + icons/logo-flag.svg | 6 ++ icons/x.svg | 3 + icons/youtube.svg | 6 +- scripts/helpers.js | 7 +++ styles/styles.css | 2 - 9 files changed, 113 insertions(+), 91 deletions(-) create mode 100644 icons/instagram.svg create mode 100644 icons/logo-flag.svg create mode 100644 icons/x.svg diff --git a/blocks/footer/footer.css b/blocks/footer/footer.css index fb981eb..50359a8 100644 --- a/blocks/footer/footer.css +++ b/blocks/footer/footer.css @@ -1,27 +1,24 @@ footer { background-color: #222; color: var(--c-primary-white); + position: relative; + padding: 0 20px; } -.footer .section { - padding: 40px 15px 0; -} - -.footer .section:last-child { - padding-bottom: 40px; +.footer .columns-container .columns-wrapper { + padding-top: 40px; } -.footer .footer-logo img { - width: 250px; - height: auto; +.footer .footer-column > * { + margin: 0; } -.footer .footer-column > * { +.footer .footer-column:first-child { margin: 0; } -.footer .columns .footer-column { - padding-bottom: 60px; +.footer .block.columns .footer-column { + padding-bottom: 20px; position: relative; margin: 0; } @@ -30,17 +27,10 @@ footer { padding-bottom: 0; } -.footer .footer-column::after { - border-top: 1px solid rgb(255 255 255 / 20%); - content: ""; - display: block; - width: 100%; - position: absolute; - bottom: 30px; -} - -.footer .footer-column:last-child::after { - display: none; +.footer .footer-column:last-child ul { + display: flex; + flex-direction: row; + gap: 20px; } .footer .footer-column ul { @@ -52,11 +42,14 @@ footer { flex-direction: column; } +.footer .footer-column .font-small { + color: var(--grey-20); +} + .footer .footer-list-item { display: flex; gap: 15px; align-items: center; - color: rgb(255 255 255 / 70%); } .footer .footer-list-item a { @@ -64,14 +57,25 @@ footer { display: flex; gap: 15px; align-items: center; + font-weight: normal; } .footer .footer-list-item a:hover, .footer .footer-list-item a:active { - color: var(--c-primary-white); + color: var(--action-hover); text-decoration: none; } +.footer .footer-list-item a:focus { + color: var(--action-focus); + text-decoration: none; +} + +.footer .footer-list-item a:has(span.icon):focus, +.footer .footer-list-item a:has(span.icon):hover { + filter: brightness(2); +} + .footer .back-to-top { position: relative; display: flex; @@ -97,7 +101,6 @@ footer { } .footer .section .default-content-wrapper { - padding-top: 10px; text-align: center; font-size: 14px; line-height: 19.6px; @@ -107,19 +110,37 @@ footer { margin-bottom: 10px; } +.footer .section .default-content-wrapper .icon { + width: auto; + height: auto; + position: absolute; + right: 40px; + top: 0; +} .footer .section .default-content-wrapper p:last-child { margin-bottom: 0; } -.footer .footer-list-item .icon { - min-width: 20px; - width: 20px; - height: auto; +.footer .default-content-wrapper ul { + display: flex; + gap: 40px; + justify-content: center; + padding: 0; +} + +.footer .section:not(.columns-container) .default-content-wrapper { + display: flex; + justify-content: center; + flex-direction: column; + padding: 40px 0; + align-items: flex-start; + font-size: 16px; + line-height: 1.5; } @media (width >= 768px) { - .footer .section { - padding: 40px 30px; + footer { + padding: 0 40px; } .footer .columns > div { @@ -130,31 +151,18 @@ footer { .footer .columns .footer-column { width: calc(50% - 30px); padding-bottom: 0; - margin-top: 30px; } - .footer .footer-column::after { - width: 1px; - height: 100%; - border-top: unset; - border-right: 1px solid rgb(255 255 255 / 20%); - top: 0; - right: -30px; + .footer .section:not(.columns-container) .default-content-wrapper { + flex-direction: row; + gap: 40px; } } @media (width >= 960px) { - .footer { - padding-top: 30px; - } - - .footer .section { - padding-left: 40px; - padding-right: 40px; - } .footer .columns > div { - gap: 60px; + gap: 24px; align-items: stretch; } @@ -163,12 +171,7 @@ footer { gap: 60px; } - .footer .footer-logo .icon { - width: 100%; - height: auto; - } - - .footer .footer-logo img { - width: auto; + .footer .section:not(.columns-container) .default-content-wrapper { + justify-content: center; } } diff --git a/blocks/footer/footer.js b/blocks/footer/footer.js index ba5798c..73bbfb6 100644 --- a/blocks/footer/footer.js +++ b/blocks/footer/footer.js @@ -1,6 +1,7 @@ import { getMetadata } from '../../scripts/aem.js'; -import { getTextLabel } from '../../scripts/scripts.js'; +// import { getTextLabel } from '../../scripts/scripts.js'; import { loadFragment } from '../fragment/fragment.js'; +import { addTitleAttributeToIconLink } from '../../scripts/helpers.js'; /** * loads and decorates the footer @@ -19,17 +20,17 @@ export default async function decorate(block) { const columns = [...footer.querySelectorAll('.columns > div > div')]; columns.forEach((column) => { - // if the element contains only image => logo - if (column.childElementCount === 1 && column.querySelector('p > span > img')) { - column.classList.add('footer-logo'); - } - column.classList.add('footer-column'); - // each heading should be rendered as h3 - [...column.querySelectorAll('h1, h2, h3, h4, h5, h6')].forEach((heading) => heading.classList.add('h3')); + // each heading should be rendered as font-small + [...column.querySelectorAll('h1, h2, h3, h4, h5, h6')].forEach((heading) => heading.classList.add('font-small')); }); + // a11y for social icons + const socialIconLinks = footer.querySelectorAll('.footer-column:has(a[title=""]) a[title=""]'); + console.log('🚀 ~ decorate ~ socialIcons:', socialIconLinks); + socialIconLinks.forEach((anchor) => addTitleAttributeToIconLink(anchor)); + const lists = [...footer.querySelectorAll('ul')]; lists.forEach((list) => { [...list.querySelectorAll(':scope > li')].forEach((listItem) => { @@ -48,30 +49,31 @@ export default async function decorate(block) { }); }); - // add back to top button - const backToTopIcon = ` - - - - `; + // TODO add back to top button + // const backToTopIcon = ` + // + // + // + // + // `; - const backToTopText = getTextLabel('top'); + // const backToTopText = getTextLabel('top'); - const backToTopNode = document.createRange().createContextualFragment(` - - `); + // const backToTopNode = document.createRange().createContextualFragment(` + // + // `); - footer.querySelector('.section:last-child').prepend(backToTopNode); + // footer.querySelector('.section:last-child').prepend(backToTopNode); - footer.querySelector('.back-to-top').addEventListener('click', () => { - window.scrollTo({ - top: 0, - behavior: 'smooth', - }); - }); + // footer.querySelector('.back-to-top').addEventListener('click', () => { + // window.scrollTo({ + // top: 0, + // behavior: 'smooth', + // }); + // }); block.append(footer); } diff --git a/icons/facebook.svg b/icons/facebook.svg index 3988481..f950f1f 100644 --- a/icons/facebook.svg +++ b/icons/facebook.svg @@ -1,3 +1,3 @@ - - + + \ No newline at end of file diff --git a/icons/instagram.svg b/icons/instagram.svg new file mode 100644 index 0000000..db6d5d0 --- /dev/null +++ b/icons/instagram.svg @@ -0,0 +1,3 @@ + + + diff --git a/icons/logo-flag.svg b/icons/logo-flag.svg new file mode 100644 index 0000000..75f710c --- /dev/null +++ b/icons/logo-flag.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/icons/x.svg b/icons/x.svg new file mode 100644 index 0000000..4ea80ef --- /dev/null +++ b/icons/x.svg @@ -0,0 +1,3 @@ + + + diff --git a/icons/youtube.svg b/icons/youtube.svg index cefd4d6..a31b671 100644 --- a/icons/youtube.svg +++ b/icons/youtube.svg @@ -1,3 +1,3 @@ - - - \ No newline at end of file + + + diff --git a/scripts/helpers.js b/scripts/helpers.js index c4a8da0..999bb65 100644 --- a/scripts/helpers.js +++ b/scripts/helpers.js @@ -62,3 +62,10 @@ export function callOnIntersection(elements, onChange) { observer.observe(video); }); } + +export function addTitleAttributeToIconLink(element) { + const iconElement = element.querySelector('[data-icon-name]'); + if (iconElement) { + element.setAttribute('title', iconElement.getAttribute('data-icon-name')); + } +} diff --git a/styles/styles.css b/styles/styles.css index 7d4b85c..2620f91 100644 --- a/styles/styles.css +++ b/styles/styles.css @@ -468,8 +468,6 @@ main img { .icon { display: inline-block; - height: 20px; - width: 20px; } .icon img { From ee2b7fa87b34ba0457231aa57f97f10a7598009c Mon Sep 17 00:00:00 2001 From: Ioana Iordache Date: Wed, 4 Sep 2024 14:53:27 +0200 Subject: [PATCH 008/159] KAW-7905: remove console statement --- blocks/footer/footer.js | 1 - 1 file changed, 1 deletion(-) diff --git a/blocks/footer/footer.js b/blocks/footer/footer.js index 73bbfb6..b20570f 100644 --- a/blocks/footer/footer.js +++ b/blocks/footer/footer.js @@ -28,7 +28,6 @@ export default async function decorate(block) { // a11y for social icons const socialIconLinks = footer.querySelectorAll('.footer-column:has(a[title=""]) a[title=""]'); - console.log('🚀 ~ decorate ~ socialIcons:', socialIconLinks); socialIconLinks.forEach((anchor) => addTitleAttributeToIconLink(anchor)); const lists = [...footer.querySelectorAll('ul')]; From 00c8a960c219cc1f0b3e773702698729e9e2ff25 Mon Sep 17 00:00:00 2001 From: Ioana Iordache Date: Wed, 4 Sep 2024 15:02:21 +0200 Subject: [PATCH 009/159] KAW-7905: fix build --- blocks/footer/footer.css | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/blocks/footer/footer.css b/blocks/footer/footer.css index 50359a8..a98c38e 100644 --- a/blocks/footer/footer.css +++ b/blocks/footer/footer.css @@ -17,20 +17,14 @@ footer { margin: 0; } -.footer .block.columns .footer-column { - padding-bottom: 20px; - position: relative; - margin: 0; -} - .footer .footer-column:last-child { padding-bottom: 0; } -.footer .footer-column:last-child ul { - display: flex; - flex-direction: row; - gap: 20px; +.footer .block.columns .footer-column { + padding-bottom: 20px; + position: relative; + margin: 0; } .footer .footer-column ul { @@ -117,11 +111,12 @@ footer { right: 40px; top: 0; } + .footer .section .default-content-wrapper p:last-child { margin-bottom: 0; } -.footer .default-content-wrapper ul { +.footer .section .default-content-wrapper ul { display: flex; gap: 40px; justify-content: center; @@ -160,7 +155,6 @@ footer { } @media (width >= 960px) { - .footer .columns > div { gap: 24px; align-items: stretch; From 3eab626e520ff223b0482bbccd62f0c0a603edd8 Mon Sep 17 00:00:00 2001 From: Ioana Iordache Date: Thu, 5 Sep 2024 13:50:57 +0200 Subject: [PATCH 010/159] KAW-7905: aadress pr comments --- blocks/footer/footer.css | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/blocks/footer/footer.css b/blocks/footer/footer.css index a98c38e..067e6b6 100644 --- a/blocks/footer/footer.css +++ b/blocks/footer/footer.css @@ -32,10 +32,15 @@ footer { padding: 0; list-style: none; display: flex; - gap: 10px; + gap: 24px; flex-direction: column; } +.footer .footer-column:last-child ul { + flex-direction: row; + gap: 20px; +} + .footer .footer-column .font-small { color: var(--grey-20); } @@ -82,7 +87,7 @@ footer { border: unset; color: rgb(255 255 255 / 50%); font-size: 16px; - line-height: 24px; + line-height: 150%; } .footer .back-to-top:hover, @@ -97,11 +102,11 @@ footer { .footer .section .default-content-wrapper { text-align: center; font-size: 14px; - line-height: 19.6px; + line-height: 150%; } .footer .section .default-content-wrapper p { - margin-bottom: 10px; + margin-bottom: 0; } .footer .section .default-content-wrapper .icon { @@ -121,6 +126,7 @@ footer { gap: 40px; justify-content: center; padding: 0; + margin-bottom: 0; } .footer .section:not(.columns-container) .default-content-wrapper { @@ -130,7 +136,7 @@ footer { padding: 40px 0; align-items: flex-start; font-size: 16px; - line-height: 1.5; + line-height: 150%; } @media (width >= 768px) { From f22455a9f703a07c466a9be0c0802ac7e4b9f1e0 Mon Sep 17 00:00:00 2001 From: Ioana Iordache Date: Mon, 9 Sep 2024 10:09:44 +0200 Subject: [PATCH 011/159] KAW-7905: add back to top button --- blocks/footer/footer.css | 25 ++++++++--------- blocks/footer/footer.js | 59 +++++++++++++++++++++++++--------------- icons/chevron-up.svg | 4 +++ 3 files changed, 53 insertions(+), 35 deletions(-) create mode 100644 icons/chevron-up.svg diff --git a/blocks/footer/footer.css b/blocks/footer/footer.css index 067e6b6..c443d6b 100644 --- a/blocks/footer/footer.css +++ b/blocks/footer/footer.css @@ -76,23 +76,22 @@ footer { } .footer .back-to-top { - position: relative; - display: flex; - flex-direction: column; - gap: 0; - align-items: center; - margin: auto; - padding: 0; - background: inherit; - border: unset; - color: rgb(255 255 255 / 50%); - font-size: 16px; - line-height: 150%; + width: 32px; + height: 32px; + position: fixed; + right: 20px; + bottom: 40px; + display: none; + background-color: var(--grey-10); + color: var(--white); + border: none; + cursor: pointer; + z-index: 1000; } .footer .back-to-top:hover, .footer .back-to-top:focus { - color: rgb(255 255 255 / 70%); + background-color: var(--grey-30); } .footer .back-to-top svg { diff --git a/blocks/footer/footer.js b/blocks/footer/footer.js index b20570f..15c5068 100644 --- a/blocks/footer/footer.js +++ b/blocks/footer/footer.js @@ -1,5 +1,4 @@ import { getMetadata } from '../../scripts/aem.js'; -// import { getTextLabel } from '../../scripts/scripts.js'; import { loadFragment } from '../fragment/fragment.js'; import { addTitleAttributeToIconLink } from '../../scripts/helpers.js'; @@ -48,31 +47,47 @@ export default async function decorate(block) { }); }); - // TODO add back to top button - // const backToTopIcon = ` - // - // - // - // - // `; + // Back to top button + const backToTopNode = document.createRange().createContextualFragment(` + + + `); - // const backToTopText = getTextLabel('top'); + footer.prepend(backToTopNode); - // const backToTopNode = document.createRange().createContextualFragment(` - // - // `); + const backToTopButton = footer.querySelector('.back-to-top'); + const observer = new IntersectionObserver((entries) => { + entries.forEach((entry) => { + if (entry.isIntersecting) { + backToTopButton.style.position = 'absolute'; + backToTopButton.style.bottom = `${entry.boundingClientRect.height + 80}px`; + } else { + backToTopButton.style.position = 'fixed'; + backToTopButton.style.bottom = '80px'; + } + }); + }); + observer.observe(footer); - // footer.querySelector('.section:last-child').prepend(backToTopNode); + window.addEventListener('scroll', () => { + const scrollPosition = window.scrollY + window.innerHeight; + const documentHeight = document.documentElement.scrollHeight; - // footer.querySelector('.back-to-top').addEventListener('click', () => { - // window.scrollTo({ - // top: 0, - // behavior: 'smooth', - // }); - // }); + // Display button if user scrolls close to the bottom, 40px above the footer + if (scrollPosition >= documentHeight / 3) { + backToTopButton.style.display = 'block'; + } else { + backToTopButton.style.display = 'none'; + } + }); + + footer.querySelector('.back-to-top').addEventListener('click', () => { + window.scrollTo({ + top: 0, + behavior: 'smooth', + }); + }); block.append(footer); } diff --git a/icons/chevron-up.svg b/icons/chevron-up.svg new file mode 100644 index 0000000..ba5fad3 --- /dev/null +++ b/icons/chevron-up.svg @@ -0,0 +1,4 @@ + + + + \ No newline at end of file From aaea6d6cee2ab8ad2c7e8b778b0af3ceb81bc76a Mon Sep 17 00:00:00 2001 From: Ioana Iordache Date: Mon, 9 Sep 2024 11:36:53 +0200 Subject: [PATCH 012/159] KAW-7905: add updated viewport and limit back-to-top on dealer pages --- blocks/footer/footer.css | 2 +- blocks/footer/footer.js | 61 +++++++++++++++++++++------------------- 2 files changed, 33 insertions(+), 30 deletions(-) diff --git a/blocks/footer/footer.css b/blocks/footer/footer.css index c443d6b..925044b 100644 --- a/blocks/footer/footer.css +++ b/blocks/footer/footer.css @@ -159,7 +159,7 @@ footer { } } -@media (width >= 960px) { +@media (width >= 1024px) { .footer .columns > div { gap: 24px; align-items: stretch; diff --git a/blocks/footer/footer.js b/blocks/footer/footer.js index 15c5068..671ce85 100644 --- a/blocks/footer/footer.js +++ b/blocks/footer/footer.js @@ -48,46 +48,49 @@ export default async function decorate(block) { }); // Back to top button - const backToTopNode = document.createRange().createContextualFragment(` + const path = window.location.pathname; + if (!(path.includes('importatori-dealer') || path.includes('import-dealers'))) { + const backToTopNode = document.createRange().createContextualFragment(` `); - footer.prepend(backToTopNode); + footer.prepend(backToTopNode); - const backToTopButton = footer.querySelector('.back-to-top'); - const observer = new IntersectionObserver((entries) => { - entries.forEach((entry) => { - if (entry.isIntersecting) { - backToTopButton.style.position = 'absolute'; - backToTopButton.style.bottom = `${entry.boundingClientRect.height + 80}px`; - } else { - backToTopButton.style.position = 'fixed'; - backToTopButton.style.bottom = '80px'; - } + const backToTopButton = footer.querySelector('.back-to-top'); + const observer = new IntersectionObserver((entries) => { + entries.forEach((entry) => { + if (entry.isIntersecting) { + backToTopButton.style.position = 'absolute'; + backToTopButton.style.bottom = `${entry.boundingClientRect.height + 80}px`; + } else { + backToTopButton.style.position = 'fixed'; + backToTopButton.style.bottom = '80px'; + } + }); }); - }); - observer.observe(footer); + observer.observe(footer); - window.addEventListener('scroll', () => { - const scrollPosition = window.scrollY + window.innerHeight; - const documentHeight = document.documentElement.scrollHeight; + window.addEventListener('scroll', () => { + const scrollPosition = window.scrollY + window.innerHeight; + const documentHeight = document.documentElement.scrollHeight; - // Display button if user scrolls close to the bottom, 40px above the footer - if (scrollPosition >= documentHeight / 3) { - backToTopButton.style.display = 'block'; - } else { - backToTopButton.style.display = 'none'; - } - }); + // Display button if user scrolls close to the bottom, 40px above the footer + if (scrollPosition >= documentHeight / 3) { + backToTopButton.style.display = 'block'; + } else { + backToTopButton.style.display = 'none'; + } + }); - footer.querySelector('.back-to-top').addEventListener('click', () => { - window.scrollTo({ - top: 0, - behavior: 'smooth', + footer.querySelector('.back-to-top').addEventListener('click', () => { + window.scrollTo({ + top: 0, + behavior: 'smooth', + }); }); - }); + } block.append(footer); } From c2723ba836ebf0fbfc99f749a5b0a8f8788fef6b Mon Sep 17 00:00:00 2001 From: Ioana Iordache Date: Mon, 9 Sep 2024 13:53:26 +0200 Subject: [PATCH 013/159] KAW-7905: footer updates --- blocks/footer/footer.css | 16 +++++------ blocks/footer/footer.js | 61 +++++++++++++++++++--------------------- 2 files changed, 36 insertions(+), 41 deletions(-) diff --git a/blocks/footer/footer.css b/blocks/footer/footer.css index 925044b..f73ba32 100644 --- a/blocks/footer/footer.css +++ b/blocks/footer/footer.css @@ -1,5 +1,5 @@ footer { - background-color: #222; + background-color: var(--black); color: var(--c-primary-white); position: relative; padding: 0 20px; @@ -13,12 +13,9 @@ footer { margin: 0; } -.footer .footer-column:first-child { - margin: 0; -} - .footer .footer-column:last-child { padding-bottom: 0; + margin: 0; } .footer .block.columns .footer-column { @@ -28,11 +25,11 @@ footer { } .footer .footer-column ul { - margin-top: 20px; + margin-top: 24px; padding: 0; list-style: none; display: flex; - gap: 24px; + gap: 16px; flex-direction: column; } @@ -52,6 +49,7 @@ footer { } .footer .footer-list-item a { + border-bottom: 1px solid transparent; color: var(--c-primary-white); display: flex; gap: 15px; @@ -61,8 +59,7 @@ footer { .footer .footer-list-item a:hover, .footer .footer-list-item a:active { - color: var(--action-hover); - text-decoration: none; + border-bottom: 1px solid var(--c-primary-white); } .footer .footer-list-item a:focus { @@ -73,6 +70,7 @@ footer { .footer .footer-list-item a:has(span.icon):focus, .footer .footer-list-item a:has(span.icon):hover { filter: brightness(2); + border: none; } .footer .back-to-top { diff --git a/blocks/footer/footer.js b/blocks/footer/footer.js index 671ce85..15c5068 100644 --- a/blocks/footer/footer.js +++ b/blocks/footer/footer.js @@ -48,49 +48,46 @@ export default async function decorate(block) { }); // Back to top button - const path = window.location.pathname; - if (!(path.includes('importatori-dealer') || path.includes('import-dealers'))) { - const backToTopNode = document.createRange().createContextualFragment(` + const backToTopNode = document.createRange().createContextualFragment(` `); - footer.prepend(backToTopNode); + footer.prepend(backToTopNode); - const backToTopButton = footer.querySelector('.back-to-top'); - const observer = new IntersectionObserver((entries) => { - entries.forEach((entry) => { - if (entry.isIntersecting) { - backToTopButton.style.position = 'absolute'; - backToTopButton.style.bottom = `${entry.boundingClientRect.height + 80}px`; - } else { - backToTopButton.style.position = 'fixed'; - backToTopButton.style.bottom = '80px'; - } - }); - }); - observer.observe(footer); - - window.addEventListener('scroll', () => { - const scrollPosition = window.scrollY + window.innerHeight; - const documentHeight = document.documentElement.scrollHeight; - - // Display button if user scrolls close to the bottom, 40px above the footer - if (scrollPosition >= documentHeight / 3) { - backToTopButton.style.display = 'block'; + const backToTopButton = footer.querySelector('.back-to-top'); + const observer = new IntersectionObserver((entries) => { + entries.forEach((entry) => { + if (entry.isIntersecting) { + backToTopButton.style.position = 'absolute'; + backToTopButton.style.bottom = `${entry.boundingClientRect.height + 80}px`; } else { - backToTopButton.style.display = 'none'; + backToTopButton.style.position = 'fixed'; + backToTopButton.style.bottom = '80px'; } }); + }); + observer.observe(footer); - footer.querySelector('.back-to-top').addEventListener('click', () => { - window.scrollTo({ - top: 0, - behavior: 'smooth', - }); + window.addEventListener('scroll', () => { + const scrollPosition = window.scrollY + window.innerHeight; + const documentHeight = document.documentElement.scrollHeight; + + // Display button if user scrolls close to the bottom, 40px above the footer + if (scrollPosition >= documentHeight / 3) { + backToTopButton.style.display = 'block'; + } else { + backToTopButton.style.display = 'none'; + } + }); + + footer.querySelector('.back-to-top').addEventListener('click', () => { + window.scrollTo({ + top: 0, + behavior: 'smooth', }); - } + }); block.append(footer); } From eb80a94e18d2d5da3785a382a153464cafa69fba Mon Sep 17 00:00:00 2001 From: Ioana Iordache Date: Mon, 9 Sep 2024 15:35:37 +0200 Subject: [PATCH 014/159] KAW-7905: correct link states --- blocks/footer/footer.css | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/blocks/footer/footer.css b/blocks/footer/footer.css index f73ba32..71c2cfb 100644 --- a/blocks/footer/footer.css +++ b/blocks/footer/footer.css @@ -58,19 +58,17 @@ footer { } .footer .footer-list-item a:hover, +.footer .footer-list-item a:focus, .footer .footer-list-item a:active { border-bottom: 1px solid var(--c-primary-white); } -.footer .footer-list-item a:focus { - color: var(--action-focus); - text-decoration: none; -} +.footer .footer-list-item a:has(span.icon):hover, .footer .footer-list-item a:has(span.icon):focus, -.footer .footer-list-item a:has(span.icon):hover { +.footer .footer-list-item a:has(span.icon):active { filter: brightness(2); - border: none; + border-bottom: 1px solid transparent; } .footer .back-to-top { From 7a4d5f98406fb53ab2dcf47268b49736ebe67c40 Mon Sep 17 00:00:00 2001 From: Lakshmishri Date: Mon, 9 Sep 2024 16:54:00 +0200 Subject: [PATCH 015/159] add localhost for not loading cookies --- scripts/delayed.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/delayed.js b/scripts/delayed.js index c111c14..98ffa15 100644 --- a/scripts/delayed.js +++ b/scripts/delayed.js @@ -2,7 +2,7 @@ import { loadScript } from './aem.js'; // OneTrust Cookies Consent Notice if (!window.location.pathname.includes('srcdoc') - && !['hlx.live', 'aem.page', 'aem.live'].some((url) => window.location.host.includes(url))) { + && !['localhost', 'hlx.live', 'aem.page', 'aem.live'].some((url) => window.location.host.includes(url))) { // when running on localhost in the block library host is empty but the path is srcdoc // on localhost/hlx.page/hlx.live the consent notice is displayed every time the page opens, // because the cookie is not persistent. To avoid this annoyance, disable unless on the From 598088797032e0470f6eb5d5e6244df2295f1ffc Mon Sep 17 00:00:00 2001 From: Lakshmishri Date: Mon, 9 Sep 2024 16:57:23 +0200 Subject: [PATCH 016/159] add dev env to not show cookies consent --- scripts/delayed.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/delayed.js b/scripts/delayed.js index 98ffa15..143c9ee 100644 --- a/scripts/delayed.js +++ b/scripts/delayed.js @@ -2,7 +2,7 @@ import { loadScript } from './aem.js'; // OneTrust Cookies Consent Notice if (!window.location.pathname.includes('srcdoc') - && !['localhost', 'hlx.live', 'aem.page', 'aem.live'].some((url) => window.location.host.includes(url))) { + && !['localhost', 'hlx.page', 'hlx.live', 'aem.page', 'aem.live'].some((url) => window.location.host.includes(url))) { // when running on localhost in the block library host is empty but the path is srcdoc // on localhost/hlx.page/hlx.live the consent notice is displayed every time the page opens, // because the cookie is not persistent. To avoid this annoyance, disable unless on the From f7254e046df545aea266e2d1be52f6ec5352ed15 Mon Sep 17 00:00:00 2001 From: Lakshmishri Date: Wed, 11 Sep 2024 09:51:06 +0200 Subject: [PATCH 017/159] KAW-7936 wire up title component --- blocks/title/title.css | 62 ++++++++++++++++++++++++++++++++++++++++++ blocks/title/title.js | 31 +++++++++++++++++++++ scripts/helpers.js | 54 ++++++++++++++++++++++++++++++++++++ styles/styles.css | 11 ++++---- 4 files changed, 153 insertions(+), 5 deletions(-) create mode 100644 blocks/title/title.css create mode 100644 blocks/title/title.js diff --git a/blocks/title/title.css b/blocks/title/title.css new file mode 100644 index 0000000..210af2d --- /dev/null +++ b/blocks/title/title.css @@ -0,0 +1,62 @@ +.title { + padding-top: 40px; + padding-bottom: 60px; + max-width: 616px; + display: flex; + flex-flow: column; + gap: 12px; +} + +.heading { + margin: 0; + + strong { + font-weight: normal; + color: var(--text-red); + } +} + +.title.line { + padding-top: 80px; + padding-bottom: 40px; + align-items: center; +} + +.vertical-line-wrapper { + height: 80px; + width: 2px; + align-items: flex-end; + display: flex; +} + +.vertical-line { + height: 20px; + width: 2px; + background-color: var(--text-red); +} + +.vertical-line.animate { + height: 80px; + transition: height 5s ease-in-out; +} + +@media (width >= 768px) { + .title { + max-width: 784px; + padding-top: 60px; + padding-bottom: 60px; + } + + .title.line { + padding-top: 120px; + padding-bottom: 60px; + } +} + +@media (width >= 1024px) { + .title { + max-width: 924px; + padding-top: 80px; + padding-bottom: 120px; + } +} \ No newline at end of file diff --git a/blocks/title/title.js b/blocks/title/title.js new file mode 100644 index 0000000..46d4122 --- /dev/null +++ b/blocks/title/title.js @@ -0,0 +1,31 @@ +import { unwrapDivs, adjustPretitle } from '../../scripts/helpers.js'; + +export default async function decorate(block) { + unwrapDivs(block); + adjustPretitle(block); + + const headings = block.querySelectorAll('h1, h2, h3, h4, h5, h6'); + [...headings].forEach((heading) => heading.classList.add('heading')); + + const isLineVariant = block.classList.contains('line'); + + if (isLineVariant) { + const lineEle = document.createElement('div'); + lineEle.classList.add('vertical-line-wrapper'); + const innerEle = document.createElement('div'); + innerEle.classList.add('vertical-line'); + lineEle.appendChild(innerEle); + block.prepend(lineEle); + + const observer = new IntersectionObserver((entries) => { + entries.forEach((entry) => { + if (entry.isIntersecting) { + innerEle.classList.add('animate'); + } else { + innerEle.classList.remove('animate'); + } + }); + }); + observer.observe(block); + } +} diff --git a/scripts/helpers.js b/scripts/helpers.js index 999bb65..99494cb 100644 --- a/scripts/helpers.js +++ b/scripts/helpers.js @@ -69,3 +69,57 @@ export function addTitleAttributeToIconLink(element) { element.setAttribute('title', iconElement.getAttribute('data-icon-name')); } } + +export const adjustPretitle = (element) => { + const headingSelector = 'h1, h2, h3, h4, h5, h6'; + + [...element.querySelectorAll(headingSelector)].forEach((heading) => { + const isNextElHeading = heading.nextElementSibling?.matches(headingSelector); + + if (!isNextElHeading) { + return; + } + + const currentLevel = Number(heading.tagName[1]); + const nextElLevel = Number(heading.nextElementSibling.tagName[1]); + + if (currentLevel > nextElLevel) { + const pretitle = document.createElement('span'); + pretitle.classList.add('pretitle'); + pretitle.append(...heading.childNodes); + + heading.replaceWith(pretitle); + } + }); +}; + +export const unwrapDivs = (element, options = {}) => { + const stack = [element]; + const { ignoreDataAlign = false } = options; + + while (stack.length > 0) { + const currentElement = stack.pop(); + + let i = 0; + while (i < currentElement.children.length) { + const node = currentElement.children[i]; + const attributesLength = [...node.attributes].filter((el) => { + if (ignoreDataAlign) { + return !(el.name.startsWith('data-align') || el.name.startsWith('data-valign')); + } + + return el; + }).length; + + if (node.tagName === 'DIV' && attributesLength === 0) { + while (node.firstChild) { + currentElement.insertBefore(node.firstChild, node); + } + node.remove(); + } else { + stack.push(node); + i += 1; + } + } + } +}; diff --git a/styles/styles.css b/styles/styles.css index 2620f91..2ea9594 100644 --- a/styles/styles.css +++ b/styles/styles.css @@ -45,6 +45,7 @@ --error: #b81f2d; /* old variables */ + --text-red: var(--action-default); --link-color: var(--action-default); --link-hover-color: var(--action-hover); --c-primary-white: var(--white); @@ -108,7 +109,7 @@ h6, h1, .h1 { - font-size: 2.25rem; + font-size: 2.875rem; font-style: normal; font-weight: 500; line-height: 140%; @@ -160,15 +161,15 @@ h6, letter-spacing: 0.15px; } -@media (width >= 768px) { +@media (width >= 1025px) { h1, .h1 { - font-size: 2.5rem; + font-size: 3.75rem; } h2, .h2 { - font-size: 2.25rem; + font-size: 2.5rem; } h3, @@ -192,7 +193,7 @@ h6, } } -@media (width >= 1024px) { +@media (width >= 1440px) { h1, .h1 { font-size: 4.375rem; From 697ba8c26031cff24a2334abe63e8e1969253102 Mon Sep 17 00:00:00 2001 From: Tomasz Dziezyk Date: Wed, 11 Sep 2024 15:15:27 +0200 Subject: [PATCH 018/159] KAW-7904 Implement header --- blocks/header/header.css | 511 +++++++++++++++++---------------------- blocks/header/header.js | 100 ++++++-- styles/styles.css | 5 +- 3 files changed, 307 insertions(+), 309 deletions(-) diff --git a/blocks/header/header.css b/blocks/header/header.css index 98ba3ef..362725d 100644 --- a/blocks/header/header.css +++ b/blocks/header/header.css @@ -1,433 +1,366 @@ /* header and nav layout */ header .nav-wrapper { - --color-gray: #999; - width: 100%; - z-index: 2; - position: relative; + z-index: var(--z-index-header); + position: fixed; } header nav { - box-sizing: border-box; display: flex; - flex-flow: column; + flex-flow: row; height: var(--nav-height); - padding: 15px 30px; + padding: 20px; + max-width: 1240px; + margin: auto; } -header nav[aria-expanded='true'] { - overflow-y: auto; - min-height: 100vh; - background-color: #222; - color: var(--color-gray); - max-width: 350px; - width: 50%; - position: relative; - min-width: 270px +header nav p { + margin: 0; + line-height: 1; } -header .nav-brand, -.nav-link-section .icon-logo-bimota-h { - display: none; +header a:any-link { + font-size: 1.25rem; + font-style: normal; + font-weight: 500; + line-height: 130%; + color: var(--grey-90); } -header .nav-wrapper.hide .nav-brand { - display: none; +header a:active, +header a:focus, +header a:hover { + color: var(--action-default); } -header .nav-wrapper.hide nav { - height: 100px; +/* brand */ +header .nav-brand { + flex-grow: 1; } -header nav p { - margin: 0; - line-height: 1; +header .nav-brand span.icon { + display: flex; + height: auto; + width: auto; } -.nav-logo-mobile { - position: absolute; - top: 10px; - left: 0; - transform: translateX(40vw); +header .nav-brand img { + width: 111px; + height: 31px; } -.nav-logo-mobile .icon-logo-bimota-h { - width: 100%; - height: 100%; - max-width: 170px; - max-height: 47px; +header .nav-dealer-locator { + margin-right: 20px; } -header a:any-link, -.nav-drop-text { - color: currentcolor; - padding: 5px 0; - display: flex; +header .nav-dealer-locator a.button { + display: inline-flex; + height: 30px; + padding: 6px 12px; + justify-content: center; align-items: center; - column-gap: .25em; - text-decoration: none; -} - -.nav-sections a.active, -.nav-drop.active .nav-drop-text { - color: var(--c-primary-white); + gap: 8px; + border-radius: 26px; + background: var(--white); + color: var(--black); + text-align: center; + font-size: 0.75rem; + font-style: normal; + font-weight: 600; + line-height: 150%; + letter-spacing: 0.44px; } -/* brand */ -header .nav-brand img { - max-width: 100%; - height: auto; +header .nav-drop picture { + display: none; } header .nav-link-section { - display: flex; + position: fixed; + top: 0; + right: 0; + height: 100vh; + width: 320px; + padding: 25px 20px 0; + display: none; flex-flow: column; - gap: 30px; + gap: 20px; + background-color: var(--white); + z-index: 2; } -/* sections */ -header .nav-sections { - flex: 1; - display: none; - visibility: hidden; +header .nav-close-button { + align-self: flex-end; + width: 20px; + margin-bottom: 20px; } -header nav[aria-expanded='true'] .nav-sections { +header .nav-flag { + position: fixed; + bottom: 0; + right: 20px; display: flex; - visibility: visible; } -.nav-tools .default-content-wrapper { +header nav[aria-expanded="true"] .nav-link-section { display: flex; - padding: 7px; - list-style: none; - margin-bottom: 0; - align-items: center; -} - -header .nav-sections .default-content-wrapper { - flex: 1; -} - -.nav-sections .default-content-wrapper .nav-logo { - align-self: flex-start; } header .nav-sections ul { list-style: none; - padding-left: 0; - font-size: 14px; - font-weight: 600; + padding: 0; + font-size: 1.25rem; + font-style: normal; + font-weight: 500; + line-height: 130%; display: flex; - align-items: flex-start; - column-gap: .25em; flex-flow: column; + gap: 24px; + margin: 0; } header .nav-sections ul li { width: 100%; } -.nav-sections ul > li > ul { - margin-top: 0; +header .nav-drop ul { + cursor: auto; } -/* tools */ -header .nav-tools { - display: none; - visibility: hidden; +header .nav-sections ul > li > ul { + margin: 0; + gap: 16px; + padding: 10px 0 0; } -header nav[aria-expanded='true'] .nav-tools { +header .nav-sections ul > li > ul a:any-link { + font-size: 0.875rem; + font-style: normal; + font-weight: 500; + line-height: 150%; + letter-spacing: 0.44px; +} + +/* tools */ +header .nav-tools .default-content-wrapper { + list-style: none; + padding: 0; + gap: 16px; display: flex; - visibility: visible; - padding-left: 30px; - align-items: center; + margin: 27px 0 0; } -.nav-tools .default-content-wrapper li { - padding: 5px 10px 6px; - line-height: 1; - color: var(--c-primary-white); +header .nav-tools .default-content-wrapper li { + margin: 0; +} + +header .nav-tools .default-content-wrapper li a:any-link { + font-size: 0.875rem; + font-style: normal; + font-weight: 600; + line-height: 130%; + letter-spacing: 0.44px; } /* hamburger */ header .nav-hamburger { - height: 22px; display: flex; - align-self: start; - justify-content: flex-end; - flex: 1; + align-items: center; } header .nav-hamburger button { - height: 22px; - margin: auto; + height: 24px; border: 0; border-radius: 0; padding: 0; background-color: transparent; - color: inherit; - overflow: initial; - text-overflow: initial; - white-space: initial; cursor: pointer; } -header .nav-hamburger-icon, -header .nav-hamburger-icon::before, -header .nav-hamburger-icon::after { - box-sizing: border-box; - display: block; - position: relative; - width: 20px; -} - -header .nav-hamburger-icon::before, -header .nav-hamburger-icon::after { - content: ''; - position: absolute; - background: currentcolor; -} - -header nav[aria-expanded='true'] .nav-hamburger { - flex: initial; - align-self: flex-end; -} - -header nav[aria-expanded='false'] .nav-hamburger-icon, -header nav[aria-expanded='false'] .nav-hamburger-icon::before, -header nav[aria-expanded='false'] .nav-hamburger-icon::after { - height: 2px; - border-radius: 2px; - background: var(--color-gray); -} - -header nav[aria-expanded='false'] .nav-hamburger-icon::before { - top: -6px; -} - -header nav[aria-expanded='false'] .nav-hamburger-icon::after { - top: 6px; -} - -header nav[aria-expanded='true'] .nav-hamburger-icon { - height: 22px; -} - -header nav[aria-expanded='true'] .nav-hamburger-icon::before, -header nav[aria-expanded='true'] .nav-hamburger-icon::after { - top: 3px; - left: 1px; - transform: rotate(45deg); - transform-origin: 2px 1px; - width: 24px; - height: 2px; - border-radius: 2px; -} - -header nav[aria-expanded='true'] .nav-hamburger-icon::after { - top: unset; - bottom: 3px; - transform: rotate(-45deg); -} - /* nav-drop */ header .nav-drop { position: relative; cursor: pointer; } -header .nav-drop::after { - content: ''; - display: inline-block; - position: absolute; - top: 10px; - right: 5px; - transform: rotate(135deg); - width: 6px; - height: 6px; - border: 2px solid currentcolor; - border-radius: 0 1px 0 0; - border-width: 2px 2px 0 0; -} - -header .nav-drop[aria-expanded='false'] ul { +header .nav-drop[aria-expanded="false"] ul { display: none; } -header .nav-drop[aria-expanded='true'] ul { +.nav-sections .nav-drop-text { display: flex; - flex-flow: column; - padding: 5px 0 5px 15px; -} - -header .nav-drop[aria-expanded='true']::after { - bottom: 0.5em; - transform: rotate(315deg); + justify-content: space-between; } .nav-sections .nav-drop-text:hover { text-decoration: none; } -.nav-sections a:hover, -header nav[aria-expanded='true'] button:hover .nav-hamburger-icon::after, -header nav[aria-expanded='true'] button:hover .nav-hamburger-icon::before, -header .nav-drop[aria-expanded='true']:hover::after { - color: #ffffffb2; +header .nav-backdrop { + position: fixed; + top: 0; + left: 0; + width: 100vw; + height: 100vh; + background: rgb(0 0 0 / 40%); + z-index: 1; } -@media (width >= 640px) { - header .nav-drop::after { - top: 8px; - } +header .nav-backdrop.hide { + display: none; } -@media (width >= 992px) { - header { - --nav-height: 130px; - } - +@media (width >= 768px) { header nav { - display: flex; - justify-content: space-between; + padding: 20px 30px 16px 24px; } - header a:any-link, - .nav-link-section .a, - .nav-tools .default-content-wrapper li { - color: var(--text-color); - letter-spacing: 1px; - font-weight: 400; + header .nav-brand img { + height: 34px; + width: auto; } - header .nav-wrapper { - max-width: 100%; - background-color: var(--c-primary-white); - position: fixed; + header .nav-link-section { + padding: 24px 30px 0; } - header nav[aria-expanded='true'] { - min-height: auto; - overflow: visible; - margin: auto; - background-color: var(--c-primary-white); - padding-top: 0; - max-width: 1280px; - width: 100%; + header .nav-dealer-locator { + margin-right: 32px; } - header nav .nav-hamburger { - display: none; - visibility: hidden; + header .nav-flag { + right: 30px; } +} +@media (width >= 1024px) { header .nav-brand { - display: block; - align-self: flex-end; + flex-grow: unset; } header .nav-link-section { - flex-flow: row; - } - - header .nav-sections { - display: flex; - visibility: visible; - white-space: nowrap; + position: static; + width: auto; + padding: 0; + flex-direction: row; + background-color: transparent; + height: auto; + flex-grow: 1; align-items: center; } - header .nav-sections .default-content-wrapper { - display: flex; - flex-flow: row; - justify-content: space-between; - flex: 1; - align-items: center; + header .nav-backdrop { + display: none; } - .nav-logo-mobile .icon-logo-bimota-h { + header .nav-hamburger, + header .nav-close-button, + header .nav-flag, + header .nav-drop-text .chevron-icon { display: none; } - header .nav-sections .icon-logo-bimota-h { - display: block; - height: 100%; - width: 100%; - max-width: 250px; - max-height: 70px; + header .nav-dealer-locator { + margin: 0; + display: flex; + align-items: center; } - .nav-sections a:hover, - .nav-sections a.active, - .nav-drop.active .nav-drop-text { - color: var(--link-color); + header .nav-sections { + flex-grow: 1; + justify-content: center; + display: flex; } header .nav-sections ul { - display: flex; - gap: 30px; - margin: 0; - flex-flow: row; - align-items: center; - justify-content: center; + flex-direction: row; + gap: 28px; } - .nav-tools .default-content-wrapper li { - cursor: pointer; + header .nav-tools { + margin-right: 24px; } - header .nav-sections .default-content-wrapper > ul > li { - flex: 0 1 auto; - position: relative; - font-weight: 500; - min-height: 80px; - display: flex; + header .nav-tools ul { + flex-direction: row; + gap: 12px; } - header .nav-sections .default-content-wrapper > ul > li > ul { - display: none; - position: relative; + header .nav-tools .default-content-wrapper { + margin: 0; } - header .nav-sections .default-content-wrapper > ul > li[aria-expanded='true'] > ul { - display: block; - position: absolute; - width: 250px; - top: 80px; - padding: 25px; - background-color: var(--c-primary-white); - white-space: initial; - box-shadow: 0 5px 12px rgba(0 0 0 / 15%); + header .nav-sections ul, + header .nav-link-section a:any-link, + header .nav-tools .default-content-wrapper li a:any-link { + font-size: 0.875rem; + font-style: normal; + font-weight: 600; + line-height: 130%; + letter-spacing: 0.44px; } - .nav-tools .default-content-wrapper a, - .nav-drop-text { - color: var(--text-color); + header .nav-sections ul li { + width: auto; } - .nav-tools a:any-link:hover { - color: var(--text-color); + /* expanded menu item content */ + header .nav-sections .nav-drop ul { + position: fixed; + top: var(--nav-height); + padding: 40px; + width: 100vw; + left: 0; + height: auto; + background: var(--white); + gap: unset; + justify-content: space-between; + flex-wrap: wrap; + row-gap: 40px; } - - .nav-sections .nav-drop ul a:any-link { - color: var(--color-gray); + + header .nav-sections .nav-drop ul li a:any-link { + padding: 0 16px; + display: flex; + flex-direction: column; + gap: 16px; + font-size: 1.25rem; + font-style: normal; + font-weight: 500; + line-height: 140%; } - - .nav-sections .nav-drop ul a:hover { - color: var(--link-hover-color); + + header .nav-sections .nav-drop ul picture { + display: flex; } - header .nav-sections .default-content-wrapper > ul > li > ul > li { - padding: 8px 0; + header .nav-sections .nav-drop ul img { + width: 187px; + height: auto; } - header .nav-drop::after { - display: none; + header .nav-drop[aria-expanded="true"]::after { + content: ''; + display: block; + width: 100vw; + height: calc(100vh - var(--nav-height)); + position: fixed; + top: var(--nav-height); + left: 0; + background: rgb(0 0 0 / 40%); + z-index: -1; + cursor: auto; } +} - header nav[aria-expanded='true'] .nav-tools { +@media (width >= 1024px) { + header nav { padding-left: 0; + padding-right: 0; + } + + header .nav-sections .nav-drop ul { + padding-left: calc((100vw - 1240px) / 2); + padding-right: calc((100vw - 1240px) / 2); } } \ No newline at end of file diff --git a/blocks/header/header.js b/blocks/header/header.js index 4ebced2..7160a0e 100644 --- a/blocks/header/header.js +++ b/blocks/header/header.js @@ -2,7 +2,41 @@ import { getMetadata } from '../../scripts/aem.js'; import { loadFragment } from '../fragment/fragment.js'; // media query match that indicates mobile/tablet width -const isDesktop = window.matchMedia('(min-width: 992px)'); +const isDesktop = window.matchMedia('(min-width: 1024px)'); + +const hamburgerIcon = ` + + + + + + + + + + +`; + +const chevronIcon = ` + + + +`; + +const flag = ` + + + + + + +`; + +const closeIcon = ` + + + +`; function closeOnEscape(e) { if (e.code === 'Escape') { @@ -70,6 +104,13 @@ function toggleMenu(nav, navSections, forceExpanded = null) { } }); + const backdropEl = nav.querySelector('.nav-backdrop'); + if (!expanded) { + backdropEl.classList.remove('hide'); + } else { + backdropEl.classList.add('hide'); + } + // enable menu collapse on escape keypress if (!expanded || isDesktop.matches) { // collapse menu on escape press @@ -117,7 +158,8 @@ function redirectPage(event) { export default async function decorate(block) { // load nav as fragment const navMeta = getMetadata('nav'); - const navPath = navMeta ? new URL(navMeta, window.location).pathname : '/nav'; + // const navPath = navMeta ? new URL(navMeta, window.location).pathname : '/nav'; + const navPath = '/drafts/tdziezyk/v3-nav'; const fragment = await loadFragment(navPath); // decorate nav DOM @@ -126,7 +168,7 @@ export default async function decorate(block) { nav.id = 'nav'; while (fragment.firstElementChild) nav.append(fragment.firstElementChild); - const classes = ['brand', 'sections', 'tools']; + const classes = ['brand', 'sections', 'tools', 'dealer-locator']; classes.forEach((c, i) => { const section = nav.children[i]; if (section) section.classList.add(`nav-${c}`); @@ -140,29 +182,31 @@ export default async function decorate(block) { } const navSections = nav.querySelector('.nav-sections'); - const mobileLogoWrapper = document.createElement('div'); - mobileLogoWrapper.classList.add('nav-logo-mobile'); + if (navSections) { navSections.querySelectorAll(':scope .default-content-wrapper > ul > li').forEach((navSection) => { if (navSection.querySelector('ul')) { const textWrapper = document.createElement('a'); textWrapper.classList.add('nav-drop-text'); textWrapper.append(navSection.firstChild); + textWrapper.innerHTML += `${chevronIcon}`; navSection.prepend(textWrapper); navSection.classList.add('nav-drop'); + + // wrapping pictures with links if the link follows immediately after the picture + navSection.querySelectorAll('ul picture + a').forEach((link) => { + const picture = link.previousElementSibling; + + link.prepend(picture); + }); } - navSection.addEventListener('click', () => toggleSubNav(navSection, navSections)); + navSection.addEventListener('click', (event) => { + if (event.target.classList.contains('nav-drop-text')) { + toggleSubNav(navSection, navSections); + } + }); }); - const defaultContentWrapper = navSections.querySelector('.default-content-wrapper'); - const logoButton = defaultContentWrapper.querySelector('.default-content-wrapper .button'); - if (logoButton) { - logoButton.className = 'nav-logo'; - defaultContentWrapper.prepend(logoButton); - const buttonContainer = defaultContentWrapper.querySelector('.button-container'); - mobileLogoWrapper.appendChild(logoButton.cloneNode(true)); - buttonContainer.remove(); - } } const navTools = nav.querySelector('.nav-tools'); @@ -176,21 +220,39 @@ export default async function decorate(block) { }); } + const navDealerLocator = nav.querySelector('.nav-dealer-locator'); + const dealerLocatorButton = navDealerLocator.querySelector('a'); + navDealerLocator.innerHTML = ''; + navDealerLocator.append(dealerLocatorButton); + if (navSections && navTools) { const navLinksWrapper = document.createElement('div'); navLinksWrapper.classList.add('nav-link-section'); - navLinksWrapper.append(navSections, navTools); + const flagEl = document.createElement('span'); + flagEl.classList.add('nav-flag'); + flagEl.innerHTML = flag; + const closeEl = document.createElement('button'); + closeEl.classList.add('nav-close-button'); + closeEl.innerHTML = closeIcon; + closeEl.addEventListener('click', () => toggleMenu(nav, navSections)); + navLinksWrapper.append(closeEl, navSections, navTools, flagEl); nav.append(navLinksWrapper); + + const backdrop = document.createElement('div'); + backdrop.classList.add('nav-backdrop'); + nav.append(backdrop); } + nav.append(navDealerLocator); + // hamburger for mobile const hamburger = document.createElement('div'); hamburger.classList.add('nav-hamburger'); hamburger.innerHTML = ``; hamburger.addEventListener('click', () => toggleMenu(nav, navSections)); - nav.prepend(hamburger); + nav.append(hamburger); nav.setAttribute('aria-expanded', 'false'); // prevent mobile nav behavior on window resize toggleMenu(nav, navSections, isDesktop.matches); @@ -200,7 +262,7 @@ export default async function decorate(block) { const navWrapper = document.createElement('div'); navWrapper.className = 'nav-wrapper'; - navWrapper.append(mobileLogoWrapper, nav); + navWrapper.append(nav); block.append(navWrapper); checkForActiveLink(navSections); diff --git a/styles/styles.css b/styles/styles.css index 7d4b85c..3b7d291 100644 --- a/styles/styles.css +++ b/styles/styles.css @@ -17,7 +17,7 @@ --body-font-size: 16px; /* nav height */ - --nav-height: 80px; + --nav-height: 70px; /* section paddings */ --section-y-padding: 40px; @@ -44,6 +44,9 @@ --warning: #e68619; --error: #b81f2d; + /* z indexes */ + --z-index-header: 2; + /* old variables */ --link-color: var(--action-default); --link-hover-color: var(--action-hover); From 51af69cf5b6af2e021bec960d80196ffae19ded7 Mon Sep 17 00:00:00 2001 From: Tomasz Dziezyk Date: Thu, 12 Sep 2024 09:07:22 +0200 Subject: [PATCH 019/159] KAW-7904 Improve header css'es --- blocks/header/header.css | 75 +++++++++++++++++++++++++++++++++++++--- blocks/header/header.js | 6 ++-- 2 files changed, 74 insertions(+), 7 deletions(-) diff --git a/blocks/header/header.css b/blocks/header/header.css index 362725d..3693fa7 100644 --- a/blocks/header/header.css +++ b/blocks/header/header.css @@ -3,6 +3,7 @@ header .nav-wrapper { width: 100%; z-index: var(--z-index-header); position: fixed; + color: var(--grey-90); } header nav { @@ -12,6 +13,7 @@ header nav { padding: 20px; max-width: 1240px; margin: auto; + background-color: var(--white); } header nav p { @@ -62,13 +64,23 @@ header .nav-dealer-locator a.button { gap: 8px; border-radius: 26px; background: var(--white); - color: var(--black); text-align: center; font-size: 0.75rem; font-style: normal; font-weight: 600; line-height: 150%; letter-spacing: 0.44px; + border: solid 1px var(--action-default); +} + +header .nav-dealer-locator a.button:hover { + border-color: var(--action-hover); + color: var(--action-hover); +} + +header .nav-dealer-locator a.button:focus { + border-color: var(--action-focus); + color: var(--action-focus); } header .nav-drop picture { @@ -177,6 +189,10 @@ header .nav-hamburger button { cursor: pointer; } +header .nav-hamburger button svg { + color: var(--grey-90); +} + /* nav-drop */ header .nav-drop { position: relative; @@ -210,6 +226,40 @@ header .nav-backdrop.hide { display: none; } +header.transparent nav { + background-color: transparent; + color: var(--white); +} + +header.transparent a:any-link { + color: var(--white); +} + +header.transparent .nav-hamburger svg { + color: var(--white); +} + +header.transparent .nav-dealer-locator a.button { + background-color: var(--white); + border-color: transparent; + color: var(--black); +} + +header.transparent .nav-dealer-locator a.button:hover { + border-color: var(--action-hover); + color: var(--action-hover); +} + +header.transparent .nav-dealer-locator a.button:focus { + border-color: var(--action-focus); + color: var(--action-focus); +} + +header.transparent nav[aria-expanded="true"] .nav-link-section a:any-link, +header.transparent nav[aria-expanded="true"] .nav-link-section a.nav-drop-text { + color: var(--grey-90); +} + @media (width >= 768px) { header nav { padding: 20px 30px 16px 24px; @@ -340,7 +390,7 @@ header .nav-backdrop.hide { } header .nav-drop[aria-expanded="true"]::after { - content: ''; + content: ""; display: block; width: 100vw; height: calc(100vh - var(--nav-height)); @@ -351,9 +401,26 @@ header .nav-backdrop.hide { z-index: -1; cursor: auto; } + + header.transparent nav[aria-expanded="true"] .nav-link-section a:any-link, + header.transparent nav[aria-expanded="true"] .nav-link-section a.nav-drop-text { + color: var(--white); + } + + header.transparent nav[aria-expanded="true"] .nav-link-section .nav-drop a:any-link { + color: var(--grey-90); + } + + header.transparent nav[aria-expanded="true"] .nav-link-section .nav-drop a:focus { + color: var(--action-focus); + } + + header.transparent nav[aria-expanded="true"] .nav-link-section .nav-drop a:hover { + color: var(--action-hover); + } } -@media (width >= 1024px) { +@media (width >= 1440px) { header nav { padding-left: 0; padding-right: 0; @@ -363,4 +430,4 @@ header .nav-backdrop.hide { padding-left: calc((100vw - 1240px) / 2); padding-right: calc((100vw - 1240px) / 2); } -} \ No newline at end of file +} diff --git a/blocks/header/header.js b/blocks/header/header.js index 7160a0e..d1ea75d 100644 --- a/blocks/header/header.js +++ b/blocks/header/header.js @@ -5,9 +5,9 @@ import { loadFragment } from '../fragment/fragment.js'; const isDesktop = window.matchMedia('(min-width: 1024px)'); const hamburgerIcon = ` - + - + @@ -202,7 +202,7 @@ export default async function decorate(block) { } navSection.addEventListener('click', (event) => { - if (event.target.classList.contains('nav-drop-text')) { + if (event.target.classList.contains('nav-drop-text') || event.target.closest('.nav-drop-text')) { toggleSubNav(navSection, navSections); } }); From cc6676475b1bfe7e5446b01dbc11adb6385b3806 Mon Sep 17 00:00:00 2001 From: Tomasz Dziezyk Date: Thu, 12 Sep 2024 10:43:04 +0200 Subject: [PATCH 020/159] KAW-7904 Add scrolling logic for header --- blocks/header/header.css | 16 ++++++++++++++-- blocks/header/header.js | 31 +++++++++++++++++++++++++++++++ styles/styles.css | 4 ++++ 3 files changed, 49 insertions(+), 2 deletions(-) diff --git a/blocks/header/header.css b/blocks/header/header.css index 3693fa7..7cc213e 100644 --- a/blocks/header/header.css +++ b/blocks/header/header.css @@ -1,8 +1,19 @@ /* header and nav layout */ + +header { + position: fixed; + top: 0; + transition: 500ms all; + width: 100vw; + z-index: var(--z-index-header); +} + +header.fade-out { + top: calc(-1 * var(--nav-height)); +} + header .nav-wrapper { width: 100%; - z-index: var(--z-index-header); - position: fixed; color: var(--grey-90); } @@ -231,6 +242,7 @@ header.transparent nav { color: var(--white); } +/* stylelint-disable-next-line no-descending-specificity */ header.transparent a:any-link { color: var(--white); } diff --git a/blocks/header/header.js b/blocks/header/header.js index d1ea75d..b0acf34 100644 --- a/blocks/header/header.js +++ b/blocks/header/header.js @@ -151,6 +151,35 @@ function redirectPage(event) { } window.location.replace(redirectUrl); } + +function handleTransparentAndScrolling(nav) { + const useTransparentVariant = !!document.querySelector('main > .section > .hero-wrapper'); + const header = nav.closest('header'); + let prevScrollingPosition = 0; + + document.addEventListener('scroll', () => { + const { scrollY } = window; + + if (useTransparentVariant) { + header.classList.add('transparent', 'can-be-transparent'); + + if (scrollY > 100) { + header.classList.remove('transparent'); + } else { + header.classList.add('transparent'); + } + } + + if (scrollY - prevScrollingPosition > 0 && scrollY > 200) { + header.classList.add('fade-out'); + } else if (prevScrollingPosition - scrollY > 0) { + header.classList.remove('fade-out'); + } + + prevScrollingPosition = scrollY; + }); +} + /** * loads and decorates the header, mainly the nav * @param {Element} block The header block element @@ -277,4 +306,6 @@ export default async function decorate(block) { }); }, { rootMargin: '0px 0px -1000px 0px' }); observer.observe(document.querySelector('main')); + + handleTransparentAndScrolling(nav); } diff --git a/styles/styles.css b/styles/styles.css index 3b7d291..96b3268 100644 --- a/styles/styles.css +++ b/styles/styles.css @@ -496,6 +496,10 @@ div[class$="-wrapper"]:not(:first-child) { } } +header:not(.can-be-transparent) + main { + margin-top: var(--nav-height); +} + /* sections */ main .section { padding: var(--section-y-padding) var(--section-x-padding); From ff06afa3bb8157a842eb85cbd14fe6987a7f834e Mon Sep 17 00:00:00 2001 From: Tomasz Dziezyk Date: Thu, 12 Sep 2024 10:49:01 +0200 Subject: [PATCH 021/159] KAW-7904 Fix chevron animation --- blocks/header/header.css | 10 ++++++++++ blocks/header/header.js | 4 ++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/blocks/header/header.css b/blocks/header/header.css index 7cc213e..2ea963b 100644 --- a/blocks/header/header.css +++ b/blocks/header/header.css @@ -214,6 +214,16 @@ header .nav-drop[aria-expanded="false"] ul { display: none; } +header .nav-drop .chevron-icon { + transition: transform 200ms ease-in-out; + transform-origin: center center; + display: flex; +} + +header .nav-drop[aria-expanded="true"] .chevron-icon { + transform: rotate(180deg); +} + .nav-sections .nav-drop-text { display: flex; justify-content: space-between; diff --git a/blocks/header/header.js b/blocks/header/header.js index b0acf34..e677cfd 100644 --- a/blocks/header/header.js +++ b/blocks/header/header.js @@ -18,8 +18,8 @@ const hamburgerIcon = ` `; const chevronIcon = ` - - + + `; From 69c0329547b22cdd5d8de26d9ed4834fe4852e1e Mon Sep 17 00:00:00 2001 From: Tomasz Dziezyk Date: Thu, 12 Sep 2024 10:57:41 +0200 Subject: [PATCH 022/159] KAW-7904 Refactor --- blocks/header/header.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/blocks/header/header.css b/blocks/header/header.css index 2ea963b..e8e3b41 100644 --- a/blocks/header/header.css +++ b/blocks/header/header.css @@ -119,7 +119,7 @@ header .nav-close-button { } header .nav-flag { - position: fixed; + position: absolute; bottom: 0; right: 20px; display: flex; From bc596fb9ba17e92686b48f8c59b8d4bdf8cc4e3b Mon Sep 17 00:00:00 2001 From: Tomasz Dziezyk Date: Thu, 12 Sep 2024 11:25:03 +0200 Subject: [PATCH 023/159] KAW-7904 Update icons --- blocks/header/header.css | 15 ++++++++++--- blocks/header/header.js | 45 ++++++--------------------------------- icons/chevron.svg | 3 +++ icons/close.svg | 4 ++-- icons/hamburger.svg | 10 +++++++++ icons/logo-flag-black.svg | 6 ++++++ icons/logo.svg | 11 ++++++++++ scripts/scripts.js | 32 +++++++++++++++++++++++++++- 8 files changed, 82 insertions(+), 44 deletions(-) create mode 100644 icons/chevron.svg create mode 100644 icons/hamburger.svg create mode 100644 icons/logo-flag-black.svg create mode 100644 icons/logo.svg diff --git a/blocks/header/header.css b/blocks/header/header.css index e8e3b41..e30aac1 100644 --- a/blocks/header/header.css +++ b/blocks/header/header.css @@ -118,6 +118,11 @@ header .nav-close-button { margin-bottom: 20px; } +header .icon-close { + display: flex; + color: var(--grey-90); +} + header .nav-flag { position: absolute; bottom: 0; @@ -125,6 +130,10 @@ header .nav-flag { display: flex; } +header .nav-flag .icon { + display: flex; +} + header nav[aria-expanded="true"] .nav-link-section { display: flex; } @@ -214,13 +223,13 @@ header .nav-drop[aria-expanded="false"] ul { display: none; } -header .nav-drop .chevron-icon { +header .nav-drop .icon-chevron { transition: transform 200ms ease-in-out; transform-origin: center center; display: flex; } -header .nav-drop[aria-expanded="true"] .chevron-icon { +header .nav-drop[aria-expanded="true"] .icon-chevron { transform: rotate(180deg); } @@ -328,7 +337,7 @@ header.transparent nav[aria-expanded="true"] .nav-link-section a.nav-drop-text { header .nav-hamburger, header .nav-close-button, header .nav-flag, - header .nav-drop-text .chevron-icon { + header .nav-drop-text .icon-chevron { display: none; } diff --git a/blocks/header/header.js b/blocks/header/header.js index e677cfd..1222ef2 100644 --- a/blocks/header/header.js +++ b/blocks/header/header.js @@ -1,43 +1,10 @@ import { getMetadata } from '../../scripts/aem.js'; +import { customDecoreateIcons } from '../../scripts/scripts.js'; import { loadFragment } from '../fragment/fragment.js'; // media query match that indicates mobile/tablet width const isDesktop = window.matchMedia('(min-width: 1024px)'); -const hamburgerIcon = ` - - - - - - - - - - -`; - -const chevronIcon = ` - - - -`; - -const flag = ` - - - - - - -`; - -const closeIcon = ` - - - -`; - function closeOnEscape(e) { if (e.code === 'Escape') { const nav = document.getElementById('nav'); @@ -218,7 +185,7 @@ export default async function decorate(block) { const textWrapper = document.createElement('a'); textWrapper.classList.add('nav-drop-text'); textWrapper.append(navSection.firstChild); - textWrapper.innerHTML += `${chevronIcon}`; + textWrapper.innerHTML += ''; navSection.prepend(textWrapper); navSection.classList.add('nav-drop'); @@ -259,10 +226,10 @@ export default async function decorate(block) { navLinksWrapper.classList.add('nav-link-section'); const flagEl = document.createElement('span'); flagEl.classList.add('nav-flag'); - flagEl.innerHTML = flag; + flagEl.innerHTML = ''; const closeEl = document.createElement('button'); closeEl.classList.add('nav-close-button'); - closeEl.innerHTML = closeIcon; + closeEl.innerHTML = ''; closeEl.addEventListener('click', () => toggleMenu(nav, navSections)); navLinksWrapper.append(closeEl, navSections, navTools, flagEl); nav.append(navLinksWrapper); @@ -278,7 +245,7 @@ export default async function decorate(block) { const hamburger = document.createElement('div'); hamburger.classList.add('nav-hamburger'); hamburger.innerHTML = ``; hamburger.addEventListener('click', () => toggleMenu(nav, navSections)); nav.append(hamburger); @@ -308,4 +275,6 @@ export default async function decorate(block) { observer.observe(document.querySelector('main')); handleTransparentAndScrolling(nav); + + customDecoreateIcons(nav); } diff --git a/icons/chevron.svg b/icons/chevron.svg new file mode 100644 index 0000000..4952f2a --- /dev/null +++ b/icons/chevron.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/icons/close.svg b/icons/close.svg index e7b4747..103f557 100644 --- a/icons/close.svg +++ b/icons/close.svg @@ -1,4 +1,4 @@ - - + + \ No newline at end of file diff --git a/icons/hamburger.svg b/icons/hamburger.svg new file mode 100644 index 0000000..3ab87cb --- /dev/null +++ b/icons/hamburger.svg @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/icons/logo-flag-black.svg b/icons/logo-flag-black.svg new file mode 100644 index 0000000..c199615 --- /dev/null +++ b/icons/logo-flag-black.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/icons/logo.svg b/icons/logo.svg new file mode 100644 index 0000000..142e87d --- /dev/null +++ b/icons/logo.svg @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/scripts/scripts.js b/scripts/scripts.js index d56037b..146584f 100644 --- a/scripts/scripts.js +++ b/scripts/scripts.js @@ -94,6 +94,36 @@ function swappingPlacesBlock(main) { }); } +export function customDecoreateIcons(main) { + // inline icons give the possibility to change its colors using the css variables + const decorateInlineIcons = (rootElement) => { + const inlineIcons = ['icon-logo', 'icon-hamburger', 'icon-chevron', 'icon-close']; + const isInlineIcon = (el) => { + const isInline = (className) => inlineIcons.includes(className); + return [...el.classList].some(isInline); + }; + const inlineIconsList = [...rootElement.querySelectorAll('span.icon')].filter(isInlineIcon); + + inlineIconsList.forEach((async (inlineIcon) => { + const iconName = [...inlineIcon.classList].find((c) => c.startsWith('icon-')).substring(5); + inlineIcon.classList.remove('icon'); // removing the 'icon' class, so the icon won't be used by decorateIcon + const icon = await fetch(`${window.hlx.codeBasePath}/icons/${iconName}.svg`); + + try { + const svgIcon = await icon.text(); + const svgEl = document.createRange().createContextualFragment(svgIcon).children[0]; + inlineIcon.innerHTML = svgEl.outerHTML; + } catch (error) { + // eslint-disable-next-line no-console + console.error(error); + } + })); + }; + + decorateInlineIcons(main); + decorateIcons(main); +} + /** * Decorates the main element. * @param {Element} main The main element @@ -102,7 +132,7 @@ function swappingPlacesBlock(main) { export function decorateMain(main) { // hopefully forward compatible button decoration decorateButtons(main); - decorateIcons(main); + customDecoreateIcons(main); buildAutoBlocks(main); decorateSections(main); customDecorateSections(main); From 803bf741a4e438c67d4478138ba7aedbf6cc00a3 Mon Sep 17 00:00:00 2001 From: Lakshmishri Date: Thu, 12 Sep 2024 11:49:20 +0200 Subject: [PATCH 024/159] KAW-7941-NBA-component --- blocks/nba/nba.css | 54 +++++++++++++++++++++++++++++++++++++++++++ blocks/nba/nba.js | 33 ++++++++++++++++++++++++++ icons/arrow-right.svg | 5 ++++ scripts/helpers.js | 13 +++-------- styles/styles.css | 5 ++-- 5 files changed, 98 insertions(+), 12 deletions(-) create mode 100644 blocks/nba/nba.css create mode 100644 blocks/nba/nba.js create mode 100644 icons/arrow-right.svg diff --git a/blocks/nba/nba.css b/blocks/nba/nba.css new file mode 100644 index 0000000..84e8cc1 --- /dev/null +++ b/blocks/nba/nba.css @@ -0,0 +1,54 @@ +.nba { + --row-gap: 40px; + + justify-content: center; + align-items: center; + padding: 60px 20px; +} + +.nba-text-wrapper { + --row-gap: 16px; + + justify-content: center; + align-items: center; + text-align: center; +} + +.nba-button-wrapper { + --row-gap: 24px; + + width: 100%; +} + +.nba .nba-button-wrapper:not(:first-child) { + padding-top: 0; +} + +.nba-button-wrapper .icon-arrow-right { + height: 24px; + width: 24px; +} + +.nba , +.nba-button-wrapper, +.nba-text-wrapper { + display: flex; + flex-flow: column; + gap: var(--row-gap) +} + +.heading { + margin-bottom: 0; +} + +@media (width >= 768px) { + .nba { + padding-top: 80px; + padding-bottom: 80px; + } + + .nba .nba-button-wrapper { + width: auto; + flex-flow: row; + } +} \ No newline at end of file diff --git a/blocks/nba/nba.js b/blocks/nba/nba.js new file mode 100644 index 0000000..80410ef --- /dev/null +++ b/blocks/nba/nba.js @@ -0,0 +1,33 @@ +import { unwrapDivs } from '../../scripts/helpers.js'; + +export default async function decorate(block) { + const textWrapper = document.createElement('div'); + textWrapper.classList.add('nba-text-wrapper'); + + const headings = block.querySelectorAll('h1, h2, h3, h4, h5, h6'); + [...headings].forEach((heading) => { + heading.classList.add('heading'); + textWrapper.append(heading); + }); + + block.querySelectorAll('p').forEach((textEle) => { + if (!textEle.children.length) { + textWrapper.append(textEle); + } + }); + block.prepend(textWrapper); + + const buttonWrapper = document.createElement('div'); + buttonWrapper.classList.add('nba-button-wrapper'); + block.querySelectorAll('a').forEach((button, index) => { + const buttonClass = index < 1 ? 'primary' : 'secondary'; + button.classList.add('button', buttonClass); + if (button.parentElement.classList.contains('button-container')) { + button.parentElement.remove(); + } + buttonWrapper.append(button); + }); + block.append(buttonWrapper); + + unwrapDivs(block); +} diff --git a/icons/arrow-right.svg b/icons/arrow-right.svg new file mode 100644 index 0000000..db216f1 --- /dev/null +++ b/icons/arrow-right.svg @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/scripts/helpers.js b/scripts/helpers.js index 99494cb..38285bc 100644 --- a/scripts/helpers.js +++ b/scripts/helpers.js @@ -93,9 +93,8 @@ export const adjustPretitle = (element) => { }); }; -export const unwrapDivs = (element, options = {}) => { +export const unwrapDivs = (element) => { const stack = [element]; - const { ignoreDataAlign = false } = options; while (stack.length > 0) { const currentElement = stack.pop(); @@ -103,15 +102,9 @@ export const unwrapDivs = (element, options = {}) => { let i = 0; while (i < currentElement.children.length) { const node = currentElement.children[i]; - const attributesLength = [...node.attributes].filter((el) => { - if (ignoreDataAlign) { - return !(el.name.startsWith('data-align') || el.name.startsWith('data-valign')); - } - - return el; - }).length; + const attributesLength = [...node.attributes].filter((el) => el).length; - if (node.tagName === 'DIV' && attributesLength === 0) { + if (node && attributesLength === 0) { while (node.firstChild) { currentElement.insertBefore(node.firstChild, node); } diff --git a/styles/styles.css b/styles/styles.css index 2ea9594..3b0547e 100644 --- a/styles/styles.css +++ b/styles/styles.css @@ -57,6 +57,7 @@ .dark { background-color: var(--black); + color: var(--white); } :root .dark { @@ -436,8 +437,8 @@ button.secondary.small { .dark a.button.primary:hover, .dark button.primary:hover { - color: #ed1c24; - border-color: #ed1c24; + color: #ae2d27; + border-color: #ae2d27; } .dark a.button.primary:focus, From bb1cdea5fc9a73d4fc20a5dd97e7fa2ae33e194f Mon Sep 17 00:00:00 2001 From: Tomasz Dziezyk Date: Thu, 12 Sep 2024 12:15:58 +0200 Subject: [PATCH 025/159] KAW-7904 Add underline style for active links --- blocks/header/header.css | 51 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 47 insertions(+), 4 deletions(-) diff --git a/blocks/header/header.css b/blocks/header/header.css index e30aac1..30c8e9a 100644 --- a/blocks/header/header.css +++ b/blocks/header/header.css @@ -184,8 +184,18 @@ header .nav-tools .default-content-wrapper { header .nav-tools .default-content-wrapper li { margin: 0; + position: relative; +} + +header .nav-tools .default-content-wrapper li.active::after { + content: ""; + display: block; + width: 100%; + height: 1px; + background: black; } + header .nav-tools .default-content-wrapper li a:any-link { font-size: 0.875rem; font-style: normal; @@ -223,6 +233,10 @@ header .nav-drop[aria-expanded="false"] ul { display: none; } +header .nav-sections .nav-drop[aria-expanded="true"] { + color: var(--action-default); +} + header .nav-drop .icon-chevron { transition: transform 200ms ease-in-out; transform-origin: center center; @@ -385,6 +399,20 @@ header.transparent nav[aria-expanded="true"] .nav-link-section a.nav-drop-text { width: auto; } + header .nav-sections .nav-drop[aria-expanded="true"] .nav-drop-text { + color: var(--black); + } + + header .nav-sections .nav-drop[aria-expanded="true"] .nav-drop-text::after { + content: ""; + display: block; + width: 100%; + height: 1px; + position: absolute; + bottom: 0; + background: currentcolor; + } + /* expanded menu item content */ header .nav-sections .nav-drop ul { position: fixed; @@ -434,19 +462,34 @@ header.transparent nav[aria-expanded="true"] .nav-link-section a.nav-drop-text { } header.transparent nav[aria-expanded="true"] .nav-link-section a:any-link, - header.transparent nav[aria-expanded="true"] .nav-link-section a.nav-drop-text { + header.transparent + nav[aria-expanded="true"] + .nav-link-section + a.nav-drop-text { color: var(--white); } - header.transparent nav[aria-expanded="true"] .nav-link-section .nav-drop a:any-link { + header.transparent + nav[aria-expanded="true"] + .nav-link-section + .nav-drop + a:any-link { color: var(--grey-90); } - header.transparent nav[aria-expanded="true"] .nav-link-section .nav-drop a:focus { + header.transparent + nav[aria-expanded="true"] + .nav-link-section + .nav-drop + a:focus { color: var(--action-focus); } - header.transparent nav[aria-expanded="true"] .nav-link-section .nav-drop a:hover { + header.transparent + nav[aria-expanded="true"] + .nav-link-section + .nav-drop + a:hover { color: var(--action-hover); } } From 6a680faea077c007aa4a720536c19b9f8c48e96c Mon Sep 17 00:00:00 2001 From: Tomasz Dziezyk Date: Thu, 12 Sep 2024 12:23:08 +0200 Subject: [PATCH 026/159] KAW-7904 Fix navigation location --- blocks/header/header.css | 5 +++++ blocks/header/header.js | 16 +++++++++++----- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/blocks/header/header.css b/blocks/header/header.css index 30c8e9a..50009a6 100644 --- a/blocks/header/header.css +++ b/blocks/header/header.css @@ -15,6 +15,7 @@ header.fade-out { header .nav-wrapper { width: 100%; color: var(--grey-90); + background-color: var(--white); } header nav { @@ -275,6 +276,10 @@ header.transparent nav { color: var(--white); } +header.transparent .nav-wrapper { + background-color: transparent; +} + /* stylelint-disable-next-line no-descending-specificity */ header.transparent a:any-link { color: var(--white); diff --git a/blocks/header/header.js b/blocks/header/header.js index 1222ef2..3bf0f91 100644 --- a/blocks/header/header.js +++ b/blocks/header/header.js @@ -108,7 +108,7 @@ function redirectPage(event) { const currentUrl = window.location; let redirectUrl = currentUrl.origin; - if (event.target.innerHTML === 'ENG') { + if (event.target.innerHTML.toLowerCase() === 'en') { if (!currentUrl.pathname.includes('/en/')) { redirectUrl = `${redirectUrl}/en`; } @@ -154,8 +154,7 @@ function handleTransparentAndScrolling(nav) { export default async function decorate(block) { // load nav as fragment const navMeta = getMetadata('nav'); - // const navPath = navMeta ? new URL(navMeta, window.location).pathname : '/nav'; - const navPath = '/drafts/tdziezyk/v3-nav'; + const navPath = navMeta ? new URL(navMeta, window.location).pathname : '/nav'; const fragment = await loadFragment(navPath); // decorate nav DOM @@ -211,8 +210,15 @@ export default async function decorate(block) { toolsWrapper.classList.add('default-content-wrapper'); navTools.append(toolsWrapper); navTools.firstElementChild.remove(); - toolsWrapper.querySelectorAll('li').forEach((list) => { - list.addEventListener('click', redirectPage); + toolsWrapper.querySelectorAll('li').forEach((item) => { + item.addEventListener('click', redirectPage); + + const urlLang = document.location.pathname.includes('/en/') ? 'en' : 'ita'; + const listItemLang = item.textContent.trim().toLowerCase(); + + if (urlLang === listItemLang) { + item.classList.add('active'); + } }); } From c0d50bd132b843a745541c252baf42c46666495e Mon Sep 17 00:00:00 2001 From: Tomasz Dziezyk Date: Thu, 12 Sep 2024 12:28:19 +0200 Subject: [PATCH 027/159] KAW-7904 Fix init state of the header --- blocks/header/header.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/blocks/header/header.js b/blocks/header/header.js index 3bf0f91..ff7eee1 100644 --- a/blocks/header/header.js +++ b/blocks/header/header.js @@ -124,9 +124,7 @@ function handleTransparentAndScrolling(nav) { const header = nav.closest('header'); let prevScrollingPosition = 0; - document.addEventListener('scroll', () => { - const { scrollY } = window; - + const changeToTransparentIfNeeded = (scrollY) => { if (useTransparentVariant) { header.classList.add('transparent', 'can-be-transparent'); @@ -136,6 +134,12 @@ function handleTransparentAndScrolling(nav) { header.classList.add('transparent'); } } + }; + + document.addEventListener('scroll', () => { + const { scrollY } = window; + + changeToTransparentIfNeeded(scrollY); if (scrollY - prevScrollingPosition > 0 && scrollY > 200) { header.classList.add('fade-out'); @@ -145,6 +149,8 @@ function handleTransparentAndScrolling(nav) { prevScrollingPosition = scrollY; }); + + changeToTransparentIfNeeded(window.scrollY); } /** From a1704c40059b9aab67bf73f21335336188b0bed8 Mon Sep 17 00:00:00 2001 From: Tomasz Dziezyk Date: Thu, 12 Sep 2024 12:39:55 +0200 Subject: [PATCH 028/159] KAW-7904 Fix transparent header when click on models --- blocks/header/header.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/blocks/header/header.js b/blocks/header/header.js index ff7eee1..f110c82 100644 --- a/blocks/header/header.js +++ b/blocks/header/header.js @@ -91,6 +91,10 @@ function toggleSubNav(navSection, navSections) { const expanded = navSection.getAttribute('aria-expanded') === 'true'; toggleAllNavSections(navSections); navSection.setAttribute('aria-expanded', expanded ? 'false' : 'true'); + + if (!expanded) { + document.querySelector('header').classList.remove('transparent'); + } } function checkForActiveLink(navSections) { From 7879e87b45666a2dd265282657e57e8a8eba1c91 Mon Sep 17 00:00:00 2001 From: Tomasz Dziezyk Date: Thu, 12 Sep 2024 12:41:54 +0200 Subject: [PATCH 029/159] KAW-7904 Fix language selection --- blocks/header/header.css | 2 +- blocks/header/header.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/blocks/header/header.css b/blocks/header/header.css index 50009a6..f3e43b9 100644 --- a/blocks/header/header.css +++ b/blocks/header/header.css @@ -193,7 +193,7 @@ header .nav-tools .default-content-wrapper li.active::after { display: block; width: 100%; height: 1px; - background: black; + background: currentcolor; } diff --git a/blocks/header/header.js b/blocks/header/header.js index f110c82..4eb00d9 100644 --- a/blocks/header/header.js +++ b/blocks/header/header.js @@ -223,7 +223,7 @@ export default async function decorate(block) { toolsWrapper.querySelectorAll('li').forEach((item) => { item.addEventListener('click', redirectPage); - const urlLang = document.location.pathname.includes('/en/') ? 'en' : 'ita'; + const urlLang = document.location.pathname.includes('/en/') ? 'en' : 'it'; const listItemLang = item.textContent.trim().toLowerCase(); if (urlLang === listItemLang) { From 078554eff8a9ddab28d9931c8d35c495170262e4 Mon Sep 17 00:00:00 2001 From: Lakshmishri Date: Thu, 12 Sep 2024 13:57:46 +0200 Subject: [PATCH 030/159] remove class attribute --- blocks/nba/nba.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/blocks/nba/nba.js b/blocks/nba/nba.js index 80410ef..19132d8 100644 --- a/blocks/nba/nba.js +++ b/blocks/nba/nba.js @@ -23,7 +23,7 @@ export default async function decorate(block) { const buttonClass = index < 1 ? 'primary' : 'secondary'; button.classList.add('button', buttonClass); if (button.parentElement.classList.contains('button-container')) { - button.parentElement.remove(); + button.parentElement.removeAttribute('class'); } buttonWrapper.append(button); }); From 691330c07b3ca5f24b9cafaa1e7c9fd6165f7e79 Mon Sep 17 00:00:00 2001 From: Tomasz Dziezyk Date: Fri, 13 Sep 2024 12:06:42 +0200 Subject: [PATCH 031/159] KAW-7904 Add the Model label for expanded menu on desktop --- blocks/header/header.css | 29 +++++++++++++++++++++++------ blocks/header/header.js | 29 ++++++++++++++--------------- 2 files changed, 37 insertions(+), 21 deletions(-) diff --git a/blocks/header/header.css b/blocks/header/header.css index f3e43b9..4626fad 100644 --- a/blocks/header/header.css +++ b/blocks/header/header.css @@ -95,7 +95,8 @@ header .nav-dealer-locator a.button:focus { color: var(--action-focus); } -header .nav-drop picture { +header .nav-drop picture, +header .nav-sublist > span { display: none; } @@ -160,13 +161,13 @@ header .nav-drop ul { cursor: auto; } -header .nav-sections ul > li > ul { +header .nav-sections ul > li .nav-sublist ul { margin: 0; gap: 16px; padding: 10px 0 0; } -header .nav-sections ul > li > ul a:any-link { +header .nav-sections ul > li .nav-sublist ul a:any-link { font-size: 0.875rem; font-style: normal; font-weight: 500; @@ -197,6 +198,7 @@ header .nav-tools .default-content-wrapper li.active::after { } +/* stylelint-disable-next-line no-descending-specificity */ header .nav-tools .default-content-wrapper li a:any-link { font-size: 0.875rem; font-style: normal; @@ -230,7 +232,7 @@ header .nav-drop { cursor: pointer; } -header .nav-drop[aria-expanded="false"] ul { +header .nav-drop[aria-expanded="false"] .nav-sublist { display: none; } @@ -419,7 +421,7 @@ header.transparent nav[aria-expanded="true"] .nav-link-section a.nav-drop-text { } /* expanded menu item content */ - header .nav-sections .nav-drop ul { + header .nav-sections .nav-drop .nav-sublist { position: fixed; top: var(--nav-height); padding: 40px; @@ -427,6 +429,10 @@ header.transparent nav[aria-expanded="true"] .nav-link-section a.nav-drop-text { left: 0; height: auto; background: var(--white); + } + + header .nav-sections .nav-drop ul { + padding: 0; gap: unset; justify-content: space-between; flex-wrap: wrap; @@ -444,10 +450,21 @@ header.transparent nav[aria-expanded="true"] .nav-link-section a.nav-drop-text { line-height: 140%; } - header .nav-sections .nav-drop ul picture { + header .nav-sections .nav-drop ul picture, + header .nav-sublist > span { display: flex; } + + header .nav-sublist > span { + padding: 0 40px 24px; + font-weight: 500; + font-size: 1.75rem; + line-height: 2.275; + color: var(--black); + cursor: auto; + } + header .nav-sections .nav-drop ul img { width: 187px; height: auto; diff --git a/blocks/header/header.js b/blocks/header/header.js index 4eb00d9..8c40cc7 100644 --- a/blocks/header/header.js +++ b/blocks/header/header.js @@ -190,7 +190,8 @@ export default async function decorate(block) { if (navSections) { navSections.querySelectorAll(':scope .default-content-wrapper > ul > li').forEach((navSection) => { - if (navSection.querySelector('ul')) { + const sublist = navSection.querySelector('ul'); + if (sublist) { const textWrapper = document.createElement('a'); textWrapper.classList.add('nav-drop-text'); textWrapper.append(navSection.firstChild); @@ -204,10 +205,21 @@ export default async function decorate(block) { link.prepend(picture); }); + + const sublistWrapper = document.createElement('div'); + sublistWrapper.classList.add('nav-sublist'); + const sublistHeading = document.createElement('span'); + sublistHeading.textContent = textWrapper.textContent; + sublist.replaceWith(sublistWrapper); + sublistWrapper.append(sublistHeading); + sublistWrapper.append(sublist); } navSection.addEventListener('click', (event) => { - if (event.target.classList.contains('nav-drop-text') || event.target.closest('.nav-drop-text')) { + if ( + event.target.classList.contains('nav-drop-text') + || event.target.classList.contains('nav-drop') + || event.target.closest('.nav-drop-text')) { toggleSubNav(navSection, navSections); } }); @@ -278,19 +290,6 @@ export default async function decorate(block) { block.append(navWrapper); checkForActiveLink(navSections); - - const observer = new IntersectionObserver((entries) => { - entries.forEach((entry) => { - if (entry.isIntersecting && isDesktop) { - navWrapper.classList.add('hide'); - } else if (isDesktop) { - navWrapper.classList.remove('hide'); - } - }); - }, { rootMargin: '0px 0px -1000px 0px' }); - observer.observe(document.querySelector('main')); - handleTransparentAndScrolling(nav); - customDecoreateIcons(nav); } From 5e649de6a941733e4e55a0515f0749c76a51c239 Mon Sep 17 00:00:00 2001 From: Tomasz Dziezyk Date: Fri, 13 Sep 2024 12:33:13 +0200 Subject: [PATCH 032/159] KAW-7904 Fix hover colors --- blocks/header/header.css | 4 ++-- blocks/header/header.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/blocks/header/header.css b/blocks/header/header.css index 4626fad..737b0f9 100644 --- a/blocks/header/header.css +++ b/blocks/header/header.css @@ -44,7 +44,7 @@ header a:any-link { header a:active, header a:focus, header a:hover { - color: var(--action-default); + color: var(--action-hover); } /* brand */ @@ -335,7 +335,7 @@ header.transparent nav[aria-expanded="true"] .nav-link-section a.nav-drop-text { } } -@media (width >= 1024px) { +@media (width >= 1025px) { header .nav-brand { flex-grow: unset; } diff --git a/blocks/header/header.js b/blocks/header/header.js index 8c40cc7..cee5e23 100644 --- a/blocks/header/header.js +++ b/blocks/header/header.js @@ -3,7 +3,7 @@ import { customDecoreateIcons } from '../../scripts/scripts.js'; import { loadFragment } from '../fragment/fragment.js'; // media query match that indicates mobile/tablet width -const isDesktop = window.matchMedia('(min-width: 1024px)'); +const isDesktop = window.matchMedia('(min-width: 1025px)'); function closeOnEscape(e) { if (e.code === 'Escape') { From 5b997f9404f99bf3edd39761a655433a787a70e2 Mon Sep 17 00:00:00 2001 From: Tomasz Dziezyk Date: Fri, 13 Sep 2024 13:04:56 +0200 Subject: [PATCH 033/159] KAW-7904 Disable main doc scrolling when the menu is expanded --- blocks/header/header.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/blocks/header/header.js b/blocks/header/header.js index cee5e23..f3e6b97 100644 --- a/blocks/header/header.js +++ b/blocks/header/header.js @@ -94,6 +94,9 @@ function toggleSubNav(navSection, navSections) { if (!expanded) { document.querySelector('header').classList.remove('transparent'); + document.body.style.overflow = 'hidden'; + } else { + document.body.style.overflow = ''; } } From 9e5545f0c1b3199dab787866449ba799f941d25c Mon Sep 17 00:00:00 2001 From: Tomasz Dziezyk Date: Mon, 16 Sep 2024 09:22:04 +0200 Subject: [PATCH 034/159] KAW-7904 Add animations for header --- blocks/header/header.css | 21 +++++++----- blocks/header/header.js | 71 +++++++++++++++++++++++++++++++++++----- 2 files changed, 76 insertions(+), 16 deletions(-) diff --git a/blocks/header/header.css b/blocks/header/header.css index 737b0f9..2a18a0d 100644 --- a/blocks/header/header.css +++ b/blocks/header/header.css @@ -96,10 +96,14 @@ header .nav-dealer-locator a.button:focus { } header .nav-drop picture, -header .nav-sublist > span { +header .nav-sublist > div > span { display: none; } +header .nav-sublist > div { + overflow: hidden; +} + header .nav-link-section { position: fixed; top: 0; @@ -136,10 +140,6 @@ header .nav-flag .icon { display: flex; } -header nav[aria-expanded="true"] .nav-link-section { - display: flex; -} - header .nav-sections ul { list-style: none; padding: 0; @@ -349,6 +349,7 @@ header.transparent nav[aria-expanded="true"] .nav-link-section a.nav-drop-text { height: auto; flex-grow: 1; align-items: center; + display: flex; } header .nav-backdrop { @@ -424,11 +425,15 @@ header.transparent nav[aria-expanded="true"] .nav-link-section a.nav-drop-text { header .nav-sections .nav-drop .nav-sublist { position: fixed; top: var(--nav-height); - padding: 40px; width: 100vw; left: 0; height: auto; background: var(--white); + padding: 0; + } + + header .nav-sections .nav-drop .nav-sublist > div { + padding: 40px; } header .nav-sections .nav-drop ul { @@ -451,12 +456,12 @@ header.transparent nav[aria-expanded="true"] .nav-link-section a.nav-drop-text { } header .nav-sections .nav-drop ul picture, - header .nav-sublist > span { + header .nav-sublist > div > span { display: flex; } - header .nav-sublist > span { + header .nav-sublist > div > span { padding: 0 40px 24px; font-weight: 500; font-size: 1.75rem; diff --git a/blocks/header/header.js b/blocks/header/header.js index f3e6b97..a06a164 100644 --- a/blocks/header/header.js +++ b/blocks/header/header.js @@ -5,6 +5,45 @@ import { loadFragment } from '../fragment/fragment.js'; // media query match that indicates mobile/tablet width const isDesktop = window.matchMedia('(min-width: 1025px)'); +const animateInOut = (animateTarget, isFadeIn, initStyles, startStyles, endStyles) => { + animateTarget.style.transition = 'all 300ms ease-in-out'; + + const setStyles = (targetEl, stylesObject) => { + Object.entries(stylesObject).forEach(([key, value]) => { + targetEl.style[key] = value; + }); + }; + + const cssReflow = () => { + // trigger reflow to ensure the transition starts from the current state + // read more here: https://gist.github.com/paulirish/5d52fb081b3570c81e3a + // eslint-disable-next-line no-unused-expressions + animateTarget.offsetWidth; + }; + + const restoreDisplayPropAfterHide = () => { + const transitionEndEvent = () => { + animateTarget.style.display = ''; + animateTarget.removeEventListener('transitionend', transitionEndEvent); + }; + + animateTarget.addEventListener('transitionend', transitionEndEvent); + }; + + setStyles(animateTarget, initStyles); + + if (isFadeIn) { + setStyles(animateTarget, startStyles); + cssReflow(); + setStyles(animateTarget, endStyles); + } else { + setStyles(animateTarget, endStyles); + cssReflow(); + restoreDisplayPropAfterHide(); + setStyles(animateTarget, startStyles); + } +}; + function closeOnEscape(e) { if (e.code === 'Escape') { const nav = document.getElementById('nav'); @@ -73,8 +112,18 @@ function toggleMenu(nav, navSections, forceExpanded = null) { const backdropEl = nav.querySelector('.nav-backdrop'); if (!expanded) { + if (document.querySelector('header nav .nav-link-section')) { + const animateTarget = document.querySelector('header nav .nav-link-section'); + + animateInOut(animateTarget, !expanded, { display: 'flex' }, { right: '-320px' }, { right: '0' }); + } backdropEl.classList.remove('hide'); } else { + if (document.querySelector('header nav .nav-link-section')) { + const animateTarget = document.querySelector('header nav .nav-link-section'); + + animateInOut(animateTarget, !expanded, { display: 'flex' }, { right: '-320px' }, { right: '0' }); + } backdropEl.classList.add('hide'); } @@ -90,14 +139,17 @@ function toggleMenu(nav, navSections, forceExpanded = null) { function toggleSubNav(navSection, navSections) { const expanded = navSection.getAttribute('aria-expanded') === 'true'; toggleAllNavSections(navSections); - navSection.setAttribute('aria-expanded', expanded ? 'false' : 'true'); if (!expanded) { document.querySelector('header').classList.remove('transparent'); document.body.style.overflow = 'hidden'; + animateInOut(navSection.querySelector('.nav-sublist'), expanded, { display: 'grid' }, { gridTemplateRows: '1fr' }, { gridTemplateRows: '0fr' }); } else { document.body.style.overflow = ''; + animateInOut(navSection.querySelector('.nav-sublist'), !expanded, { display: 'grid' }, { gridTemplateRows: '0fr' }, { gridTemplateRows: '1fr' }); } + + navSection.setAttribute('aria-expanded', expanded ? 'false' : 'true'); } function checkForActiveLink(navSections) { @@ -209,13 +261,16 @@ export default async function decorate(block) { link.prepend(picture); }); - const sublistWrapper = document.createElement('div'); - sublistWrapper.classList.add('nav-sublist'); - const sublistHeading = document.createElement('span'); - sublistHeading.textContent = textWrapper.textContent; - sublist.replaceWith(sublistWrapper); - sublistWrapper.append(sublistHeading); - sublistWrapper.append(sublist); + const navSublist = document.createRange().createContextualFragment(` + + `).children[0]; + + sublist.replaceWith(navSublist); } navSection.addEventListener('click', (event) => { From a5665823e2d11ebb75783f28bad954fab1fdeebb Mon Sep 17 00:00:00 2001 From: Tomasz Dziezyk Date: Mon, 16 Sep 2024 09:46:03 +0200 Subject: [PATCH 035/159] KAW-7904 Refactor --- blocks/header/header.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/blocks/header/header.js b/blocks/header/header.js index a06a164..3244c82 100644 --- a/blocks/header/header.js +++ b/blocks/header/header.js @@ -138,15 +138,16 @@ function toggleMenu(nav, navSections, forceExpanded = null) { function toggleSubNav(navSection, navSections) { const expanded = navSection.getAttribute('aria-expanded') === 'true'; + const navSublist = navSection.querySelector('.nav-sublist'); toggleAllNavSections(navSections); - if (!expanded) { + if (expanded) { + document.body.style.overflow = ''; + animateInOut(navSublist, !expanded, { display: 'grid' }, { gridTemplateRows: '0fr' }, { gridTemplateRows: '1fr' }); + } else { document.querySelector('header').classList.remove('transparent'); document.body.style.overflow = 'hidden'; - animateInOut(navSection.querySelector('.nav-sublist'), expanded, { display: 'grid' }, { gridTemplateRows: '1fr' }, { gridTemplateRows: '0fr' }); - } else { - document.body.style.overflow = ''; - animateInOut(navSection.querySelector('.nav-sublist'), !expanded, { display: 'grid' }, { gridTemplateRows: '0fr' }, { gridTemplateRows: '1fr' }); + animateInOut(navSublist, !expanded, { display: 'grid' }, { gridTemplateRows: '0fr' }, { gridTemplateRows: '1fr' }); } navSection.setAttribute('aria-expanded', expanded ? 'false' : 'true'); From 5d7ce3f68ea5d79624c41a09729ca92d215bc19d Mon Sep 17 00:00:00 2001 From: Tomasz Dziezyk Date: Mon, 16 Sep 2024 09:49:24 +0200 Subject: [PATCH 036/159] KAW-7904 Refactor --- blocks/header/header.js | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/blocks/header/header.js b/blocks/header/header.js index 3244c82..5c21304 100644 --- a/blocks/header/header.js +++ b/blocks/header/header.js @@ -112,21 +112,17 @@ function toggleMenu(nav, navSections, forceExpanded = null) { const backdropEl = nav.querySelector('.nav-backdrop'); if (!expanded) { - if (document.querySelector('header nav .nav-link-section')) { - const animateTarget = document.querySelector('header nav .nav-link-section'); - - animateInOut(animateTarget, !expanded, { display: 'flex' }, { right: '-320px' }, { right: '0' }); - } backdropEl.classList.remove('hide'); } else { - if (document.querySelector('header nav .nav-link-section')) { - const animateTarget = document.querySelector('header nav .nav-link-section'); - - animateInOut(animateTarget, !expanded, { display: 'flex' }, { right: '-320px' }, { right: '0' }); - } backdropEl.classList.add('hide'); } + if (document.querySelector('header nav .nav-link-section')) { + const animateTarget = document.querySelector('header nav .nav-link-section'); + + animateInOut(animateTarget, !expanded, { display: 'flex' }, { right: '-320px' }, { right: '0' }); + } + // enable menu collapse on escape keypress if (!expanded || isDesktop.matches) { // collapse menu on escape press @@ -143,13 +139,12 @@ function toggleSubNav(navSection, navSections) { if (expanded) { document.body.style.overflow = ''; - animateInOut(navSublist, !expanded, { display: 'grid' }, { gridTemplateRows: '0fr' }, { gridTemplateRows: '1fr' }); } else { document.querySelector('header').classList.remove('transparent'); document.body.style.overflow = 'hidden'; - animateInOut(navSublist, !expanded, { display: 'grid' }, { gridTemplateRows: '0fr' }, { gridTemplateRows: '1fr' }); } + animateInOut(navSublist, !expanded, { display: 'grid' }, { gridTemplateRows: '0fr' }, { gridTemplateRows: '1fr' }); navSection.setAttribute('aria-expanded', expanded ? 'false' : 'true'); } From 5f4f99889d4c4664d947a39a3d9f05703d4f62b5 Mon Sep 17 00:00:00 2001 From: Ioana Iordache Date: Mon, 16 Sep 2024 10:35:13 +0200 Subject: [PATCH 037/159] KAW-7921: teaser component --- .gitignore | 2 + blocks/columns/columns.js | 1 - blocks/teaser/teaser.css | 159 ++++++++++++++++++++++++++++++++++++++ blocks/teaser/teaser.js | 20 +++++ icons/arrow-right.svg | 10 +++ 5 files changed, 191 insertions(+), 1 deletion(-) create mode 100644 blocks/teaser/teaser.css create mode 100644 blocks/teaser/teaser.js create mode 100644 icons/arrow-right.svg diff --git a/.gitignore b/.gitignore index 5f4aed1..04097bc 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,5 @@ helix-importer-ui .DS_Store *.bak .idea + +.vscode/settings.json diff --git a/blocks/columns/columns.js b/blocks/columns/columns.js index f64a7f3..4530132 100644 --- a/blocks/columns/columns.js +++ b/blocks/columns/columns.js @@ -13,7 +13,6 @@ export default function decorate(block) { block.classList.remove(borderClassName); } const isDownloadVariant = block.classList.contains('download'); - const isGridVariant = block.classList.contains('grid'); const isGalleryVariant = block.classList.contains('gallery'); const ratioClass = [...block.classList].find((cl) => cl.startsWith('ratio-')); diff --git a/blocks/teaser/teaser.css b/blocks/teaser/teaser.css new file mode 100644 index 0000000..d73f906 --- /dev/null +++ b/blocks/teaser/teaser.css @@ -0,0 +1,159 @@ +/* general styles */ +.teaser > ul { + list-style: none; + margin: 0; + padding: 0; + display: grid; + grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); + grid-gap: 24px; +} + +.teaser > ul > li { + border-radius: 4px; + background-color: var(--grey-5); + display: flex; + flex-direction: column; + justify-content: space-between; + height: 100%; + border: 1px solid transparent; + position: relative; +} + +.teaser li:hover { + border-color: var(--black); +} + +.teaser .teaser-card-body { + margin: 28px 20px; + flex-grow: 1; + display: flex; + flex-direction: column; + justify-content: space-between; +} + +.teaser .teaser-card-body .h4, +.teaser .teaser-card-body p { + margin-bottom: 16px; +} + +.teaser .teaser-card-body p:has(+ .button-container) { + margin-bottom: 24px; +} + +.teaser .button-container { + margin-top: auto; + margin-bottom: 0; +} + +.teaser .button-container .icon-arrow-right { + display: flex; +} + +.teaser .teaser-card-body a.button { + border-color: transparent; + color: var(--black); +} + +.teaser .teaser-card-body a.button::after { + position: absolute; + inset: 0; + z-index: 1; + content: ""; +} + +.teaser li:hover .teaser-card-body a.button { + border-color: var(--action-hover); + color: var(--action-hover); +} + +.teaser .teaser-card-image { + line-height: 0; +} + +.teaser > ul > li img { + width: 100%; + aspect-ratio: 4 / 3; + object-fit: cover; +} + +@media (width >= 1024px) { + .teaser .teaser-card-body { + margin: 16px 20px; + } +} + +div.teaser-wrapper + div.teaser-wrapper { + padding-top: 24px; +} + +/* teaser image */ +.teaser.image li { + overflow: hidden; + min-height: 464px; + display: grid; + justify-content: unset; + color: white; +} + +.teaser.image .teaser-card-image { + grid-area: 1 / 1; +} + +.teaser.image .teaser-card-image img { + height: 100%; +} + +.teaser.image .teaser-card-body { + grid-area: 1 / 1; + margin: 0; + padding: 20px 16px; + background-image: linear-gradient( + 180deg, + rgb(0 0 0 / 0%) 40%, + rgba(0 0 0/ 40%) 99% + ); + justify-content: end; +} + +.teaser.image .teaser-card-body .button-container { + margin-top: unset; +} + +@media (width >= 768) { + .teaser.image li { + min-height: 474px; + } +} + +@media (width >= 1025) { + .teaser.image li { + min-height: 451px; + } +} + +@media (width >= 1440) { + .teaser.image li { + min-height: 566px; + } +} + +/* teaser 30%-60% */ +@media (width >= 1024px) { + .teaser.one-two > ul { + grid-template-columns: 33% 66%; + } +} + +/* teaser 66%-33% */ +@media (width >= 1024px) { + .teaser.two-one > ul { + grid-template-columns: 66% 33%; + } +} + +/* teaser 1-1 */ +@media (width >= 1024px) { + .teaser.one-one > ul { + grid-template-columns: 50% 50%; + } +} diff --git a/blocks/teaser/teaser.js b/blocks/teaser/teaser.js new file mode 100644 index 0000000..344b726 --- /dev/null +++ b/blocks/teaser/teaser.js @@ -0,0 +1,20 @@ +import { createOptimizedPicture } from '../../scripts/aem.js'; + +export default function decorate(block) { + /* change to ul, li */ + const ul = document.createElement('ul'); + [...block.children].forEach((row) => { + const li = document.createElement('li'); + while (row.firstElementChild) li.append(row.firstElementChild); + [...li.children].forEach((div) => { + if (div.children.length === 1 && div.querySelector('picture')) div.className = 'teaser-card-image'; + else div.className = 'teaser-card-body'; + }); + ul.append(li); + // each heading should be rendered as font-small + [...li.querySelectorAll('h1, h2, h3, h4, h5, h6')].forEach((heading) => heading.classList.add('h4')); + }); + ul.querySelectorAll('picture > img').forEach((img) => img.closest('picture').replaceWith(createOptimizedPicture(img.src, img.alt, false, [{ width: '750' }]))); + block.textContent = ''; + block.append(ul); +} diff --git a/icons/arrow-right.svg b/icons/arrow-right.svg new file mode 100644 index 0000000..679dc2e --- /dev/null +++ b/icons/arrow-right.svg @@ -0,0 +1,10 @@ + + + + + + + + + + From 87f2be1929247aa67002954653d7d8620cfcc144 Mon Sep 17 00:00:00 2001 From: Tomasz Dziezyk Date: Mon, 16 Sep 2024 10:52:13 +0200 Subject: [PATCH 038/159] KAW-7904 Add animation for each model --- blocks/header/header.css | 8 ++++++++ blocks/header/header.js | 13 ++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/blocks/header/header.css b/blocks/header/header.css index 2a18a0d..4348d50 100644 --- a/blocks/header/header.css +++ b/blocks/header/header.css @@ -460,6 +460,14 @@ header.transparent nav[aria-expanded="true"] .nav-link-section a.nav-drop-text { display: flex; } + header .nav-sections .nav-sublist li { + transition: opacity 400ms linear; + opacity: 0; + } + + header .nav-sections .nav-sublist.subnav-fadein li { + opacity: 1; + } header .nav-sublist > div > span { padding: 0 40px 24px; diff --git a/blocks/header/header.js b/blocks/header/header.js index 5c21304..18b43f8 100644 --- a/blocks/header/header.js +++ b/blocks/header/header.js @@ -4,9 +4,10 @@ import { loadFragment } from '../fragment/fragment.js'; // media query match that indicates mobile/tablet width const isDesktop = window.matchMedia('(min-width: 1025px)'); +const fadeTransitionTime = 300; const animateInOut = (animateTarget, isFadeIn, initStyles, startStyles, endStyles) => { - animateTarget.style.transition = 'all 300ms ease-in-out'; + animateTarget.style.transition = `all ${fadeTransitionTime}ms ease-in-out`; const setStyles = (targetEl, stylesObject) => { Object.entries(stylesObject).forEach(([key, value]) => { @@ -139,8 +140,13 @@ function toggleSubNav(navSection, navSections) { if (expanded) { document.body.style.overflow = ''; + navSublist.classList.remove('subnav-fadein'); } else { document.querySelector('header').classList.remove('transparent'); + + setTimeout(() => { + navSublist.classList.add('subnav-fadein'); + }, 0); document.body.style.overflow = 'hidden'; } @@ -257,6 +263,11 @@ export default async function decorate(block) { link.prepend(picture); }); + // setting transtion delay for every list item + navSection.querySelectorAll('ul li').forEach((li, index) => { + li.style.transitionDelay = `${fadeTransitionTime + index * 200}ms`; + }); + const navSublist = document.createRange().createContextualFragment(`