All Projects → Checkfront → React Storybook Addon Chapters

Checkfront / React Storybook Addon Chapters

Licence: mit
📒 Showcase multiple React components within a story

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to React Storybook Addon Chapters

Cuke Ui
🥒 黄瓜ui:一个即插即用的React UI 库
Stars: ✭ 402 (+169.8%)
Mutual labels:  components, storybook
Componentdriven.org
Static site and content for Component Driven
Stars: ✭ 237 (+59.06%)
Mutual labels:  components, storybook
Qui
A Vue.js design-system for Web.
Stars: ✭ 165 (+10.74%)
Mutual labels:  components, storybook
storybook-talk
Storybook, the playground you need for your UI components! 🎨
Stars: ✭ 11 (-92.62%)
Mutual labels:  components, storybook
elements
Lovingly crafted ui components based on web components. Works well with all Frameworks - including Angular, React and Vue.
Stars: ✭ 42 (-71.81%)
Mutual labels:  components, storybook
components
Reusable React components used by HospitalRun
Stars: ✭ 109 (-26.85%)
Mutual labels:  components, storybook
Storybook
📓 The UI component explorer. Develop, document, & test React, Vue, Angular, Web Components, Ember, Svelte & more!
Stars: ✭ 67,445 (+45165.1%)
Mutual labels:  components, storybook
Story2sketch
Convert Storybook into Sketch symbols 💎
Stars: ✭ 391 (+162.42%)
Mutual labels:  components, storybook
Wp Storybook
📔 Storybook for WordPress Reusable React Components
Stars: ✭ 95 (-36.24%)
Mutual labels:  components, storybook
Ebayui Core
Collection of Marko widgets; considered to be the core building blocks for all eBay components, pages & apps
Stars: ✭ 134 (-10.07%)
Mutual labels:  components
React Impression
快速构建企业级应用
Stars: ✭ 140 (-6.04%)
Mutual labels:  components
Chat Ui Kit React
Build your own chat UI with React components in few minutes. Chat UI Kit from chatscope is an open source UI toolkit for developing web chat applications.
Stars: ✭ 131 (-12.08%)
Mutual labels:  components
Android Components
A collection of Android libraries to build browsers or browser-like applications.
Stars: ✭ 1,849 (+1140.94%)
Mutual labels:  components
Vueport
Single file components for Rails with Vue JS and Webpack
Stars: ✭ 141 (-5.37%)
Mutual labels:  components
Rmdi
React Material Design Icons – built with Pixo, Styled Components, and Styled System
Stars: ✭ 132 (-11.41%)
Mutual labels:  components
Hanzi chaizi
汉字拆字库,可以将汉字拆解成偏旁部首,在机器学习中作为汉字的字形特征
Stars: ✭ 146 (-2.01%)
Mutual labels:  components
React Storybook Addon Props Combinations
Given possible values for each prop, renders your component with all combinations of prop values.
Stars: ✭ 130 (-12.75%)
Mutual labels:  storybook
React Responsive Carousel
React.js Responsive Carousel (with Swipe)
Stars: ✭ 1,962 (+1216.78%)
Mutual labels:  storybook
Vue Storybook
Custom <story> blocks for Vue single file components
Stars: ✭ 147 (-1.34%)
Mutual labels:  storybook
Blazorise
Blazorise is a component library built on top of Blazor with support for CSS frameworks like Bootstrap, Bulma, AntDesign, and Material.
Stars: ✭ 2,103 (+1311.41%)
Mutual labels:  components

React Storybook Chapters Addon

React Storybook Chapters addon allows showcasing of multiple components within a story by breaking it down into smaller categories (chapters) and subcategories (sections) for more organizational goodness.

Using the addon, a story can consist of multiple chapters and a chapter consists of multiple sections. Each section can render a block of code, which typically used to showcase one component or a particular state of a component.

Chapters can be used to group related components together, or show varying states of a component. Each chapter comes with a Chapter Title, Chapter Subtitle, Chapter Info and a list of Sections. Simply omit any of them to hide them from rendering.

Each section comes with a Section Title, Section Subtitle, Section Info.

This addon was modified from react-storybook-addon-info and uses some of the component code from there.

React Storybook Screenshot

Usage

Install the following npm module:

npm install --save-dev react-storybook-addon-chapters

Then set the addon in the place you configure storybook like this:

import React from 'react';
import { configure, setAddon } from '@storybook/react';
import chaptersAddon from 'react-storybook-addon-chapters';

setAddon(chaptersAddon);

configure(function () {
  ...
}, module);

To turn off the default styles add:

setDefaults({sectionOptions: {useTheme: false}});

All rendered components have a specified class. With the 'useTheme' set to false you should have no problem styling your chapters.

Then create your stories with the .addWithChapters API.

import React from 'react';
import Button from './Button';
import { storiesOf } from '@storybook/react';

storiesOf('Addon Chapters')
  .addWithChapters(
    'Story With Chapters',
    {
      subtitle: <Optional story subtitle>,
      info: <Optional story info>,
      chapters: [
        // List of chapters. Refer to Configuration Format section.
        {
          title: <Optional chapter title>,
          subtitle: <Optional chapter subtitle>,
          info: <Optional chapter info>,
          sections: [
            // List of sections.
            {
              title: <Optional section title>,
              subtitle: <Optional section subtitle>,
              info: <Optional section info>,
              sectionFn: () => (<Button label="My Button" onClick={() => { alert('Hello World!'); }}/>),
              options: {
                showSource: true,
                allowSourceToggling: true,
                showPropTables: true,
                allowPropTablesToggling: true,
              },
            },
            ...
          ],
        },
        ...
      ]
    }
  );

Have a look at this example stories to learn more about the addWithChapters API.

Global options

To configure default options for all chapter sections (section.options), use setDefaults in .storybook/config.js .

import React from 'react';
import { configure, setAddon } from '@storybook/react';
import chaptersAddon, { setDefaults } from 'react-storybook-addon-chapters';

// optionally override defaults
setDefaults({
  sectionOptions: {
    showSource: true,
    allowSourceToggling: true,
    showPropTables: false,
    allowPropTablesToggling: true,
    decorator: story => (<div>{story()}</div>),
  }
});
setAddon(chaptersAddon);

configure(function () {
  ...
}, module);

Configuration Format

Story

Key Description Type Default
subtitle Story subtitle String -
info Additional information for the story String (markdown) -
chapters An array of Chapter objects Array -

Chapter

Key Description Type Default
title Chapter title String -
subtitle Chapter subtitle String -
info Additional information for the chapter String (markdown) -
sections An array of Section objects Array -

Section

Key Description Type Default
title Section title String -
subtitle Section subtitle String -
info Additional information for the section String (markdown) -
sectionFn A function that returns a React component to be displayed Function -
options A configuration object for this section. Refer to the next few rows for the keys Object -
options.showSource Display the component's source Boolean True
options.allowSourceToggling Allow showing/hiding of the component's source Boolean True
options.showPropTables Display the component's propTypes Boolean False
options.allowPropTablesToggling Allow showing/hiding of the component's propTypes Boolean True
options.decorator An optional decorator function that will be used for rendering the component in section Function -

The FAQ

Components lose their names on static build

Component names also get minified with other javascript code when building for production. When creating components, set the displayName static property to show the correct component name on static builds.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].