Skip to content

Commit 3b533cc

Browse files
authored
chore(design-system): use app font-family (supabase#39958)
add custom font to design-system
1 parent 7c18997 commit 3b533cc

File tree

9 files changed

+65
-5
lines changed

9 files changed

+65
-5
lines changed
27.8 KB
Binary file not shown.
30.5 KB
Binary file not shown.
27.9 KB
Binary file not shown.
30.6 KB
Binary file not shown.
24.4 KB
Binary file not shown.
26.4 KB
Binary file not shown.
27.5 KB
Binary file not shown.
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import { Source_Code_Pro } from 'next/font/google'
2+
import localFont from 'next/font/local'
3+
4+
export const customFont = localFont({
5+
variable: '--font-custom',
6+
display: 'swap',
7+
fallback: ['Circular', 'custom-font', 'Helvetica Neue', 'Helvetica', 'Arial', 'sans-serif'],
8+
src: [
9+
{
10+
path: './CustomFont-Book.woff2',
11+
weight: '400',
12+
style: 'normal',
13+
},
14+
{
15+
path: './CustomFont-BookItalic.woff2',
16+
weight: '400',
17+
style: 'italic',
18+
},
19+
{
20+
path: './CustomFont-Medium.woff2',
21+
weight: '500',
22+
style: 'normal',
23+
},
24+
{
25+
path: './CustomFont-Bold.woff2',
26+
weight: '700',
27+
style: 'normal',
28+
},
29+
{
30+
path: './CustomFont-BoldItalic.woff2',
31+
weight: '700',
32+
style: 'italic',
33+
},
34+
{
35+
path: './CustomFont-Black.woff2',
36+
weight: '800',
37+
style: 'normal',
38+
},
39+
{
40+
path: './CustomFont-BlackItalic.woff2',
41+
weight: '800',
42+
style: 'italic',
43+
},
44+
],
45+
})
46+
47+
export const sourceCodePro = Source_Code_Pro({
48+
subsets: ['latin'],
49+
fallback: ['Source Code Pro', 'Office Code Pro', 'Menlo', 'monospace'],
50+
variable: '--font-source-code-pro',
51+
display: 'swap',
52+
weight: ['400', '500', '600', '700'],
53+
})

apps/design-system/app/layout.tsx

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import '@/styles/globals.css'
22
import type { Metadata } from 'next'
3-
import { Inter } from 'next/font/google'
43
import { ThemeProvider } from './Providers'
54
import { SonnerToaster } from './SonnerToast'
5+
import { customFont, sourceCodePro } from './fonts'
66

7-
const inter = Inter({ subsets: ['latin'] })
7+
const className = `${customFont.variable} ${sourceCodePro.variable}`
88

99
export const metadata: Metadata = {
1010
title: 'Supabase Design System',
@@ -17,9 +17,16 @@ interface RootLayoutProps {
1717

1818
export default async function Layout({ children }: RootLayoutProps) {
1919
return (
20-
<html lang="en" suppressHydrationWarning>
21-
<head />
22-
<body className={inter.className}>
20+
<html lang="en" suppressHydrationWarning className={className}>
21+
<head>
22+
{/* [Danny]: This has to be an inline style tag here and not a separate component due to next/font */}
23+
<style
24+
dangerouslySetInnerHTML={{
25+
__html: `:root{--font-custom:${customFont.style.fontFamily};--font-source-code-pro:${sourceCodePro.style.fontFamily};}`,
26+
}}
27+
/>
28+
</head>
29+
<body>
2330
<ThemeProvider
2431
themes={['dark', 'light', 'classic-dark']}
2532
defaultTheme="system"

0 commit comments

Comments
 (0)