diff --git a/.storybook/manager.cjs b/.storybook/manager.cjs index e5489b5f..9b010c93 100644 --- a/.storybook/manager.cjs +++ b/.storybook/manager.cjs @@ -1,4 +1,5 @@ import { addons } from '@storybook/addons'; +import { STORY_RENDERED } from '@storybook/core-events' import { create } from '@storybook/theming'; const theme = create({ @@ -11,3 +12,32 @@ const theme = create({ addons.setConfig({ theme }); + +addons.register('TitleAddon', api => { + const customTitle = 'Reactstrap'; + let interval = null; + const setTitle = () => { + clearTimeout(interval); + + let storyData = null; + try { + storyData = api.getCurrentStoryData(); + } catch(e) {} + + let title; + if (!storyData) { + title = customTitle; + } else { + title = `${storyData.kind} - ${storyData.name} ⋅ ${customTitle}` + } + + if (document.title !== title) { + document.title = title; + } + interval = setTimeout(setTitle, 100); + }; + setTitle(); + api.on(STORY_RENDERED, story => { + setTitle(); + }) +})