Skip to content

Commit

Permalink
Refactor decorators for consistentcy
Browse files Browse the repository at this point in the history
  • Loading branch information
campb303 committed Apr 9, 2021
1 parent 9366880 commit 037ae75
Showing 1 changed file with 14 additions and 15 deletions.
29 changes: 14 additions & 15 deletions storybook/preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,28 +28,27 @@ export const globalTypes = {
},
};

/**Defines global theme ALL stories stories.
* * @type {Object | Function}
*/
const withThemeProvider = (Story, context) => {
const theme = webqueueTheme(context.globals.theme);
return (
<ThemeProvider theme={theme} >
<Story {...context} />
</ThemeProvider>
)
}
/**
* Wraps all sotrys in the defined decorators.
* @type {Array[]}
*/
* Array
* @type {Array}
* @see https://storybook.js.org/docs/react/writing-stories/decorators
*/
export const decorators = [
// Provide custom webqueue2 Theme
(Story, context) => {
const theme = webqueueTheme(context.globals.theme);
return (
<ThemeProvider theme={theme} >
<Story {...context.args} />
</ThemeProvider>
);
},
// Provide Item context
(Story) => (
<ItemProvider>
<Story />
</ItemProvider>
),
withThemeProvider
];

/**Set of static metadata for a story. Is also used to define the sort order of the stories and backgrounds for every story.
Expand Down

0 comments on commit 037ae75

Please sign in to comment.