Skip to content

Commit bb208ab

Browse files
authored
Update JoyPixels (#2619)
1 parent 60e3500 commit bb208ab

File tree

7 files changed

+52
-35
lines changed

7 files changed

+52
-35
lines changed

packages/gitbook/src/components/RootLayout/globals.css

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,3 +192,30 @@ html {
192192
html.dark {
193193
color-scheme: dark light;
194194
}
195+
196+
/* Emojis */
197+
198+
[class*='emoji'] {
199+
font-family: var(--font-emojis-sbix);
200+
}
201+
202+
/* Safari Only CSS here */
203+
_::-webkit-full-page-media,
204+
_:future,
205+
:root [class*='emoji'] {
206+
font-family: var(--font-emojis-sbix);
207+
}
208+
209+
/* Chrome Only CSS here */
210+
@media screen and (-webkit-min-device-pixel-ratio: 0) {
211+
.emoji {
212+
font-family: var(--font-emojis-colrv1);
213+
}
214+
}
215+
216+
/* Firefox Only CSS here */
217+
@-moz-document url-prefix() {
218+
.emoji {
219+
font-family: var(--font-emojis-colrv1);
220+
}
221+
}

packages/gitbook/src/components/primitives/Emoji/Emoji.tsx

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,32 +3,46 @@ import localFont from 'next/font/local';
33
import { getEmojiForCode } from '@/lib/emojis';
44
import { ClassValue, tcls } from '@/lib/tailwind';
55

6-
import './emoji.css';
7-
8-
/* Load the 3 variants of the font as CSS variables and let the emoji.css decide on the best one to use */
9-
10-
const svgFont = localFont({
11-
src: './svg.woff2',
6+
/**
7+
COLRv1 font.
8+
- lightweight, top quality
9+
- widely supported by modern browsers
10+
- currently not by Safari (or iOS)
11+
*/
12+
const colrv1Font = localFont({
13+
src: './joypixels-colrv1.woff2',
1214
preload: false,
13-
variable: '--font-emojis-svg',
15+
variable: '--font-emojis-colrv1',
1416
});
1517

18+
/**
19+
SBIX font.
20+
- narrowly supported
21+
- currently required for Safari (or iOS)
22+
- provide alternative font-family name (see below)
23+
*/
1624
const sbixFont = localFont({
17-
src: './sbix.woff2',
25+
src: './joypixels-sbix.woff2',
1826
preload: false,
1927
variable: '--font-emojis-sbix',
2028
});
2129

30+
/**
31+
CBDT font.
32+
- widely supported
33+
- currently not by Safari (or iOS)
34+
- retain for legacy browser support
35+
*/
2236
const cbdtFont = localFont({
23-
src: './cbdt.woff2',
37+
src: './joypixels-cbdt.woff2',
2438
preload: false,
2539
variable: '--font-emojis-cbdt',
2640
});
2741

2842
/**
2943
* Class name to set on the <html> tag to use the emoji font.
3044
*/
31-
export const emojiFontClassName = [svgFont.variable, sbixFont.variable, cbdtFont.variable].join(
45+
export const emojiFontClassName = [colrv1Font.variable, sbixFont.variable, cbdtFont.variable].join(
3246
' ',
3347
);
3448

@@ -40,5 +54,5 @@ export async function Emoji(props: { code: string; style?: ClassValue }) {
4054
const { code, style } = props;
4155

4256
const fallback = getEmojiForCode(code);
43-
return <span className={'emoji ' + tcls(style)}>{fallback}</span>;
57+
return <span className={tcls('emoji', style)}>{fallback}</span>;
4458
}

packages/gitbook/src/components/primitives/Emoji/emoji.css

Lines changed: 0 additions & 24 deletions
This file was deleted.
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)