Skip to content

Commit eb258ff

Browse files
authored
Merge pull request #10131 from TylerAPfledderer/refactor/inter-font-through-css
Refactor: Bring `Inter` and `IBM Plex Mono` Fonts to Prod / Update Implementation
2 parents 23d11a1 + e02613f commit eb258ff

File tree

10 files changed

+67
-63
lines changed

10 files changed

+67
-63
lines changed

.storybook/main.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ module.exports = {
1212
"@storybook/addon-a11y",
1313
"@chakra-ui/storybook-addon",
1414
],
15+
staticDirs: ["../static"],
1516
babel: async (options) => ({
1617
...babelConfig,
1718
}),

.storybook/preview.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ import { action } from "@storybook/addon-actions"
22

33
import theme from "../src/@chakra-ui/gatsby-plugin/theme"
44

5+
import "../static/fonts/inter-font-face.css"
6+
import "../static/fonts/ibm-plex-font-face.css"
7+
58
const chakraBreakpointArray = Object.entries(theme.breakpoints)
69

710
// Gatsby's Link overrides:

gatsby-ssr.tsx

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,21 @@ export const onRenderBody = ({ setHeadComponents }: RenderBodyArgs) => {
1818
crossOrigin="anonymous"
1919
key="interFont"
2020
/>,
21+
<link
22+
rel="preload"
23+
href="/fonts/Inter-Regular.woff"
24+
as="font"
25+
type="font/woff"
26+
crossOrigin="anonymous"
27+
key="interFont"
28+
/>,
29+
<link
30+
rel="preload"
31+
href="/fonts/IBMPlexMono-Regular.woff2"
32+
as="font"
33+
type="font/woff2"
34+
crossOrigin="anonymous"
35+
key="interFont"
36+
/>,
2137
])
2238
}

src/@chakra-ui/gatsby-plugin/foundations/typography.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
const typography = {
2-
// TODO: Uncomment when the `Inter` font is included in the project
3-
// fonts: {
4-
// heading: "Inter, sans-serif",
5-
// body: "Inter, sans-serif",
6-
// },
2+
fonts: {
3+
heading: "Inter, sans-serif",
4+
body: "Inter, sans-serif",
5+
monospace: "'IBM Plex Mono', Courier, monospace",
6+
},
77

88
lineHeights: {
99
"5xs": 1.1,

src/@chakra-ui/gatsby-plugin/theme.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,6 @@ const config: ThemeConfig = {
2929
*/
3030
const theme: ThemeOverride = {
3131
config,
32-
// TODO: fonts object to be removed (it'll now be in the 'foundation' directory)
33-
fonts: {
34-
// old fonts from the previous theme
35-
// TODO: update the fonts when we transition to the Design System
36-
heading:
37-
"system-ui, -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Helvetica, Arial, sans-serif",
38-
body: "system-ui, -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Helvetica, Arial, sans-serif",
39-
monospace:
40-
"SFMono-Regular, Consolas, 'Roboto Mono', 'Droid Sans Mono', 'Liberation Mono', Menlo, Courier, monospace",
41-
},
4232
styles,
4333
...foundations,
4434
semanticTokens,

src/components/Fonts.tsx

Lines changed: 0 additions & 46 deletions
This file was deleted.

src/components/Layout.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ import { isMobile } from "../utils/isMobile"
2828
import type { Context } from "../types"
2929

3030
import client from "../apollo"
31-
import Fonts from "./Fonts"
31+
32+
import "../../static/fonts/inter-font-face.css"
33+
import "../../static/fonts/ibm-plex-font-face.css"
3234

3335
export interface IProps {
3436
children?: React.ReactNode
@@ -107,7 +109,6 @@ const Layout: React.FC<IProps> = ({
107109
return (
108110
<ApolloProvider client={client}>
109111
<ThemeProvider theme={theme}>
110-
<Fonts />
111112
<ZenModeContext.Provider value={{ isZenMode, handleZenModeChange }}>
112113
<SkipLink hrefId="#main-content" />
113114
<TranslationBanner
38.4 KB
Binary file not shown.

static/fonts/ibm-plex-font-face.css

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
@font-face {
2+
font-family: "IBM Plex Mono";
3+
font-style: normal;
4+
font-weight: 400;
5+
font-display: swap;
6+
src: url("./IBMPlexMono-Regular.woff2") format("woff2");
7+
}

static/fonts/inter-font-face.css

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
@font-face {
2+
font-family: "Inter";
3+
font-style: normal;
4+
font-weight: 400;
5+
font-display: swap;
6+
src: url("./Inter-Regular.woff2") format("woff2"),
7+
url("./Inter-Regular.woff") format("woff");
8+
}
9+
@font-face {
10+
font-family: "Inter";
11+
font-style: italic;
12+
font-weight: 400;
13+
font-display: swap;
14+
src: url("./Inter-Italic.woff2") format("woff2"),
15+
url("./Inter-Italic.woff") format("woff");
16+
}
17+
@font-face {
18+
font-family: "Inter";
19+
font-style: normal;
20+
font-weight: 700;
21+
font-display: swap;
22+
src: url("./Inter-Bold.woff2") format("woff2"),
23+
url("./Inter-Bold.woff") format("woff");
24+
}
25+
@font-face {
26+
font-family: "Inter";
27+
font-style: italic;
28+
font-weight: 700;
29+
font-display: swap;
30+
src: url("./Inter-BoldItalic.woff2") format("woff2"),
31+
url("./Inter-BoldItalic.woff") format("woff");
32+
}

0 commit comments

Comments
 (0)