diff --git a/examples/angular-cli/.storybook/main.js b/examples/angular-cli/.storybook/main.js index 1f934f0b01bc..5345ec67fd0f 100644 --- a/examples/angular-cli/.storybook/main.js +++ b/examples/angular-cli/.storybook/main.js @@ -11,5 +11,6 @@ module.exports = { '@storybook/addon-jest', '@storybook/addon-backgrounds', '@storybook/addon-a11y', + '@storybook/addon-toolbars', ], }; diff --git a/examples/angular-cli/.storybook/preview.ts b/examples/angular-cli/.storybook/preview.ts index ea3ecd41c449..366164a97c8a 100644 --- a/examples/angular-cli/.storybook/preview.ts +++ b/examples/angular-cli/.storybook/preview.ts @@ -23,3 +23,18 @@ addParameters({ prepareForInline, }, }); + +export const globalTypes = { + theme: { + name: 'Theme', + description: 'Global theme for components', + defaultValue: 'light', + toolbar: { + icon: 'paintbrush', + items: [ + { value: 'light', title: 'Light theme' }, + { value: 'dark', title: 'Dark theme' }, + ], + }, + }, +}; diff --git a/examples/angular-cli/src/stories/__snapshots__/core.stories.storyshot b/examples/angular-cli/src/stories/__snapshots__/core.stories.storyshot index c389b6841161..3f7adc08164c 100644 --- a/examples/angular-cli/src/stories/__snapshots__/core.stories.storyshot +++ b/examples/angular-cli/src/stories/__snapshots__/core.stories.storyshot @@ -15,6 +15,26 @@ exports[`Storyshots Core/Parameters passed to story 1`] = ` "docs": { "inlineStories": true }, + "globalTypes": { + "theme": { + "name": "Theme", + "description": "Global theme for components", + "defaultValue": "light", + "toolbar": { + "icon": "paintbrush", + "items": [ + { + "value": "light", + "title": "Light theme" + }, + { + "value": "dark", + "title": "Dark theme" + } + ] + } + } + }, "globalParameter": "globalParameter", "framework": "angular", "chapterParameter": "chapterParameter", diff --git a/examples/angular-cli/src/stories/theme-decorator/__snapshots__/decorators.stories.storyshot b/examples/angular-cli/src/stories/theme-decorator/__snapshots__/decorators.stories.storyshot new file mode 100644 index 000000000000..31dc967f0565 --- /dev/null +++ b/examples/angular-cli/src/stories/theme-decorator/__snapshots__/decorators.stories.storyshot @@ -0,0 +1,11 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Storyshots Core / Theme Decorators Base 1`] = ` + +
+ Change theme with the brush in toolbar +
+
+`; diff --git a/examples/angular-cli/src/stories/theme-decorator/decorators.stories.ts b/examples/angular-cli/src/stories/theme-decorator/decorators.stories.ts new file mode 100644 index 000000000000..5a961b27490d --- /dev/null +++ b/examples/angular-cli/src/stories/theme-decorator/decorators.stories.ts @@ -0,0 +1,18 @@ +import { componentWrapperDecorator, Meta } from '@storybook/angular'; + +export default { + title: 'Core / Theme Decorators', + decorators: [ + componentWrapperDecorator( + (story) => `
${story}
`, + ({ globals }) => ({ myTheme: `${globals.theme}-theme` }) + ), + ], +} as Meta; + +export const Base = (args) => ({ + template: 'Change theme with the brush in toolbar', + props: { + ...args, + }, +}); diff --git a/examples/angular-cli/src/styles.scss b/examples/angular-cli/src/styles.scss index b71e7cceb9be..2bcb866267c9 100644 --- a/examples/angular-cli/src/styles.scss +++ b/examples/angular-cli/src/styles.scss @@ -6,3 +6,12 @@ .green-color { color: $color; } + +.light-theme { + background-color: white; +} + +.dark-theme { + background-color: rgb(75, 75, 75); + color: white; +}