Skip to content

Commit c4fbb4d

Browse files
authored
Multiple small NTP improvements (#1758)
* feat: Add getLocalizedNumberFormatter * docs: Improve docs for NTP url params * style: Switch Privacy Protections icon * chore: Use getLocalizedNumberFormatter in privacy stats * fix: Icon size and snapshots * chore: cleanup * chore: Switch to env value for locale instead of reading from document
1 parent 89ed165 commit c4fbb4d

21 files changed

+298
-60
lines changed

special-pages/pages/new-tab/app/index.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ export async function init(root, messaging, telemetry, baseEnvironment) {
109109
injectName={environment.injectName}
110110
willThrow={environment.willThrow}
111111
env={environment.env}
112+
locale={environment.locale}
112113
>
113114
<InlineErrorBoundary
114115
context={'App entry point'}
@@ -201,7 +202,12 @@ async function resolveEntryPoints(widgets, didCatch) {
201202
function renderComponents(root, environment, settings, strings) {
202203
// eslint-disable-next-line no-labels,no-unused-labels
203204
$INTEGRATION: render(
204-
<EnvironmentProvider debugState={environment.debugState} injectName={environment.injectName} willThrow={environment.willThrow}>
205+
<EnvironmentProvider
206+
debugState={environment.debugState}
207+
injectName={environment.injectName}
208+
willThrow={environment.willThrow}
209+
locale={environment.locale}
210+
>
205211
<SettingsProvider settings={settings}>
206212
<TranslationProvider translationObject={strings} fallback={enStrings} textLength={environment.textLength}>
207213
<Components />

special-pages/pages/new-tab/app/privacy-stats/components/PrivacyStats.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import { displayNameForCompany, sortStatsForDisplay } from '../privacy-stats.uti
88
import { CompanyIcon } from '../../components/CompanyIcon.js';
99
import { useBodyExpansion, useBodyExpansionApi } from './BodyExpansionProvider.js';
1010
import { ProtectionsEmpty } from '../../protections/components/Protections.js';
11+
import { getLocalizedNumberFormatter } from '../../../../../shared/utils.js';
12+
import { useLocale } from '../../../../../shared/components/EnvironmentProvider';
1113

1214
/**
1315
* @import enStrings from "../strings.json"
@@ -23,7 +25,8 @@ import { ProtectionsEmpty } from '../../protections/components/Protections.js';
2325
* @param {Expansion} [props.expansion]
2426
*/
2527
export function PrivacyStats({ trackerCompanies, expansion = 'expanded' }) {
26-
const [formatter] = useState(() => new Intl.NumberFormat());
28+
const locale = useLocale();
29+
const [formatter] = useState(() => getLocalizedNumberFormatter(locale));
2730
const sorted = sortStatsForDisplay(trackerCompanies);
2831
const largestTrackerCount = sorted[0]?.count ?? 0;
2932

@@ -207,7 +210,8 @@ function PillShowMoreLess({ expansion }) {
207210
*/
208211
export function OtherText({ count }) {
209212
const { t } = useTypedTranslationWith(/** @type {Strings} */ ({}));
210-
const [formatter] = useState(() => new Intl.NumberFormat());
213+
const locale = useLocale();
214+
const [formatter] = useState(() => getLocalizedNumberFormatter(locale));
211215
const formattedCount = formatter.format(count);
212216

213217
const otherText = t('stats_otherCount', { count: String(formattedCount) });

special-pages/pages/new-tab/app/privacy-stats/components/PrivacyStats.module.css

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
.heading {}
2-
31
.control {
42
display: flex;
53
align-items: center;
@@ -17,6 +15,11 @@
1715
align-items: center;
1816
justify-content: center;
1917
padding-top: 0.5px;
18+
19+
img {
20+
max-width: 1rem;
21+
max-height: 1rem;
22+
}
2023
}
2124

2225
.caption {
@@ -163,6 +166,3 @@
163166
background: var(--color-white-at-9);
164167
}
165168
}
166-
167-
.listExpander {
168-
}

special-pages/pages/new-tab/app/protections/components/ProtectionsHeading.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import cn from 'classnames';
66
import { h } from 'preact';
77
import { useAdBlocking } from '../../settings.provider.js';
88
import { Trans } from '../../../../../shared/components/TranslationsProvider.js';
9+
import { getLocalizedNumberFormatter } from '../../../../../shared/utils.js';
10+
import { useLocale } from '../../../../../shared/components/EnvironmentProvider.js';
911

1012
/**
1113
* @import enStrings from "../strings.json"
@@ -21,7 +23,8 @@ import { Trans } from '../../../../../shared/components/TranslationsProvider.js'
2123
*/
2224
export function ProtectionsHeading({ expansion, canExpand, blockedCountSignal, onToggle, buttonAttrs = {} }) {
2325
const { t } = useTypedTranslationWith(/** @type {Strings} */ ({}));
24-
const [formatter] = useState(() => new Intl.NumberFormat());
26+
const locale = useLocale();
27+
const [formatter] = useState(() => getLocalizedNumberFormatter(locale));
2528
const adBlocking = useAdBlocking();
2629
const blockedCount = blockedCountSignal.value;
2730
const none = blockedCount === 0;
@@ -41,7 +44,7 @@ export function ProtectionsHeading({ expansion, canExpand, blockedCountSignal, o
4144
<div class={styles.heading} data-testid="ProtectionsHeading">
4245
<div class={styles.control}>
4346
<span class={styles.headingIcon}>
44-
<img src={'./icons/shield-green.svg'} alt="Privacy Shield" />
47+
<img src={'./icons/Shield-Check-Color-16.svg'} alt="Privacy Shield" />
4548
</span>
4649
<h2 class={styles.caption}>{t('protections_menuTitle')}</h2>
4750
{canExpand && (
Loading
Loading
Loading
Loading
Loading
Loading

0 commit comments

Comments
 (0)