From d19aa15388894ffee2adfa1b3e8e7444d4ee53b7 Mon Sep 17 00:00:00 2001 From: Syb Wartna Date: Wed, 22 Nov 2023 19:10:39 +0100 Subject: [PATCH 1/4] fix Firefox issue with sorting --- scripts/scripts.js | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/scripts/scripts.js b/scripts/scripts.js index 39e0800a..f4dc5389 100644 --- a/scripts/scripts.js +++ b/scripts/scripts.js @@ -473,13 +473,10 @@ const createInpageNavigation = (main) => { // Sort the object by order const sortedObject = tabItemsObj.slice().sort((obj1, obj2) => { - if (!obj1.order) { - return 1; // Move 'a' to the end - } - if (!obj2.order) { - return -1; // Move 'b' to the end - } - return obj1.order - obj2.order; + const order1 = obj1.order ?? Infinity; // Fallback to a large number if 'order' is not present + const order2 = obj2.order ?? Infinity; + + return order1 - order2; }); // From the array of objects create the DOM From 5c4c4c9113b106e96b4e75a3985b9f69f315ad4c Mon Sep 17 00:00:00 2001 From: Syb Wartna Date: Wed, 22 Nov 2023 19:14:20 +0100 Subject: [PATCH 2/4] fix naming issues --- blocks/v2-inpage-navigation/v2-inpage-navigation.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/blocks/v2-inpage-navigation/v2-inpage-navigation.js b/blocks/v2-inpage-navigation/v2-inpage-navigation.js index f50d5013..ef4e3502 100644 --- a/blocks/v2-inpage-navigation/v2-inpage-navigation.js +++ b/blocks/v2-inpage-navigation/v2-inpage-navigation.js @@ -85,7 +85,7 @@ const updateActive = (id) => { // Remove focus position document.activeElement.blur(); - // check active id is equal to id dont do anything + // check active id is equal to id don't do anything const selectedItem = document.querySelector(`.${blockName}__selected-item`); activeItemInList?.classList.remove(`${blockName}__item--active`); const itemsButton = document.querySelectorAll(`.${blockName}__items button`); @@ -119,7 +119,7 @@ const addHeaderScrollBehaviour = (header) => { }; export default async function decorate(block) { - const redButton = inpageNavigationButton(); + const ctaButton = inpageNavigationButton(); const wrapper = block.querySelector(':scope > div'); wrapper.classList.add(`${blockName}__wrapper`); @@ -182,8 +182,8 @@ export default async function decorate(block) { itemsWrapper.remove(); - if (redButton) { - wrapper.appendChild(redButton); + if (ctaButton) { + wrapper.appendChild(ctaButton); } list.addEventListener('click', gotoSection); From a44091658aa157a5e37db581b80a788924a12f7c Mon Sep 17 00:00:00 2001 From: Syb Wartna Date: Wed, 22 Nov 2023 19:24:31 +0100 Subject: [PATCH 3/4] refactor focus state --- blocks/v2-inpage-navigation/v2-inpage-navigation.css | 8 ++++++++ styles/styles.css | 6 ++++++ 2 files changed, 14 insertions(+) diff --git a/blocks/v2-inpage-navigation/v2-inpage-navigation.css b/blocks/v2-inpage-navigation/v2-inpage-navigation.css index 98095912..fad68c52 100644 --- a/blocks/v2-inpage-navigation/v2-inpage-navigation.css +++ b/blocks/v2-inpage-navigation/v2-inpage-navigation.css @@ -250,6 +250,9 @@ then we change it for the next section item in main */ padding: 0; display: flex; align-items: center; + + /* fix overlap issue for focus state of CTA */ + background-color: transparent; } .v2-inpage-navigation__items { @@ -261,6 +264,11 @@ then we change it for the next section item in main */ position: relative; color: var(--c-grey-4); padding: 12px 0; + border-radius: 1px; + } + + .v2-inpage-navigation__item button:focus-visible { + outline-offset: 5px; } /* stylelint-disable-next-line no-descending-specificity */ diff --git a/styles/styles.css b/styles/styles.css index 37e2d0bd..3c1fa89c 100644 --- a/styles/styles.css +++ b/styles/styles.css @@ -608,7 +608,13 @@ main p img { .redesign-v2 a.button:focus, .redesign-v2 button:focus { + outline: 0; +} + +.redesign-v2 a.button:focus-visible, +.redesign-v2 button:focus-visible { outline: 2px solid var(--light-border-focus); + outline-offset: 2px; } /* sections */ From 469cf587f751edd9b154bc3bcc27e38449e6266d Mon Sep 17 00:00:00 2001 From: Syb Wartna Date: Wed, 22 Nov 2023 19:33:32 +0100 Subject: [PATCH 4/4] refactor button styles --- .../v2-inpage-navigation.css | 54 ++++++++----------- .../v2-inpage-navigation.js | 2 +- 2 files changed, 24 insertions(+), 32 deletions(-) diff --git a/blocks/v2-inpage-navigation/v2-inpage-navigation.css b/blocks/v2-inpage-navigation/v2-inpage-navigation.css index fad68c52..54fa31a2 100644 --- a/blocks/v2-inpage-navigation/v2-inpage-navigation.css +++ b/blocks/v2-inpage-navigation/v2-inpage-navigation.css @@ -90,10 +90,23 @@ then we change it for the next section item in main */ .v2-inpage-navigation__items-close { background: none; border: 0; + border-radius: 4px; color: var(--c-main-black); cursor: pointer; display: block; margin: 0 0 0 auto; + padding: 0; + width: 44px; + height: 44px; +} + +.v2-inpage-navigation__items-close svg { + display: block; + margin: auto; +} + +.v2-inpage-navigation__items-close:focus-visible { + outline: 2px solid var(--light-border-focus); } .v2-inpage-navigation__dropdown-title { @@ -125,6 +138,11 @@ then we change it for the next section item in main */ letter-spacing: var(--f-subtitle-2-letter-spacing); margin: 0; width: 100%; + border-radius: 1px; + } + +.v2-inpage-navigation__item button:focus-visible { + outline-offset: 5px; } /* stylelint-disable-next-line no-descending-specificity */ @@ -164,30 +182,10 @@ then we change it for the next section item in main */ /* END Customization when dropdown is open */ -/* Blue button */ -.v2-inpage-navigation__cta:any-link { - text-transform: uppercase; - padding: 9px 21px; - font-family: var(--font-family-body); - font-size: var(--f-button-font-size); +.redesign-v2 a.button.v2-inpage-navigation__cta:any-link { + height: auto; + padding: 8px 20px; line-height: var(--f-button-line-height); - letter-spacing: var(--f-button-letter-spacing); - border: 0; - background-color: var(--c-cta-blue-default); - color: var(--c-white); - align-items: center; - display: flex; - text-decoration: none; - border-radius: 4px; -} - -.v2-inpage-navigation__cta:hover, -.v2-inpage-navigation__cta:focus { - background-color: var(--c-cta-blue-hover); -} - -.v2-inpage-navigation__cta:active { - background-color: var(--c-cta-blue-active); } @media (min-width: 744px) { @@ -264,11 +262,6 @@ then we change it for the next section item in main */ position: relative; color: var(--c-grey-4); padding: 12px 0; - border-radius: 1px; - } - - .v2-inpage-navigation__item button:focus-visible { - outline-offset: 5px; } /* stylelint-disable-next-line no-descending-specificity */ @@ -297,8 +290,7 @@ then we change it for the next section item in main */ background-color: var(--c-main-black); } - /* Blue button */ - .v2-inpage-navigation__cta:any-link { - padding: 11px 21px; + .redesign-v2 a.button.v2-inpage-navigation__cta:any-link { + padding: 10px 20px; } } diff --git a/blocks/v2-inpage-navigation/v2-inpage-navigation.js b/blocks/v2-inpage-navigation/v2-inpage-navigation.js index ef4e3502..40869152 100644 --- a/blocks/v2-inpage-navigation/v2-inpage-navigation.js +++ b/blocks/v2-inpage-navigation/v2-inpage-navigation.js @@ -28,7 +28,7 @@ const inpageNavigationButton = () => { const title = getMetadata('inpage-button'); const url = getMetadata('inpage-link'); const link = createElement('a', { - classes: `${blockName}__cta`, + classes: ['button', 'marketing-cta', `${blockName}__cta`], props: { href: url, title,