Skip to content

Commit b0ec3f2

Browse files
committed
fix: set font stack as CSS variable instead of inline fontFamily
1 parent 7070606 commit b0ec3f2

1 file changed

Lines changed: 7 additions & 12 deletions

File tree

.storybook/preview.ts

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -74,29 +74,24 @@ const preview: Preview = {
7474
context.globals.theme === "light" ? lightTheme : darkTheme;
7575

7676
useEffect(() => {
77+
const root = document.documentElement.style;
78+
7779
// Apply CSS custom properties to the document root
7880
selectedTheme.forEach(([property, value]) => {
79-
document.documentElement.style.setProperty(property, value);
81+
root.setProperty(property, value);
8082
});
83+
root.setProperty("--vscode-font-family", getDefaultFontStack());
8184

8285
// Cleanup function to remove properties when unmounting
8386
return () => {
8487
selectedTheme.forEach(([property]) => {
85-
document.documentElement.style.removeProperty(property);
88+
root.removeProperty(property);
8689
});
90+
root.removeProperty("--vscode-font-family");
8791
};
8892
}, [selectedTheme]);
8993

90-
return createElement(
91-
"div",
92-
{
93-
id: "root",
94-
style: {
95-
fontFamily: getDefaultFontStack(),
96-
},
97-
},
98-
createElement(Story),
99-
);
94+
return createElement("div", { id: "root" }, createElement(Story));
10095
},
10196
],
10297
};

0 commit comments

Comments
 (0)