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

32 lines
798 B
JavaScript
Raw Normal View History

2022-05-17 23:23:52 +02:00
import React from 'react';
2022-06-22 02:28:12 +02:00
import { DocsContainer as BaseContainer } from '@storybook/addon-docs';
2022-05-17 23:23:52 +02:00
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>
);
};