Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

css-chaos-addon

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

css-chaos-addon

An addon that applies inheritable css properties around a component to better test random use cases

  • 0.0.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
16
increased by700%
Maintainers
1
Weekly downloads
 
Created
Source

Storybook CSS Chaos Addon

An addon that applies inheritable css properties around a component to better test in-context scenarios that alter the look and feel of a component. By testing in this way, you can limit style bleeding when the component is added in an application.

Before

After

Usage scripts

Run npm install css-chaos-addon

In your main.js file, add to the addons array:

addons: ["css-chaos-addon"]

Supported CSS Properties

The inheritied properties that are set by this addon include:

  • border-collapse
  • border-spacing
  • caption-side
  • color
  • cursor
  • direction
  • empty-cells
  • font-family
  • font-size
  • font-style
  • font-variant
  • font-weight
  • letter-spacing
  • line-height
  • list-style-position
  • list-style-type
  • text-align
  • text-indent
  • text-transform
  • white-space
  • word-spacing

For more information about these properties, see the properties file here.

Some of the properties have arbitrary values that might be set by a consuming application (ex. color). If you would like to override these values with a set of your own, see the section on customizing the CSS properties.

Customizing CSS Properties

To customize, you will need to leverage Storybook's parameters feature that can be set globally or at the story level. The parameter used for the CSS Chaos Addon is called cssPropertyData.

The CSS Property keys include:

  • name: The name of the css property that will be set above addon dropdown and will be used to set the css propery value in the global css.
  • description: The description of the css property that will be shown in the addon panel underneath the name and above the dorpdown option.
  • default: The default value for the dropdown. This value will be applied automatically in the global css when the addon panel is active.
  • values: The list of options that the user has to choose from to manipualte the view. The randomize functionality will also use this list to pick a random value.

If you want to add a css property:

 parameters: {
    cssPropertyData: [
      {
        "name": "hello world",
        "description": "Lorem ipsum",
        "default": "world",
        "values": [
          "hello",
          "world"
        ]
      },
    ]
    ,
  }

If you want to alter a css property, update one or all keys in the object (name, description, default, values):

 parameters: {
    cssPropertyData: [
      {
        "name": "updated-name",
        "description": "An updated description goes here",
        "default": "new default",
        "values": [
          "this",
          "includes",
          "updated",
          "values",
          "new default"
        ]
      },
    ]
    ,
  }

To remove an existing css property dropdown from the addon panel, remove all of the values from the object:

 parameters: {
    cssPropertyData: [
      {
        "name": "color",
        "values": []
      },
    ]
    ,
  }

Development scripts

  • npm start runs babel in watch mode and starts Storybook
  • npm run build build and package your addon code

Keywords

FAQs

Package last updated on 07 Jul 2022

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc