0
owncast/web/.storybook/storybook-theme.js

32 lines
805 B
JavaScript
Raw Normal View History

2022-05-17 14:23:52 -07:00
import React from 'react';
import { DocsContainer as BaseContainer } from '@storybook/addon-docs/blocks';
import { useDarkMode } from 'storybook-dark-mode';
import { themes } from '@storybook/theming';
export const DocsContainer = ({ children, context }) => {
const dark = useDarkMode();
return (
<BaseContainer
context={{
...context,
storyById: id => {
const storyContext = context.storyById(id);
return {
...storyContext,
parameters: {
...storyContext?.parameters,
docs: {
...storyContext?.parameters?.docs,
theme: dark ? themes.dark : themes.light,
},
},
};
},
}}
>
{children}
</BaseContainer>
);
};