1 line
No EOL
4.3 KiB
Text
1 line
No EOL
4.3 KiB
Text
{"version":3,"sources":["../src/manager.ts","../src/constants.ts","../src/Tool.tsx"],"names":["addons","types","ADDON_ID","TOOL_ID","PARAM_KEY","EVENTS","React","memo","useState","useGlobals","useStorybookApi","Icons","IconButton","TooltipLinkList","WithTooltip","Tool","isTooltipVisible","setIsTooltipVisible","globals","updateGlobals","api","isActive","onHide","theme","i","viewMode"],"mappings":"AAAA,OAAS,UAAAA,EAAQ,SAAAC,MAAa,yBCAvB,IAAMC,EAAW,8CACXC,EAAU,GAAGD,SACbE,EAAY,gBAEZC,EAAS,CACpB,OAAQ,GAAGH,WACX,QAAS,GAAGA,YACZ,MAAO,GAAGA,SACZ,ECRA,OAAOI,GAAS,QAAAC,EAAM,YAAAC,MAAgB,QACtC,OAAS,cAAAC,EAAY,mBAAAC,MAAuB,yBAC5C,OAAS,SAAAC,EAAO,cAAAC,EAAY,mBAAAC,EAAiB,eAAAC,MAAmB,wBAGzD,IAAMC,EAAOR,EAAK,UAA2B,CAClD,GAAM,CAACS,EAAkBC,CAAmB,EAAIT,EAAS,EAAK,EACxD,CAACU,EAASC,CAAa,EAAIV,EAAW,EACtCW,EAAMV,EAAgB,EAEtBW,EAAW,CAAC,CAACH,EAAQd,CAAS,EAEpC,OACEE,EAAA,cAACQ,EAAA,CACC,UAAU,MACV,oBAAmB,GACnB,QAAS,CAAC,CAAE,OAAAQ,CAAO,IAEfhB,EAAA,cAACO,EAAA,CACC,MAAO,CACL,UACA,UACA,WACA,YACA,UACA,cACA,UACA,WACA,UACA,OACA,SACA,cACA,UACA,WACA,cACA,eACA,iBACA,WACA,QACA,MACF,EAAE,IAAI,CAACU,EAAOC,KAAO,CACnB,GAAID,EACJ,MAAOA,EACP,SAAU,CACRJ,EAAc,CACZ,CAACf,CAAS,EAAGoB,EAAID,EAAQ,EAC3B,CAAC,EACDD,EAAO,CACT,EACA,MAAOC,EACP,OAAQA,IAAUL,EAAQd,CAAS,CACrC,EAAE,EACJ,EAGJ,gBAAiBa,GAEjBX,EAAA,cAACM,EAAA,CACC,IAAKT,EACL,OAAQkB,GAAYL,EACpB,MAAM,gBAENV,EAAA,cAACK,EAAA,CAAM,KAAK,SAAS,CACvB,CACF,CAEJ,CAAC,EFxDDX,EAAO,SAASE,EAAU,IAAM,CAE9BF,EAAO,IAAIG,EAAS,CAClB,KAAMF,EAAM,KACZ,MAAO,iBACP,MAAO,CAAC,CAAE,SAAAwB,CAAS,IAAM,CAAC,EAAEA,GAAYA,EAAS,MAAM,gBAAgB,GACvE,OAAQV,CACV,CAAC,CACH,CAAC","sourcesContent":["import { addons, types } from \"@storybook/manager-api\";\nimport { ADDON_ID, TOOL_ID } from \"./constants\";\nimport { Tool } from \"./Tool\";\n\n/**\n * Note: if you want to use JSX in this file, rename it to `manager.tsx`\n * and update the entry prop in tsup.config.ts to use \"src/manager.tsx\",\n */\n\n// Register the addon\naddons.register(ADDON_ID, () => {\n // Register the tool\n addons.add(TOOL_ID, {\n type: types.TOOL,\n title: \"Valkyrie theme\",\n match: ({ viewMode }) => !!(viewMode && viewMode.match(/^(story|docs)$/)),\n render: Tool,\n });\n});","export const ADDON_ID = \"valkyriecoms/storybook-addon-valkyrie-theme\";\nexport const TOOL_ID = `${ADDON_ID}/tool`;\nexport const PARAM_KEY = `valkyrieTheme`;\n\nexport const EVENTS = {\n RESULT: `${ADDON_ID}/result`,\n REQUEST: `${ADDON_ID}/request`,\n CLEAR: `${ADDON_ID}/clear`,\n};","import React, { memo, useState } from \"react\";\nimport { useGlobals, useStorybookApi } from \"@storybook/manager-api\";\nimport { Icons, IconButton, TooltipLinkList, WithTooltip } from \"@storybook/components\";\nimport { ADDON_ID, PARAM_KEY, TOOL_ID } from \"./constants\";\n\nexport const Tool = memo(function MyAddonSelector() {\n const [isTooltipVisible, setIsTooltipVisible] = useState(false);\n const [globals, updateGlobals] = useGlobals();\n const api = useStorybookApi();\n\n const isActive = !!globals[PARAM_KEY];\n\n return (\n <WithTooltip\n placement=\"top\"\n closeOnOutsideClick\n tooltip={({ onHide }) => {\n return (\n <TooltipLinkList\n links={[\n '(clear)',\n 'l-light',\n 'l-coffee',\n 'l-apricot',\n 'l-rainy',\n 'l-botanical',\n 'l-vivid',\n 'l-cherry',\n 'l-sushi',\n 'l-u0',\n 'd-dark',\n 'd-persimmon',\n 'd-astro',\n 'd-future',\n 'd-botanical',\n 'd-green-lime',\n 'd-green-orange',\n 'd-cherry',\n 'd-ice',\n 'd-u0',\n ].map((theme, i) => ({\n id: theme,\n title: theme,\n onClick() {\n updateGlobals({\n [PARAM_KEY]: i ? theme : false,\n });\n onHide();\n },\n value: theme,\n active: theme === globals[PARAM_KEY],\n }))}\n />\n );\n }}\n onVisibleChange={setIsTooltipVisible}\n >\n <IconButton\n key={TOOL_ID}\n active={isActive || isTooltipVisible}\n title=\"Switch theme\"\n >\n <Icons icon=\"mirror\" />\n </IconButton>\n </WithTooltip>\n );\n});"]} |