Skip to content

add font preloading #22

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Apr 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions apps/site/astro.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export default defineConfig({
customCss: ['./src/styles/starlight.css'],
favicon: '/favicon.png',
components: {
Head: './src/components/starlight/StarlightHead.astro',
Header: './src/components/starlight/StarlightHeader.astro',
Sidebar: './src/components/starlight/StarlightSidebar.astro',
Footer: './src/components/starlight/StarlightFooter.astro',
Expand Down
2 changes: 1 addition & 1 deletion apps/site/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"@astrojs/starlight-tailwind": "2.0.1",
"@astrojs/tailwind": "5.1.0",
"@fontsource-variable/dosis": "5.0.19",
"@fontsource/atkinson-hyperlegible": "5.0.19",
"@fontsource-variable/inter": "5.0.17",
"@iconify-json/ph": "1.1.11",
"@iconify-json/ri": "1.1.20",
"@tailwindcss/forms": "0.5.7",
Expand Down
9 changes: 9 additions & 0 deletions apps/site/src/components/layout/Fonts.astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
import '@fontsource-variable/dosis';
import dosisWoff2 from '@fontsource-variable/dosis/files/dosis-latin-wght-normal.woff2?url';
import '@fontsource-variable/inter';
import interWoff2 from '@fontsource-variable/inter/files/inter-latin-wght-normal.woff2';
---

<link rel="preload" as="font" type="font/woff2" href={dosisWoff2} crossorigin />
<link rel="preload" as="font" type="font/woff2" href={interWoff2} crossorigin />
8 changes: 8 additions & 0 deletions apps/site/src/components/starlight/StarlightHead.astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
import Head from '@astrojs/starlight/components/Head.astro';
import type { Props } from '@astrojs/starlight/props';
import Fonts from '../layout/Fonts.astro';
---

<Head {...Astro.props} />
<Fonts />
3 changes: 1 addition & 2 deletions apps/site/src/components/starlight/StarlightHeader.astro
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
---
import '@fontsource-variable/dosis';
import '@fontsource/atkinson-hyperlegible/400.css';
import '@fontsource/atkinson-hyperlegible/700.css';
import '@fontsource-variable/inter';
import Banner from '../layout/Banner.astro';
import Header from '../layout/Header.astro';
---
Expand Down
5 changes: 2 additions & 3 deletions apps/site/src/layouts/Layout.astro
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
---
import '@fontsource-variable/dosis';
import '@fontsource/atkinson-hyperlegible/400.css';
import '@fontsource/atkinson-hyperlegible/700.css';
import Analytics from '~/components/layout/Analytics.astro';
import Banner from '~/components/layout/Banner.astro';
import Fonts from '~/components/layout/Fonts.astro';
import Footer from '~/components/layout/Footer.astro';
import Header from '~/components/layout/Header.astro';
import '~/styles/global.css';
Expand All @@ -22,6 +20,7 @@ const { title } = Astro.props;
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
<meta name="generator" content={Astro.generator} />
<title>{title}</title>
<Fonts />
</head>
<body class="flex min-h-full flex-col bg-white antialiased">
<Banner />
Expand Down
22 changes: 20 additions & 2 deletions apps/site/src/styles/starlight.css
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,19 @@
}
}

@layer base {
.sidebar-content .group-label > span {
font-family: "Dosis Variable";
font-weight: 900;
text-transform: uppercase;
}

.right-sidebar-panel h2 {
font-family: "Dosis Variable";
font-weight: 900;
text-transform: uppercase;
}

@layer base {
/*
1. Use a consistent sensible line-height in all browsers.
2. Prevent adjustments of font size after orientation changes in iOS.
Expand All @@ -38,7 +49,8 @@
-o-tab-size: 4;
tab-size: 4;
/* 3 */
font-family: ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
font-family: ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji",
"Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
/* 4 */
font-feature-settings: normal;
/* 5 */
Expand Down Expand Up @@ -97,4 +109,10 @@
vertical-align: middle;
/* 2 */
}

h1 {
font-family: "Dosis Variable";
font-weight: 900;
text-transform: uppercase;
}
}
42 changes: 23 additions & 19 deletions apps/site/tailwind.config.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,31 @@
export const colors = {
primary: {
50: '#FEF6FA',
100: '#FCEDF5',
200: '#F9D7E8',
300: '#F5C1DB',
400: '#F0A3C9',
500: '#EB80B5',
600: '#E34F99',
700: '#AE1C66',
800: '#8D1752',
900: '#6E1240',
950: '#4B0C2B',
},
};

export const fontFamily = {
sans: ['"Inter Variable"'],
heading: ['"Dosis Variable"'],
};

/** @type {import('tailwindcss').Config} */
export default {
content: ['./src/**/*.{astro,html,js,jsx,md,mdx,svelte,ts,tsx,vue}'],
theme: {
extend: {
colors: {
primary: {
50: '#FEF6FA',
100: '#FCEDF5',
200: '#F9D7E8',
300: '#F5C1DB',
400: '#F0A3C9',
500: '#EB80B5',
600: '#E34F99',
700: '#AE1C66',
800: '#8D1752',
900: '#6E1240',
950: '#4B0C2B',
},
},
fontFamily: {
sans: ['"Atkinson Hyperlegible"'],
heading: ['"Dosis Variable"'],
},
colors,
fontFamily,
},
},
plugins: [require('@tailwindcss/typography'), require('@tailwindcss/forms')],
Expand Down
35 changes: 5 additions & 30 deletions apps/site/tailwind.starlight.config.js
Original file line number Diff line number Diff line change
@@ -1,40 +1,15 @@
import { colors, fontFamily } from './tailwind.config';

/** @type {import('tailwindcss').Config} */
export default {
content: ['./src/**/*.{astro,html,js,jsx,md,mdx,svelte,ts,tsx,vue}'],
theme: {
extend: {
colors: {
primary: {
50: '#FEF6FA',
100: '#FCEDF5',
200: '#F9D7E8',
300: '#F5C1DB',
400: '#F0A3C9',
500: '#EB80B5',
600: '#E34F99',
700: '#AE1C66',
800: '#8D1752',
900: '#6E1240',
950: '#4B0C2B',
},
accent: {
50: '#FEF6FA',
100: '#FCEDF5',
200: '#F9D7E8',
300: '#F5C1DB',
400: '#F0A3C9',
500: '#EB80B5',
600: '#E34F99',
700: '#AE1C66',
800: '#8D1752',
900: '#6E1240',
950: '#4B0C2B',
},
},
fontFamily: {
sans: ['"Atkinson Hyperlegible"'],
heading: ['"Dosis Variable"'],
primary: colors.primary,
accent: colors.primary,
},
fontFamily,
},
},
plugins: [require('@astrojs/starlight-tailwind')()],
Expand Down
10 changes: 5 additions & 5 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.