Skip to content

Commit 830539c

Browse files
authored
NTP: Add badge to omnibar popover (#1956)
* Update omnibar popover to style "New" as a badge * Update localised strings * Update tests to accomodate NEW badge * Update Russian localization badge text
1 parent bc04e92 commit 830539c

File tree

15 files changed

+233
-8
lines changed

15 files changed

+233
-8
lines changed

special-pages/pages/new-tab/app/components/Popover.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,11 @@ import styles from './Popover.module.css';
1111
/**
1212
* @param {object} props
1313
* @param {string} props.title
14+
* @param {string} [props.badge]
1415
* @param {() => void} props.onClose
1516
* @param {import('preact').ComponentChildren} props.children
1617
*/
17-
export function Popover({ title, onClose, children }) {
18+
export function Popover({ title, badge, onClose, children }) {
1819
const { t } = useTypedTranslationWith(/** @type {Strings} */ ({}));
1920
const titleId = useId();
2021
const descriptionId = useId();
@@ -46,8 +47,9 @@ export function Popover({ title, onClose, children }) {
4647
<button class={styles.closeButton} onClick={onClose} aria-label={t('ntp_popover_close_button')}>
4748
<Cross />
4849
</button>
49-
<h3 id={titleId} class={styles.title}>
50-
{title}
50+
<h3 id={titleId} class={styles.heading}>
51+
{badge && <span class={styles.badge}>{badge}</span>}
52+
<span class={styles.title}>{title}</span>
5153
</h3>
5254
<p id={descriptionId} class={styles.description}>
5355
{children}

special-pages/pages/new-tab/app/components/Popover.module.css

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,24 @@
4646
}
4747
}
4848

49+
.heading {
50+
display: flex;
51+
flex-direction: column;
52+
gap: var(--sp-1);
53+
}
54+
55+
.badge {
56+
background: var(--color-yellow-60);
57+
border-radius: var(--border-radius-xs);
58+
color: var(--color-black);
59+
font-size: 11.5px;
60+
font-weight: 600;
61+
line-height: var(--sp-4);
62+
padding: 0 var(--sp-2);
63+
text-transform: uppercase;
64+
width: fit-content;
65+
}
66+
4967
.title {
5068
font-size: var(--title-3-em-font-size);
5169
font-weight: var(--title-3-em-font-weight);

special-pages/pages/new-tab/app/omnibar/components/Omnibar.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,11 @@ export function Omnibar({ mode, setMode, enableAi, showCustomizePopover, tabId }
8888
<div class={styles.tabSwitcherContainer}>
8989
<TabSwitcher mode={mode} onChange={handleChangeMode} />
9090
{showCustomizePopover && (
91-
<Popover title={t('omnibar_customizePopoverTitle')} onClose={handleCloseCustomizePopover}>
91+
<Popover
92+
title={t('omnibar_customizePopoverTitle')}
93+
badge={t('omnibar_customizePopoverBadge')}
94+
onClose={handleCloseCustomizePopover}
95+
>
9296
<Trans
9397
str={t('omnibar_customizePopoverDescription')}
9498
values={{

special-pages/pages/new-tab/app/omnibar/integration-tests/omnibar.spec.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1190,7 +1190,8 @@ test.describe('omnibar widget', () => {
11901190
await omnibar.ready();
11911191

11921192
await expect(omnibar.popover()).toBeVisible();
1193-
await expect(omnibar.popover()).toHaveText(/New! Toggle between search and AI chat/);
1193+
await expect(omnibar.popover()).toHaveText(/New/);
1194+
await expect(omnibar.popover()).toHaveText(/Toggle between search and AI chat/);
11941195
await expect(omnibar.popover()).toHaveText(/Either way, your info stays private/);
11951196
});
11961197

special-pages/pages/new-tab/app/omnibar/strings.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,13 @@
6060
"description": "Badge text shown next to open tab suggestions."
6161
},
6262
"omnibar_customizePopoverTitle": {
63-
"title": "New! Toggle between search and AI chat",
63+
"title": "Toggle between search and AI chat",
6464
"description": "Title for the popover that introduces the search/AI toggle feature."
6565
},
66+
"omnibar_customizePopoverBadge": {
67+
"title": "New",
68+
"description": "Badge text for the popover that introduces the search/AI toggle feature."
69+
},
6670
"omnibar_customizePopoverDescription": {
6771
"title": "Either way, your info stays private.<br />Don't want this? <button>Customize</button>",
6872
"description": "Description message in the popover including privacy statement and customize option."
226 Bytes
Loading

special-pages/pages/new-tab/public/locales/de/new-tab.json

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@
2828
"title" : "Neuen Tab anpassen",
2929
"note" : "Heading text describing that there's a list of toggles for customizing the page layout."
3030
},
31+
"ntp_popover_close_button" : {
32+
"title" : "Schließen",
33+
"note" : "Button that closes the current popover."
34+
},
3135
"updateNotification_updated_version" : {
3236
"title" : "Browser auf Version {version} aktualisiert.",
3337
"note" : "Text to indicate which new version was updated. `{version}` will be formatted like `1.22.0`"
@@ -176,6 +180,26 @@
176180
"title" : "{url} besuchen",
177181
"description" : "Text placed after suggestions that will open a webpage."
178182
},
183+
"omnibar_askDuckAiSuffix" : {
184+
"title" : "Frag Duck.ai",
185+
"description" : "Text placed after aiChat suggestions that will submit a chat query."
186+
},
187+
"omnibar_switchToTab" : {
188+
"title" : "Zu Tab wechseln",
189+
"description" : "Badge text shown next to open tab suggestions."
190+
},
191+
"omnibar_customizePopoverTitle" : {
192+
"title" : "Wechseln zwischen Suche und KI-Chat",
193+
"description" : "Title for the popover that introduces the search/AI toggle feature."
194+
},
195+
"omnibar_customizePopoverBadge" : {
196+
"title" : "Neu",
197+
"description" : "Badge text for the popover that introduces the search/AI toggle feature."
198+
},
199+
"omnibar_customizePopoverDescription" : {
200+
"title" : "Deine Daten bleiben auf jeden Fall privat.<br />Du möchtest das nicht? <button>Anpassen</button>",
201+
"description" : "Description message in the popover including privacy statement and customize option."
202+
},
179203
"nextSteps_sectionTitle" : {
180204
"title" : "Nächste Schritte",
181205
"note" : "Text that goes in the Next Steps bubble above the first card"

special-pages/pages/new-tab/public/locales/en/new-tab.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,9 +190,13 @@
190190
"description": "Badge text shown next to open tab suggestions."
191191
},
192192
"omnibar_customizePopoverTitle": {
193-
"title": "New! Toggle between search and AI chat",
193+
"title": "Toggle between search and AI chat",
194194
"description": "Title for the popover that introduces the search/AI toggle feature."
195195
},
196+
"omnibar_customizePopoverBadge": {
197+
"title": "New",
198+
"description": "Badge text for the popover that introduces the search/AI toggle feature."
199+
},
196200
"omnibar_customizePopoverDescription": {
197201
"title": "Either way, your info stays private.<br />Don't want this? <button>Customize</button>",
198202
"description": "Description message in the popover including privacy statement and customize option."

special-pages/pages/new-tab/public/locales/es/new-tab.json

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@
2828
"title" : "Personalizar página Nueva pestaña",
2929
"note" : "Heading text describing that there's a list of toggles for customizing the page layout."
3030
},
31+
"ntp_popover_close_button" : {
32+
"title" : "Cerrar",
33+
"note" : "Button that closes the current popover."
34+
},
3135
"updateNotification_updated_version" : {
3236
"title" : "Navegador actualizado a la versión {version}.",
3337
"note" : "Text to indicate which new version was updated. `{version}` will be formatted like `1.22.0`"
@@ -176,6 +180,26 @@
176180
"title" : "Visita {url}",
177181
"description" : "Text placed after suggestions that will open a webpage."
178182
},
183+
"omnibar_askDuckAiSuffix" : {
184+
"title" : "Pregúntale a Duck.ai",
185+
"description" : "Text placed after aiChat suggestions that will submit a chat query."
186+
},
187+
"omnibar_switchToTab" : {
188+
"title" : "Cambiar a Pestaña",
189+
"description" : "Badge text shown next to open tab suggestions."
190+
},
191+
"omnibar_customizePopoverTitle" : {
192+
"title" : "Alterna entre la búsqueda y el chat de IA",
193+
"description" : "Title for the popover that introduces the search/AI toggle feature."
194+
},
195+
"omnibar_customizePopoverBadge" : {
196+
"title" : "Nuevo",
197+
"description" : "Badge text for the popover that introduces the search/AI toggle feature."
198+
},
199+
"omnibar_customizePopoverDescription" : {
200+
"title" : "De cualquier manera, tu información sigue siendo privada.¿No es lo que querías? <button>Personalizar</button>",
201+
"description" : "Description message in the popover including privacy statement and customize option."
202+
},
179203
"nextSteps_sectionTitle" : {
180204
"title" : "Próximos pasos",
181205
"note" : "Text that goes in the Next Steps bubble above the first card"

special-pages/pages/new-tab/public/locales/fr/new-tab.json

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@
2828
"title" : "Personnaliser la nouvelle page d'onglet",
2929
"note" : "Heading text describing that there's a list of toggles for customizing the page layout."
3030
},
31+
"ntp_popover_close_button" : {
32+
"title" : "Fermer",
33+
"note" : "Button that closes the current popover."
34+
},
3135
"updateNotification_updated_version" : {
3236
"title" : "Mise à jour : le navigateur est passé à la version {version}.",
3337
"note" : "Text to indicate which new version was updated. `{version}` will be formatted like `1.22.0`"
@@ -176,6 +180,26 @@
176180
"title" : "Visiter {url}",
177181
"description" : "Text placed after suggestions that will open a webpage."
178182
},
183+
"omnibar_askDuckAiSuffix" : {
184+
"title" : "Demandez à Duck.ai",
185+
"description" : "Text placed after aiChat suggestions that will submit a chat query."
186+
},
187+
"omnibar_switchToTab" : {
188+
"title" : "Passer à l'onglet",
189+
"description" : "Badge text shown next to open tab suggestions."
190+
},
191+
"omnibar_customizePopoverTitle" : {
192+
"title" : "Basculer entre la recherche et le chat IA",
193+
"description" : "Title for the popover that introduces the search/AI toggle feature."
194+
},
195+
"omnibar_customizePopoverBadge" : {
196+
"title" : "Nouveau",
197+
"description" : "Badge text for the popover that introduces the search/AI toggle feature."
198+
},
199+
"omnibar_customizePopoverDescription" : {
200+
"title" : "Dans tous les cas, vos informations restent privées.<br />Ce n'est pas ce que vous souhaitez&nbsp;? <button>Personnaliser</button>",
201+
"description" : "Description message in the popover including privacy statement and customize option."
202+
},
179203
"nextSteps_sectionTitle" : {
180204
"title" : "Étapes suivantes",
181205
"note" : "Text that goes in the Next Steps bubble above the first card"

0 commit comments

Comments
 (0)