Skip to content

Commit

Permalink
try and fix snapshots
Browse files Browse the repository at this point in the history
  • Loading branch information
langermank committed Feb 10, 2024
1 parent da4f490 commit 8a4d8fc
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 14 deletions.
18 changes: 9 additions & 9 deletions docs/storybook/.storybook/preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ const primerThemes = [
]

export const globalTypes = {
colorScheme: {
theme: {
name: 'Theme',
description: 'Switch themes',
defaultValue: 'light',
Expand All @@ -67,24 +67,24 @@ export const globalTypes = {

export const decorators = [
(Story, context) => {
const {colorScheme} = context.globals
const {theme} = context.globals

useEffect(() => {
const colorMode = colorScheme.startsWith('light') ? 'light' : 'dark'
const colorMode = theme.startsWith('light') ? 'light' : 'dark'
document.body.setAttribute('data-color-mode', colorMode)

const lightTheme = colorScheme.startsWith('light') ? colorScheme : undefined
const lightTheme = theme.startsWith('light') ? theme : undefined
document.body.setAttribute('data-light-theme', lightTheme)

const darkTheme = colorScheme.startsWith('dark') ? colorScheme : undefined
const darkTheme = theme.startsWith('dark') ? theme : undefined
document.body.setAttribute('data-dark-theme', darkTheme)
}, [colorScheme])
}, [theme])

const {parameters} = context
const defaultStoryType = 'swatch'
const storyType = parameters.storyType || defaultStoryType

if (context.globals.colorScheme === 'light-dark-split') {
if (context.globals.theme === 'light-dark-split') {
return (
<div className="light-dark-split">
{['light', 'dark'].map(theme => (
Expand All @@ -105,7 +105,7 @@ export const decorators = [
)
}

return context.globals.colorScheme === 'all' ? (
return context.globals.theme === 'all' ? (
primerThemes.map(({value: theme}) => (
<ThemeProvider key={theme} dayScheme={theme} nightScheme={theme} colorMode="day">
<div
Expand All @@ -126,7 +126,7 @@ export const decorators = [
</ThemeProvider>
))
) : (
<ThemeProvider dayScheme={context.globals.colorScheme} nightScheme={context.globals.colorScheme} colorMode="day">
<ThemeProvider dayScheme={context.globals.theme} nightScheme={context.globals.theme} colorMode="day">
<div className={clsx('story-wrap', parameters.storyType === 'swatch' && 'SwatchDecorator')}>
<Story {...context} />
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,11 @@ import {getTokensByName} from '../../utilities/getTokensByName'
export default {
title: 'Color/Functional/Tables',
parameters: {
parameters: {
controls: {hideNoControlsWarning: true},
options: {
showPanel: false,
},
controls: {hideNoControlsWarning: true},
options: {
showPanel: false,
},
tags: ['excludeSnapshot'],
},
}

Expand Down

0 comments on commit 8a4d8fc

Please sign in to comment.