UNPKG

storybook-addon-playground

Version:

A playground to enable consumers learn how to use the component library or to reproduce bugs

23 lines (20 loc) 838 B
import { useCallback, useEffect } from 'react'; import usePlaygroundState from './usePlaygroundState.js'; import { useStorybookApi } from '@storybook/manager-api'; import { PANEL_ID } from '../consts/addon-consts.js'; import '@codemirror/commands'; const useAutoOpenPlayground = () => { const { isPlaygroundStorySelected } = usePlaygroundState(); const { togglePanel, setSelectedPanel } = useStorybookApi(); const openPlaygroundPanel = useCallback(() => { togglePanel(true); setSelectedPanel(PANEL_ID); }, [togglePanel, setSelectedPanel]); useEffect(() => { if (isPlaygroundStorySelected) { openPlaygroundPanel(); } }, [isPlaygroundStorySelected, openPlaygroundPanel]); }; export { useAutoOpenPlayground as default }; //# sourceMappingURL=useAutoOpenPlayground.js.map