0.0.68 • Published 1 year ago

@storybook-extras/variants v0.0.68

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

Getting started

  1. Install the addon:
yarn add @storybook-extras/variants -D
  1. Add the addon
// .storybook/main.ts
import { StorybookConfig } from '@storybook/angular';
import { ExtrasConfig } from '@storybook-extras/preset';

const config: StorybookConfig & ExtrasConfig = {
    ...
    "addons": [
        "@storybook-extras/variants",
        // it will be included automatically if you are using
        // "@storybook-extras/preset",
        ...
    ],
    ...
}

export default config;

How to use

  • Simply enable the variants through the toolbar or using the parameters like so:
// .storybook/preview.ts 
// button.stories.ts
parameters: {
    variants: {
        enable: true
    },
};

Parameters

NameTypeDefaultDescription
enablebooleanfalseEnable the variants addon
includestring[][]Include variants from the list
excludestring[][]Exclude variants from the list
groupBystring[][]Group the variants by these keys
autoCalculatebooleanfalseAutomatically 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.

// .storybook/preview.ts
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.

0.0.68

1 year ago

0.0.40

1 year ago

0.0.46

1 year ago

0.0.37

1 year ago

0.0.38

1 year ago

0.0.39

1 year ago

0.0.32

1 year ago

0.0.33

1 year ago

0.0.34

1 year ago

0.0.36

1 year ago

0.0.62

1 year ago

0.0.63

1 year ago

0.0.64

1 year ago

0.0.65

1 year ago

0.0.66

1 year ago

0.0.67

1 year ago

0.0.60

1 year ago

0.0.61

1 year ago

0.0.59

1 year ago

0.0.51

1 year ago

0.0.52

1 year ago

0.0.53

1 year ago

0.0.54

1 year ago

0.0.55

1 year ago

0.0.56

1 year ago

0.0.57

1 year ago

0.0.58

1 year ago

0.0.50

1 year ago

0.0.48

1 year ago

0.0.31

1 year ago

0.0.30

1 year ago

0.0.28

1 year ago

0.0.27

1 year ago

0.0.24

1 year ago

0.0.23

1 year ago

0.0.22

1 year ago

0.0.21

1 year ago

0.0.18

1 year ago

0.0.17

1 year ago

0.0.16

1 year ago

0.0.15

1 year ago

0.0.14

1 year ago

0.0.13

1 year ago

0.0.12

1 year ago

0.0.11

1 year ago

0.0.1

1 year ago