Skip to content

Commit 5121e98

Browse files
fix: polyfill country flag emojis for Edge/Windows (issue #52)
Co-authored-by: Alessandro100 <18631060+Alessandro100@users.noreply.github.com>
1 parent ce071a6 commit 5121e98

File tree

5 files changed

+20
-1
lines changed

5 files changed

+20
-1
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"@vercel/speed-insights": "^1.3.1",
2222
"axios": "^1.7.2",
2323
"countries-list": "^3.1.1",
24+
"country-flag-emoji-polyfill": "^0.1.8",
2425
"date-fns": "^2.30.0",
2526
"date-fns-tz": "^2.0.0",
2627
"export-to-csv": "^1.3.0",
76.5 KB
Binary file not shown.

src/app/Theme.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,10 @@ export enum ThemeModeEnum {
5656
}
5757

5858
export const fontFamily = {
59-
primary: 'var(--font-mulish)',
59+
// "Twemoji Country Flags" is loaded via a polyfill (polyfillCountryFlagEmojis in providers.tsx)
60+
// and uses unicode-range: U+1F1E6-1F1FF, so it only applies to flag emoji code points
61+
// and does not affect any other text rendering.
62+
primary: '"Twemoji Country Flags", var(--font-mulish)',
6063
secondary: 'var(--font-ibm-plex-mono)',
6164
};
6265

src/app/providers.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { type RemoteConfigValues } from './interface/RemoteConfig';
88
// Look into this provider and see if it's client blocking. Niche provider might be able to isolate for single use
99
import { LocalizationProvider } from '@mui/x-date-pickers/LocalizationProvider';
1010
import { AdapterDayjs } from '@mui/x-date-pickers/AdapterDayjs';
11+
import { polyfillCountryFlagEmojis } from 'country-flag-emoji-polyfill';
1112

1213
interface ProvidersProps {
1314
children: React.ReactNode;
@@ -19,6 +20,15 @@ export function Providers({
1920
children,
2021
remoteConfig,
2122
}: ProvidersProps): React.ReactElement {
23+
// Polyfill country flag emojis for browsers that don't support them natively
24+
// (e.g. Microsoft Edge / Chrome on Windows)
25+
React.useEffect(() => {
26+
polyfillCountryFlagEmojis(
27+
'Twemoji Country Flags',
28+
'/fonts/TwemojiCountryFlags.woff2',
29+
);
30+
}, []);
31+
2232
// Start MSW in mock mode to intercept API calls client-side
2333
React.useEffect(() => {
2434
if (process.env.NEXT_PUBLIC_API_MOCKING === 'enabled') {

yarn.lock

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4994,6 +4994,11 @@ countries-list@^3.1.1:
49944994
resolved "https://registry.yarnpkg.com/countries-list/-/countries-list-3.2.2.tgz#34ded4d3c8ebe715306cb5658c34f73a0c8f01cb"
49954995
integrity sha512-ABJ/RWQBrPWy+hRuZoW+0ooK8p65Eo3WmUZwHm6v4wmfSPznNAKzjy3+UUYrJK2v3182BVsgWxdB6ROidj39kw==
49964996

4997+
country-flag-emoji-polyfill@^0.1.8:
4998+
version "0.1.8"
4999+
resolved "https://registry.yarnpkg.com/country-flag-emoji-polyfill/-/country-flag-emoji-polyfill-0.1.8.tgz#d2cfb23dd2f949b80d83eb9822b613bf62957173"
5000+
integrity sha512-Mbah52sADS3gshUYhK5142gtUuJpHYOXlXtLFI3Ly4RqgkmPMvhX9kMZSTqDM8P7UqtSW99eHKFphhQSGXA3Cg==
5001+
49975002
crc-32@^1.2.0:
49985003
version "1.2.2"
49995004
resolved "https://registry.yarnpkg.com/crc-32/-/crc-32-1.2.2.tgz#3cad35a934b8bf71f25ca524b6da51fb7eace2ff"

0 commit comments

Comments
 (0)