Skip to content

Commit cc66785

Browse files
refactor: supply Inter font through css files
1 parent 5bd35cd commit cc66785

File tree

8 files changed

+42
-64
lines changed

8 files changed

+42
-64
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: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ 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+
57
const chakraBreakpointArray = Object.entries(theme.breakpoints)
68

79
// Gatsby's Link overrides:

gatsby-ssr.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export const onRenderBody = ({ setHeadComponents }: RenderBodyArgs) => {
1212
setHeadComponents([
1313
<link
1414
rel="preload"
15-
href="/fonts/Inter-Regular.woff2"
15+
href="/fonts/Inter-Regular.woff2?v=3.19"
1616
as="font"
1717
type="font/woff2"
1818
crossOrigin="anonymous"

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

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
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+
},
76

87
lineHeights: {
98
"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: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ 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"
3233

3334
export interface IProps {
3435
children?: React.ReactNode
@@ -107,7 +108,6 @@ const Layout: React.FC<IProps> = ({
107108
return (
108109
<ApolloProvider client={client}>
109110
<ThemeProvider theme={theme}>
110-
<Fonts />
111111
<ZenModeContext.Provider value={{ isZenMode, handleZenModeChange }}>
112112
<SkipLink hrefId="#main-content" />
113113
<TranslationBanner

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)