storybook-addon-playground
Version:
A playground to enable consumers learn how to use the component library or to reproduce bugs
24 lines (21 loc) • 947 B
JavaScript
import { useStorybookState, useParameter } from '@storybook/manager-api';
import { ADDON_ID_FOR_PARAMETERS } from '../consts/addon-consts.js';
import { DEFAULT_ADDON_PARAMETERS } from '../consts/parameter-consts.js';
import '@codemirror/commands';
import { githubDark, githubLight } from '@uiw/codemirror-theme-github';
function isBasicTheme(theme) {
return typeof theme === "string" && ["light", "dark"].includes(theme);
}
function getTheme(basicThemeName) {
return basicThemeName === "dark" ? githubDark : githubLight;
}
const useEditorTheme = () => {
const { theme: storybookTheme } = useStorybookState();
const { editorTheme: addonTheme } = useParameter(ADDON_ID_FOR_PARAMETERS, DEFAULT_ADDON_PARAMETERS);
if (isBasicTheme(addonTheme)) {
return getTheme(addonTheme);
}
return addonTheme || getTheme(storybookTheme.base);
};
export { useEditorTheme as default };
//# sourceMappingURL=useEditorTheme.js.map