Skip to content

Commit 3183162

Browse files
committed
feat(theme): optimize Libre Baskerville
1 parent 4c5ae0c commit 3183162

File tree

7 files changed

+41
-49
lines changed

7 files changed

+41
-49
lines changed

app/layout.tsx

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
import { AppRouterCacheProvider } from '@mui/material-nextjs/v15-appRouter';
99
import InitColorSchemeScript from '@mui/material/InitColorSchemeScript';
1010
import { type Metadata, type Viewport } from 'next';
11-
import { Roboto } from 'next/font/google';
11+
import { Libre_Baskerville, Roboto } from 'next/font/google';
1212
import { type PropsWithChildren } from 'react';
1313

1414
import { Drawer } from '@/components/Drawer/Drawer';
@@ -22,8 +22,6 @@ import { theme } from '@/theme/theme';
2222
import { getClock } from '@/tools/clock/getClock';
2323
import { MENU } from '@/tools/markdown/menu';
2424

25-
import '@fontsource/libre-baskerville';
26-
2725
export const dynamicParams = false;
2826

2927
export const metadata: Metadata = {
@@ -39,6 +37,13 @@ export const viewport: Viewport = {
3937
width: 'device-width',
4038
};
4139

40+
const baskerville = Libre_Baskerville({
41+
display: 'swap',
42+
subsets: ['latin'],
43+
variable: '--font-baskerville',
44+
weight: ['400', '700'],
45+
});
46+
4247
const roboto = Roboto({
4348
display: 'swap',
4449
subsets: ['latin'],
@@ -49,19 +54,13 @@ const roboto = Roboto({
4954
export default async ({ children }: PropsWithChildren) => {
5055
const clock = await getClock();
5156
return (
52-
<Box
53-
component="html"
57+
<html
5458
lang="en"
5559
suppressHydrationWarning
5660
// NOTE Pad with the tallest toolbar: extra spacing in mobile, who's going
5761
// to complain?
58-
sx={{ scrollPaddingTop: 64 }}
5962
>
60-
<Box
61-
className={roboto.variable}
62-
component="body"
63-
sx={{ display: 'flex' }}
64-
>
63+
<body className={[baskerville.variable, roboto.variable].join(' ')}>
6564
<InitColorSchemeScript attribute="data" />
6665
<AppRouterCacheProvider>
6766
<ThemeProvider theme={theme}>
@@ -107,7 +106,7 @@ export default async ({ children }: PropsWithChildren) => {
107106
</LayoutProvider>
108107
</ThemeProvider>
109108
</AppRouterCacheProvider>
110-
</Box>
111-
</Box>
109+
</body>
110+
</html>
112111
);
113112
};

components/Markdown/renderers/Code.tsx

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,26 @@ const CodeBlock = ({
1010
children,
1111
language,
1212
}: PropsWithChildren<{ language: string }>) => (
13-
<Box
14-
component={Prism}
15-
customStyle={{
16-
borderRadius: undefined,
17-
margin: undefined,
18-
padding: undefined,
19-
}}
20-
language={language || 'text'}
21-
style={style}
22-
sx={{
23-
borderRadius: 4,
24-
display: 'block',
25-
fontSize: 'body2.fontSize',
26-
overscrollBehaviorInline: 'contain',
27-
p: 2,
28-
}}
29-
>
30-
{typeof children === 'string' ? children.trim() : children}
13+
<Box sx={{ borderRadius: 4, overflow: 'hidden' }}>
14+
<Box
15+
component={Prism}
16+
customStyle={{
17+
borderRadius: undefined,
18+
margin: undefined,
19+
padding: undefined,
20+
}}
21+
language={language || 'text'}
22+
style={style}
23+
sx={{
24+
borderRadius: 'inherit',
25+
display: 'block',
26+
fontSize: 'body2.fontSize',
27+
overscrollBehaviorInline: 'contain',
28+
p: 2,
29+
}}
30+
>
31+
{typeof children === 'string' ? children.trim() : children}
32+
</Box>
3133
</Box>
3234
);
3335

components/Markdown/renderers/Heading.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export const Heading: Components[`h${1 | 2 | 3 | 4 | 5 | 6}`] = ({
1919
throw new Error('Could not guess heading level');
2020
}
2121
return (
22-
<Typography id={id} sx={{ pt: 2 }} variant={node.tagName}>
22+
<Typography id={id} sx={{ pt: { xs: 2, sm: 3 } }} variant={node.tagName}>
2323
{children}
2424
</Typography>
2525
);

components/Markdown/renderers/Quote.tsx

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@ export const Quote: Components['blockquote'] = ({ children }) => (
77
sx={{
88
color: 'text.secondary',
99
display: 'grid',
10-
fontDisplay: 'swap',
11-
fontFamily: 'Libre Baskerville, serif',
12-
fontStyle: 'italic',
1310
gap: 2,
1411
pl: 2,
1512
py: 1,
@@ -24,9 +21,7 @@ export const Quote: Components['blockquote'] = ({ children }) => (
2421
position: 'absolute',
2522
width: 4,
2623
},
27-
'> *': {
28-
fontFamily: 'inherit',
29-
},
24+
'> *': { fontFamily: 'inherit' },
3025
}}
3126
>
3227
{children}

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
"dependencies": {
2828
"@emotion/react": "11.14.0",
2929
"@emotion/styled": "11.14.1",
30-
"@fontsource/libre-baskerville": "5.2.10",
3130
"@korumite/kiwi": "3.4.2",
3231
"@mdi/js": "7.4.47",
3332
"@mdi/react": "1.6.1",

pnpm-lock.yaml

Lines changed: 0 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

theme/theme.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,13 +111,18 @@ export const theme = responsiveFontSizes(
111111
MuiCssBaseline: {
112112
styleOverrides: {
113113
'blockquote, ol, p, pre, ul': { margin: 0, padding: 0 },
114-
html: { fontSize: 18, scrollBehavior: 'smooth' },
115-
em: {
114+
'blockquote, em': {
116115
fontDisplay: 'swap',
117116
fontFamily: 'Libre Baskerville, serif',
118117
fontSize: '0.9em',
119118
fontStyle: 'italic',
120119
},
120+
body: { display: 'flex' },
121+
html: {
122+
fontSize: 18,
123+
scrollBehavior: 'smooth',
124+
scrollPaddingTop: 64,
125+
},
121126
'ol, ul': { paddingLeft: '1em' },
122127
},
123128
},

0 commit comments

Comments
 (0)