aboutsummaryrefslogtreecommitdiffstats
path: root/packages/forms/.storybook/theme/index.js
diff options
context:
space:
mode:
Diffstat (limited to 'packages/forms/.storybook/theme/index.js')
-rw-r--r--packages/forms/.storybook/theme/index.js58
1 files changed, 58 insertions, 0 deletions
diff --git a/packages/forms/.storybook/theme/index.js b/packages/forms/.storybook/theme/index.js
new file mode 100644
index 000000000..f016f21eb
--- /dev/null
+++ b/packages/forms/.storybook/theme/index.js
@@ -0,0 +1,58 @@
1import React from 'react';
2import injectSheet, { ThemeProvider } from 'react-jss';
3import addons, { makeDecorator } from '@storybook/addons';
4import theme from '@meetfranz/theme';
5
6const defaultTheme = {
7 name: 'Default',
8 variables: theme('default'),
9};
10
11const darkTheme = {
12 name: 'Dark Mode',
13 variables: theme('dark'),
14};
15
16const themes = [defaultTheme, darkTheme];
17
18const styles = (theme) => ({
19 title: {
20 fontSize: 14,
21 },
22 container: {
23 border: theme.inputBorder,
24 borderRadius: theme.borderRadiusSmall,
25 marginBottom: 20,
26 padding: 20,
27 background: theme.colorContentBackground,
28 },
29});
30
31const Container = injectSheet(styles)(({ name, classes, story }) => (
32 <article>
33 <h1 className={classes.title}>{name}</h1>
34 <div className={classes.container}>
35 {story}
36 </div>
37 </article>
38));
39
40export default makeDecorator({
41 name: 'withTheme',
42 parameterName: 'theme',
43 // This means don't run this decorator if the notes decorator is not set
44 // skipIfNoParametersOrOptions: true,
45 wrapper: (getStory, context, { options }) => {
46 const channel = addons.getChannel();
47
48 return (
49 <>
50 {themes.map(theme => (
51 <ThemeProvider theme={theme.variables}>
52 <Container story={getStory(context)} name={theme.name} />
53 </ThemeProvider>
54 ))}
55 </>
56 );
57 }
58})