Skip to content

Commit

Permalink
Fix theme in storybook
Browse files Browse the repository at this point in the history
  • Loading branch information
jonrohan committed Jun 3, 2024
1 parent 2aa8243 commit d0b1720
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions docs/.storybook/preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,12 @@ export const decorators = [
const {parameters} = context
const defaultStoryType = 'banner'
const storyType = parameters.storyType || defaultStoryType
document.body.setAttribute('data-color-mode', context.globals.theme.startsWith('light') ? 'light' : 'dark')
document.body.setAttribute(
'data-light-theme',
context.globals.theme.startsWith('light') ? context.globals.theme : undefined,
)
document.body.setAttribute(
'data-dark-theme',
context.globals.theme.startsWith('dark') ? context.globals.theme : undefined,
)
const colorMode = context.globals.theme === '' ? 'light' : (context.globals.theme.startsWith('light') ? 'light' : 'dark')
const lightTheme = context.globals.theme === '' ? 'light' : (colorMode === 'light' ? context.globals.theme : undefined)
const darkTheme = context.globals.theme === '' ? 'dark' : (colorMode === 'dark' ? context.globals.theme : undefined)
document.body.setAttribute('data-color-mode', colorMode)
document.body.setAttribute('data-light-theme', lightTheme)
document.body.setAttribute('data-dark-theme', darkTheme)
return (
<>
{context.globals.theme === 'all' ? (
Expand Down

0 comments on commit d0b1720

Please sign in to comment.