/** * @file * @copyright 2020 Aleksej Komarov * @license MIT */ import { useLocalState } from '../backend'; import { Flex, Section, Tabs } from '../components'; import { Pane, Window } from '../layouts'; const r = require.context('../stories', false, /\.stories\.js$/); /** * @returns {{ * meta: { * title: string, * render: () => any, * }, * }[]} */ const getStories = () => r.keys().map((path) => r(path)); export const KitchenSink = (props, context) => { const { panel } = props; const [theme] = useLocalState(context, 'kitchenSinkTheme'); const [pageIndex, setPageIndex] = useLocalState(context, 'pageIndex', 0); const stories = getStories(); const story = stories[pageIndex]; const Layout = panel ? Pane : Window; return (
{stories.map((story, i) => ( setPageIndex(i)}> {story.meta.title} ))}
{story.meta.render()}
); };