Socket
Socket
Sign inDemoInstall

storybook-addon-cookie

Package Overview
Dependencies
124
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    storybook-addon-cookie

Storybook addon for setting document.cookie


Version published
Weekly downloads
37K
increased by12.99%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

demo

Features

  • Set document.cookie for each Storybook.

Live demo

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

Add package to storybook configuration.

// .storybook/main.js
module.exports = {
  addons: [
    // ..other addons
    "storybook-addon-cookie",
  ]
}

If you want to use it only in a specific story, you can provide cookieDecorator to story.

But you can't control cookie by the panel.

// Component.stories.jsx
import React from 'react';
import Component from './Component';

import { cookieDecorator } from 'storybook-addon-cookie';

export default {
  title: 'Component',
  compoent: Component,
  decorators: [cookieDecorator],
};

Usage

You can pass cookie object into cookie parameter.

Or control cookie by addon panel.

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.

Keywords

FAQs

Last updated on 26 Mar 2023

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc