Skip to content

Commit 52f4748

Browse files
committed
refactor: vanilla extract banner and theme on stories (#5469)
* feat: banner vanilla extract * fix: imports and format
1 parent 671427e commit 52f4748

File tree

5 files changed

+311
-441
lines changed

5 files changed

+311
-441
lines changed

.changeset/strong-cats-float.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@ultraviolet/ui": major
3+
---
4+
5+
- Refactor component `Banner` to use vanilla-extract instead of Emotion
6+
- Fix dark/darker theme on stories with vanilla extract

.storybook/preview.tsx

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,16 +143,29 @@ const withThemeProvider = (Story: StoryFn, context: { globals: { theme: string }
143143
}
144144

145145
const decorators = [
146-
(Story: StoryFn) => (
146+
(Story: StoryFn, context: { globals: { theme: string } }) => {
147+
const theme = context.globals.theme || "light"
148+
const finalTheme = () => {
149+
if (theme === "light") {
150+
return lightTheme
151+
}
152+
if (theme === "dark") {
153+
return darkTheme
154+
}
155+
156+
return darkerTheme
157+
}
158+
159+
return (
147160
<>
148-
<ThemeProviderUI>
161+
<ThemeProviderUI theme={finalTheme()}>
149162
{
150163
// eslint-disable-next-line react/jsx-curly-brace-presence
151164
<Story />
152165
}
153166
</ThemeProviderUI>
154167
</>
155-
), // Storybook is broken without this please refer to this issue: https://github.com/storybookjs/storybook/issues/24625
168+
)}, // Storybook is broken without this please refer to this issue: https://github.com/storybookjs/storybook/issues/24625
156169
withThemeFromJSXProvider({
157170
themes: {
158171
light: lightTheme,

0 commit comments

Comments
 (0)