Table of Contents
Getting started
yarn add @storybook-extras/variants -D
import { StorybookConfig } from '@storybook/angular';
import { ExtrasConfig } from '@storybook-extras/preset';
const config: StorybookConfig & ExtrasConfig = {
...
"addons": [
"@storybook-extras/variants",
...
],
...
}
export default config;
How to use
- Simply enable the variants through the toolbar or using the parameters like so:
parameters: {
variants: {
enable: true
},
};
Parameters
enable | boolean | false | Enable the variants addon |
include | string[] | [] | Include variants from the list |
exclude | string[] | [] | Exclude variants from the list |
groupBy | string[] | [] | Group the variants by these keys |
autoCalculate | boolean | false | Automatically calculate the variants |
NOTES
- If you set
autoCalculate to false, you can use the include parameters to include the variants.
- If you set
autoCalculate to true, you can use the exclude parameters to filter the variants.
- Toolbar button will not show if
autoCalculate is set to true or include is not empty.
Compatibility
This addon was initially developed for Angular 15 & Storybook v7 in mind. However, you can still use it in older versions, but you will need to use the decorator directly in preview.js instead of adding the addon in your main.js.
import { withVariants } from '@storybook-extras/variants';
export const decorators = [withVariants()];
This approach will also work for React, Vue, and other frameworks. Please open an issue if you find any compatibility issues, pull requests are always welcome.
v0.0.68 - 2023-03-01
deps
| Commit | Type | Description |
| --- | --- | --- |
| d9a2e9b | chore | upgrade storybook to v7.0.0-beta.58 |
| fef8f9f | chore | bump @angular/forms from 15.1.2 to 15.1.5 |
| a7e7476 | chore | bump @angular/compiler from 15.1.2 to 15.1.5 |
deps-dev
| Commit | Type | Description |
| --- | --- | --- |
| 0d66973 | chore | bump storybook from 7.0.0-beta.45 to 7.0.0-beta.51 |
| 46c43ad | chore | bump @storybook/addon-essentials |
| e643904 | chore | bump @storybook/core-events |
release
| Commit | Type | Description |
| --- | --- | --- |
| bfab0ac | chore | Update CHANGELOG.md [skip ci] |
angular
| Commit | Type | Description |
| --- | --- | --- |
| deb0376 | feat | enable upgrade insecure requests |
| ba6406e | feat | add upgradeInsecureRequests |
preset
| Commit | Type | Description |
| --- | --- | --- |
| b8512b6 | docs | update chromatic demo url [skip ci] |
others
| Commit | Type | Description |
| --- | --- | --- |
| e478a05 | N/A | Bump version to: v0.0.68 [skip ci] |