diff --git a/.storybook/preview.ts b/.storybook/preview.ts index dbad0b72..eb7fd155 100644 --- a/.storybook/preview.ts +++ b/.storybook/preview.ts @@ -29,3 +29,31 @@ export const parameters = { }, }, }; + +export const globalTypes = { + version: { + name: 'version', + description: 'Select version Stable/Beta', + toolbar: { + icon: 'branch', + items: [ + { value: 'stable', icon: 'branch', title: 'Stable Version' }, + { value: 'beta', icon: 'branch', title: 'Beta Version' }, + ], + dynamicTitle: true, + }, + }, +} + + +export const decorators = [ + (storyFn, context) => { + if (context.globals.version === 'stable' && window.parent.location.hostname.includes('next')) { + window.parent.location.assign('https://baklava.design' + window.parent.location.search); + } + if (context.globals.version === 'beta' && !window.parent.location.hostname.includes('next')) { + window.parent.location.assign('https://next.baklava.design' + window.parent.location.search); + } + return storyFn(); + } +]; diff --git a/README.md b/README.md index 385fb176..adf6f1ed 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@

Baklava Design System

-

+

NPM Package Stable diff --git a/docs/welcome.stories.mdx b/docs/welcome.stories.mdx index 16609a78..e91ca1c3 100644 --- a/docs/welcome.stories.mdx +++ b/docs/welcome.stories.mdx @@ -3,4 +3,9 @@ import ReadMe from '../README.md?raw'; -{ReadMe} +{ReadMe.slice(0,ReadMe.search("Baklava is a design system"))} +

+ {window.parent.location.hostname.includes('next') && Stable Version} + {!window.parent.location.hostname.includes('next') && Beta Version} +
+{ReadMe.slice(ReadMe.search("Baklava is a design system"))}