Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0536a14

Browse files
authored
chore: fix storybook fonts (#988)
Summary: Configures storybook with MUI themes as according to their documentation. We were previously not aligned with their example. See: https://storybook.js.org/addons/@react-theming/storybook-addon Details: - configure a providerFn for MUI with CssBaseline. We were previously missing the CssBaseline implementation, causing the inconsistency. Impact: Resolves inconsistency between Storybook and production. I had tested the Tabpanel in production vs Storybook. In storybook, the font had fallen back to Times New Roman, whereas in production it had fallen back to Inter. This was because of CssBaseline being configured as a child of ThemeProvider. Resolves: #914
1 parent 6edd7cb commit 0536a14

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

site/.storybook/preview.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import CssBaseline from "@material-ui/core/CssBaseline"
12
import ThemeProvider from "@material-ui/styles/ThemeProvider"
23
import { withThemes } from "@react-theming/storybook-addon"
34
import { createMemoryHistory } from "history"
@@ -6,7 +7,14 @@ import { unstable_HistoryRouter as HistoryRouter } from "react-router-dom"
67
import { dark, light } from "../src/theme"
78
import "../src/theme/global-fonts"
89

9-
addDecorator(withThemes(ThemeProvider, [light, dark]))
10+
const providerFn = ({ children, theme }) => (
11+
<ThemeProvider theme={theme}>
12+
<CssBaseline />
13+
{children}
14+
</ThemeProvider>
15+
)
16+
17+
addDecorator(withThemes(null, [light, dark], { providerFn }))
1018

1119
const history = createMemoryHistory()
1220

0 commit comments

Comments
 (0)