diff --git a/.storybook/preview.js b/.storybook/preview.js
index 22925150..950f7adb 100644
--- a/.storybook/preview.js
+++ b/.storybook/preview.js
@@ -1,7 +1,8 @@
-import { withDesign } from "storybook-addon-designs";
+import { withDesign } from 'storybook-addon-designs'
+import { withThemeProvider, AVAILABLE_THEMES } from '../src/helpers/ThemeProvider'
export const parameters = {
- actions: { argTypesRegex: "^on[A-Z].*" },
+ actions: { argTypesRegex: '^on[A-Z].*' },
controls: {
matchers: {
color: /(background|color)$/i,
@@ -10,6 +11,20 @@ export const parameters = {
},
}
-export const decorators = [
- withDesign
-];
+const themeKeys = Object.keys(AVAILABLE_THEMES)
+
+export const globalTypes = {
+ theme: {
+ name: 'Theme',
+ description: 'Switch theme for preview',
+ defaultValue: themeKeys[0],
+ toolbar: {
+ items: themeKeys.map((key) => {
+ return { value: key, title: AVAILABLE_THEMES[key] }
+ }),
+ showName: true,
+ },
+ },
+}
+
+export const decorators = [withDesign, withThemeProvider]
diff --git a/src/helpers/ThemeProvider.tsx b/src/helpers/ThemeProvider.tsx
new file mode 100644
index 00000000..bb618d36
--- /dev/null
+++ b/src/helpers/ThemeProvider.tsx
@@ -0,0 +1,40 @@
+import React, { ReactNode } from 'react'
+import { Tokens } from '../../tokens'
+
+export const AVAILABLE_THEMES = {
+ org: 'betterplace.org',
+ at: 'betterplace.at',
+ me: 'betterplace.me',
+}
+
+type Theme = keyof typeof AVAILABLE_THEMES
+
+type ThemeProviderProps = {
+ theme: Theme
+ children: ReactNode
+}
+
+export const ThemeProvider = (props: ThemeProviderProps) => {
+ const tokens = {
+ globals: Tokens.globals,
+ [props.theme]: Tokens[props.theme],
+ }
+
+ console.log(tokens)
+
+ const ThemeContext = React.createContext(props.theme)
+
+ return (
+
+ {props.children}
+
+ )
+}
+
+export const withThemeProvider = (Story: any, context: { globals: { theme: Theme } }) => {
+ return (
+
+
+
+ )
+}
diff --git a/tokens/globals.json b/tokens/globals.json
new file mode 100644
index 00000000..0504a39d
--- /dev/null
+++ b/tokens/globals.json
@@ -0,0 +1,7 @@
+{
+ "colors": {
+ "colorRed100": "#ff0000",
+ "colorGreen100": "#00ff00",
+ "colorGreen300": "#00aa00"
+ }
+}
diff --git a/tokens/index.ts b/tokens/index.ts
new file mode 100644
index 00000000..e4a3eb2b
--- /dev/null
+++ b/tokens/index.ts
@@ -0,0 +1,11 @@
+import globals from './globals.json'
+import org from './theme-org.json'
+import at from './theme-at.json'
+import me from './theme-me.json'
+
+export const Tokens = {
+ globals,
+ org,
+ at,
+ me,
+}
diff --git a/tokens/theme-at.json b/tokens/theme-at.json
new file mode 100644
index 00000000..ca1e7f29
--- /dev/null
+++ b/tokens/theme-at.json
@@ -0,0 +1,5 @@
+{
+ "colors": {
+ "colorPrimary": "colorGreen300"
+ }
+}
diff --git a/tokens/theme-me.json b/tokens/theme-me.json
new file mode 100644
index 00000000..383b0355
--- /dev/null
+++ b/tokens/theme-me.json
@@ -0,0 +1,5 @@
+{
+ "colors": {
+ "colorPrimary": "colorRed100"
+ }
+}
diff --git a/tokens/theme-org.json b/tokens/theme-org.json
new file mode 100644
index 00000000..f5a851d3
--- /dev/null
+++ b/tokens/theme-org.json
@@ -0,0 +1,5 @@
+{
+ "colors": {
+ "colorPrimary": "colorGreen100"
+ }
+}