@compositive/storybook
Version:
Storybook framework with useful defaults and integration with Compositive.
17 lines (13 loc) • 784 B
JavaScript
import { jsx } from 'react/jsx-runtime.js';
import { ThemeProvider } from '@compositive/foundation';
const GlobalThemeProvider = ({ globals, children, defaultThemeName, themes, }) => {
const theme = globals?.theme;
const currentThemeName = theme?.name ?? defaultThemeName;
const variants = theme?.variants ?? {};
const currentTheme = themes[currentThemeName];
return (jsx(ThemeProvider, { theme: currentTheme, ...variants, children: children }));
};
const withThemes = (themes, defaultThemeName) =>
// eslint-disable-next-line react/display-name
(StoryFn, context) => (jsx(GlobalThemeProvider, { globals: context.globals, themes: themes, defaultThemeName: defaultThemeName, children: jsx(StoryFn, {}) }));
export { GlobalThemeProvider as G, withThemes as w };