Skip to content

Commit

Permalink
Implemented toolbar action to allow users to toggle dark mode for com…
Browse files Browse the repository at this point in the history
…ponents
  • Loading branch information
wrigh393 committed Mar 29, 2021
1 parent ffff828 commit 2752898
Showing 1 changed file with 26 additions and 11 deletions.
37 changes: 26 additions & 11 deletions .storybook/preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,42 @@ import ItemProvider from '../src/components/ItemProvider';
import { ThemeProvider } from "@material-ui/core/styles";
import webqueueTheme from "../src/theme";

const theme = webqueueTheme(false);



export const globalTypes = {
theme: {
name: 'Theme',
name: 'Set Dark Mode',
description: 'Global theme for components',
defaultValue: 'false',
defaultValue: false,
toolbar: {
icon: 'mirror',
// array of plain string values or MenuItem shape (see below)
items: ["light", "dark"],
items: [
{value:true, title: "Dark Mode active",},
{value:false, title: "Dark Mode off",}
],
},
},
};


const withThemeProvider = (Story, context) => {

const theme = webqueueTheme(context.globals.theme);
return (
<ThemeProvider theme={theme} >
<Story {...context} />
</ThemeProvider>
)
}

export const decorators = [
(Story) => (
<ItemProvider>
<Story />
</ItemProvider>
),
(Story, context) => (
<ThemeProvider theme={theme}>
<Story {...context} />
</ThemeProvider>
),
withThemeProvider
];

export const parameters = {
Expand All @@ -38,6 +48,11 @@ export const parameters = {
method: 'alphabetical',
order: ['Introduction', 'Components']
},

},
backgrounds: {
values: [
{ name: 'red', value: '#f00' },
{ name: 'green', value: '#0f0' },
],
},
}

0 comments on commit 2752898

Please sign in to comment.