Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit38f9406

Browse files
committed
Preload font in preview
1 parentf08d81e commit38f9406

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

‎site/.storybook/preview.tsx‎

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,16 @@ import CssBaseline from "@mui/material/CssBaseline";
44
import{
55
ThemeProviderasMuiThemeProvider,
66
StyledEngineProvider,
7-
// biome-ignore lint/style/noRestrictedImports: we extend the MUI theme
87
}from"@mui/material/styles";
98
import{DecoratorHelpers}from"@storybook/addon-themes";
109
importisChromaticfrom"chromatic/isChromatic";
1110
import{StrictMode}from"react";
12-
import{HelmetProvider}from"react-helmet-async";
11+
import{Helmet,HelmetProvider}from"react-helmet-async";
1312
import{QueryClient,QueryClientProvider}from"react-query";
1413
import{withRouter}from"storybook-addon-remix-react-router";
1514
import"theme/globalFonts";
15+
//@ts-expect-error -- This is throwing an error because of the ?url at then end of the import. It is a Vite feature to import the URL of an asset.
16+
importinterWoff2from"@fontsource-variable/inter/files/inter-latin-wght-normal.woff2?url";
1617
importtype{Decorator,Loader,Parameters}from"@storybook/react-vite";
1718
importthemesfrom"../src/theme";
1819

@@ -65,6 +66,15 @@ export const parameters: Parameters = {
6566
constwithHelmet:Decorator=(Story)=>{
6667
return(
6768
<HelmetProvider>
69+
<Helmet>
70+
<link
71+
rel="preload"
72+
as="font"
73+
type="font/woff2"
74+
href={interWoff2}
75+
crossOrigin="anonymous"
76+
/>
77+
</Helmet>
6878
<Story/>
6979
</HelmetProvider>
7080
);
@@ -95,8 +105,8 @@ const withQuery: Decorator = (Story, { parameters }) => {
95105

96106
constwithTheme:Decorator=(Story,context)=>{
97107
constselectedTheme=DecoratorHelpers.pluckThemeFromContext(context);
98-
const{ themeOverride}=DecoratorHelpers.useThemeParameters();
99-
constselected=themeOverride||selectedTheme||"dark";
108+
constthemeParameters=DecoratorHelpers.useThemeParameters();
109+
constselected=themeParameters?.themeOverride||selectedTheme||"dark";
100110

101111
// Ensure the correct theme is applied to Tailwind CSS classes by adding the
102112
// theme to the HTML class list. This approach is necessary because Tailwind

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp