17k
Downloads per week
Features
- Set
document.cookiefor each Storybook.
Installing and Setup
Install addon
With npm:
npm i storybook-addon-cookie -D
Or with yarn:
yarn add storybook-addon-cookie -D
Configure the addon
Provide cookieDecorator to Storybook by editing ./storybook/preview.js.
import { cookieDecorator } from 'storybook-addon-cookie';
export const decorators = [cookieDecorator];
Usage
You can pass cookie object into cookie parameter.
export default {
component: Example,
title: 'Example',
}
const Template = () => <Example/>
export const WithCookie = Template.bind({});
WithCookie.parameters = {
cookie: {
test: 'TEST!',
}
}
export const WithOutCookie = Template.bind({});
Each Story has independent cookie.