From fc29ac40e179e0e1df188f6cda3bf1b66df97141 Mon Sep 17 00:00:00 2001 From: Valerie Kraucunas Date: Tue, 3 Dec 2024 09:53:04 -0700 Subject: [PATCH 01/10] feat: Add confirmation to Mac Next Steps card --- .../pages/new-tab/app/components/Icons.js | 20 ++++++++++++++++ .../components/NextSteps.module.css | 17 +++++++++++++ .../next-steps/components/NextStepsCard.js | 24 ++++++++++++++++--- 3 files changed, 58 insertions(+), 3 deletions(-) diff --git a/special-pages/pages/new-tab/app/components/Icons.js b/special-pages/pages/new-tab/app/components/Icons.js index dd0198ecd..65e46bcf0 100644 --- a/special-pages/pages/new-tab/app/components/Icons.js +++ b/special-pages/pages/new-tab/app/components/Icons.js @@ -82,3 +82,23 @@ export function Cross() { ); } + +export function CheckColor() { + return ( + + + + + + ); +} diff --git a/special-pages/pages/new-tab/app/next-steps/components/NextSteps.module.css b/special-pages/pages/new-tab/app/next-steps/components/NextSteps.module.css index 21ca36c21..e6052d2d8 100644 --- a/special-pages/pages/new-tab/app/next-steps/components/NextSteps.module.css +++ b/special-pages/pages/new-tab/app/next-steps/components/NextSteps.module.css @@ -89,6 +89,23 @@ } } +.confirmation { + display: flex; + align-items: center; + transition: all .2s; + padding-bottom: var(--sp-1); + svg { + height: 1rem; + width: 1rem; + margin-right: var(--sp-2); + } + + p { + font-weight: 700; + font-size: calc(11 * var(--px-in-rem)); + } +} + .dismissBtn { position: absolute; top: 0.5rem; diff --git a/special-pages/pages/new-tab/app/next-steps/components/NextStepsCard.js b/special-pages/pages/new-tab/app/next-steps/components/NextStepsCard.js index 9e8103e48..c9a748e7c 100644 --- a/special-pages/pages/new-tab/app/next-steps/components/NextStepsCard.js +++ b/special-pages/pages/new-tab/app/next-steps/components/NextStepsCard.js @@ -3,6 +3,8 @@ import styles from './NextSteps.module.css'; import { DismissButton } from '../../components/DismissButton'; import { variants } from '../nextsteps.data'; import { useTypedTranslationWith } from '../../types'; +import { CheckColor } from '../../components/Icons'; +import { useState } from 'preact/hooks'; /** * @param {object} props @@ -14,14 +16,30 @@ import { useTypedTranslationWith } from '../../types'; export function NextStepsCard({ type, dismiss, action }) { const { t } = useTypedTranslationWith(/** @type {import("../strings.json")} */ ({})); const message = variants[type]?.(t); + const [showMacConfirmation, setShowMacConfirmation] = useState(false); + + const handleClick = () => { + if (message.id !== 'addAppToDockMac') { + return action(message.id); + } + action(message.id); + setShowMacConfirmation(true); + }; return (

{message.title}

{message.summary}

- + {message.id === 'addAppToDockMac' && !!showMacConfirmation ? ( +
+ +

Added to Dock!

+
+ ) : ( + + )} dismiss(message.id)} />
From 9bee2eb7ba967976a5c9c38eb1373d580dac07bf Mon Sep 17 00:00:00 2001 From: Valerie Kraucunas Date: Tue, 3 Dec 2024 18:35:46 -0700 Subject: [PATCH 02/10] chore: Make the fix better --- .../components/NextSteps.module.css | 26 ++++++++++++++++--- .../next-steps/components/NextStepsCard.js | 14 ++++++---- 2 files changed, 32 insertions(+), 8 deletions(-) diff --git a/special-pages/pages/new-tab/app/next-steps/components/NextSteps.module.css b/special-pages/pages/new-tab/app/next-steps/components/NextSteps.module.css index e6052d2d8..3798343b5 100644 --- a/special-pages/pages/new-tab/app/next-steps/components/NextSteps.module.css +++ b/special-pages/pages/new-tab/app/next-steps/components/NextSteps.module.css @@ -48,6 +48,16 @@ line-height: calc(14 * var(--px-in-rem)); color: var(--ntp-color-primary); + &.supressActiveStateForSwitch { + opacity: 1; + transition: opacity .3s ease-out; + + &:active { + background-color: var(--color-black-at-6); + opacity: 0; + } + } + &:hover { background-color: var(--color-black-at-6); cursor: pointer; @@ -73,6 +83,13 @@ } @media screen and (prefers-color-scheme: dark) { + &.supressActiveStateForSwitch { + /* outline: 1px solid yellow; */ + &:active { + background-color: var(--color-black-at-9); + } + } + &:hover:not(:active) { background-color: var(--color-black-at-9); } @@ -92,8 +109,11 @@ .confirmation { display: flex; align-items: center; - transition: all .2s; - padding-bottom: var(--sp-1); + transition: all .2s ease-in; + font-size: calc(11 * var(--px-in-rem)); + line-height: calc(14 * var(--px-in-rem)); + padding-bottom: calc(5 * var(--px-in-rem)); + svg { height: 1rem; width: 1rem; @@ -101,7 +121,7 @@ } p { - font-weight: 700; + font-weight: 600; font-size: calc(11 * var(--px-in-rem)); } } diff --git a/special-pages/pages/new-tab/app/next-steps/components/NextStepsCard.js b/special-pages/pages/new-tab/app/next-steps/components/NextStepsCard.js index c9a748e7c..bd6d8a4f7 100644 --- a/special-pages/pages/new-tab/app/next-steps/components/NextStepsCard.js +++ b/special-pages/pages/new-tab/app/next-steps/components/NextStepsCard.js @@ -1,4 +1,6 @@ import { h } from 'preact'; +import cn from 'classnames'; + import styles from './NextSteps.module.css'; import { DismissButton } from '../../components/DismissButton'; import { variants } from '../nextsteps.data'; @@ -16,27 +18,29 @@ import { useState } from 'preact/hooks'; export function NextStepsCard({ type, dismiss, action }) { const { t } = useTypedTranslationWith(/** @type {import("../strings.json")} */ ({})); const message = variants[type]?.(t); - const [showMacConfirmation, setShowMacConfirmation] = useState(false); + const [showConfirmation, setShowConfirmation] = useState(false); + const hasConfirmationState = message.id === 'addAppToDockMac'; const handleClick = () => { - if (message.id !== 'addAppToDockMac') { + if (!hasConfirmationState) { return action(message.id); } + action(message.id); - setShowMacConfirmation(true); + setShowConfirmation(true); }; return (

{message.title}

{message.summary}

- {message.id === 'addAppToDockMac' && !!showMacConfirmation ? ( + {hasConfirmationState && !!showConfirmation ? (

Added to Dock!

) : ( - )} From 1a590cdee0f12098799d2deb658f6994bb044a83 Mon Sep 17 00:00:00 2001 From: Valerie Kraucunas Date: Tue, 3 Dec 2024 18:49:10 -0700 Subject: [PATCH 03/10] fix: Text wrap in nextsteps button. --- .../new-tab/app/next-steps/components/NextSteps.module.css | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/special-pages/pages/new-tab/app/next-steps/components/NextSteps.module.css b/special-pages/pages/new-tab/app/next-steps/components/NextSteps.module.css index 3798343b5..b8bb0cf27 100644 --- a/special-pages/pages/new-tab/app/next-steps/components/NextSteps.module.css +++ b/special-pages/pages/new-tab/app/next-steps/components/NextSteps.module.css @@ -47,6 +47,7 @@ font-size: calc(11 * var(--px-in-rem)); line-height: calc(14 * var(--px-in-rem)); color: var(--ntp-color-primary); + text-wrap: wrap; /* needed for some languages */ &.supressActiveStateForSwitch { opacity: 1; @@ -84,7 +85,7 @@ @media screen and (prefers-color-scheme: dark) { &.supressActiveStateForSwitch { - /* outline: 1px solid yellow; */ + &:active { background-color: var(--color-black-at-9); } From 81246e9a181a4f79b07d670b3aba168f09a950a1 Mon Sep 17 00:00:00 2001 From: Valerie Kraucunas Date: Tue, 3 Dec 2024 19:19:16 -0700 Subject: [PATCH 04/10] chore: Update to use strings for confirm text --- .../new-tab/app/next-steps/components/NextStepsCard.js | 2 +- .../next-steps/integrations-tests/next-steps.spec.js | 10 ++++++++++ .../pages/new-tab/app/next-steps/nextsteps.data.js | 1 + 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/special-pages/pages/new-tab/app/next-steps/components/NextStepsCard.js b/special-pages/pages/new-tab/app/next-steps/components/NextStepsCard.js index bd6d8a4f7..232798ea9 100644 --- a/special-pages/pages/new-tab/app/next-steps/components/NextStepsCard.js +++ b/special-pages/pages/new-tab/app/next-steps/components/NextStepsCard.js @@ -37,7 +37,7 @@ export function NextStepsCard({ type, dismiss, action }) { {hasConfirmationState && !!showConfirmation ? (
-

Added to Dock!

+

{message.confirmationText}

) : (
) : ( - )} diff --git a/special-pages/pages/new-tab/app/next-steps/nextsteps.data.js b/special-pages/pages/new-tab/app/next-steps/nextsteps.data.js index eabe41889..23e592897 100644 --- a/special-pages/pages/new-tab/app/next-steps/nextsteps.data.js +++ b/special-pages/pages/new-tab/app/next-steps/nextsteps.data.js @@ -70,3 +70,9 @@ export const otherText = { /** @param {(translationId: keyof enStrings) => string} t */ nextSteps_sectionTitle: (t) => t('nextSteps_sectionTitle'), }; + +const cardsWithConfirmationText = ['addAppToDockMac']; + +export const additionalCardStates = { + hasConfirmationText: (/** @type {keyof variants} */ variantId) => cardsWithConfirmationText.includes(variantId), +}; From 8b37974cbefa3d6d8e0c15839606296e71c902d6 Mon Sep 17 00:00:00 2001 From: Valerie Kraucunas Date: Thu, 12 Dec 2024 12:51:17 -0700 Subject: [PATCH 10/10] fix: TS nest --- special-pages/pages/new-tab/app/next-steps/nextsteps.data.js | 1 + 1 file changed, 1 insertion(+) diff --git a/special-pages/pages/new-tab/app/next-steps/nextsteps.data.js b/special-pages/pages/new-tab/app/next-steps/nextsteps.data.js index 23e592897..0455c98f8 100644 --- a/special-pages/pages/new-tab/app/next-steps/nextsteps.data.js +++ b/special-pages/pages/new-tab/app/next-steps/nextsteps.data.js @@ -71,6 +71,7 @@ export const otherText = { nextSteps_sectionTitle: (t) => t('nextSteps_sectionTitle'), }; +/** @type {string[]} cardsWithConfirmationText */ const cardsWithConfirmationText = ['addAppToDockMac']; export const additionalCardStates = {