3.15.0 • Published 3 years ago

@component-controls/storybook v3.15.0

Weekly downloads
473
License
MIT
Repository
github
Last release
3 years ago

Table of contents

Shocase sites

Overview

Storybook plugin for documenting your projects with component controls

  • Full replacement for the storybook addon-docs
  • Works with storybook-5 and storybook-6

Limitations

  • Initial version is only for react apps. More frameworks are on the roadmap.
  • Only handles the ESM(CSF) and MDX stories format. The storiesOf API is not supported and there are currently no plans to support it.

Getting started with storybook

Storybook addon panels

The component-controls block components have been designed from the ground up to be able to be placed either on documentation pages or in addon tabs.

You can turn on and off the available panels:

  {
    name: '@component-controls/storybook',
    options: {
      controlsPanel: true,
      propsPanel: true,
      storySourcePanel: true,
    }
  }  

Custom documentation pages

component-controls installs a default Page with some standard documentation boocks, however you can replace the deafult page and add new pages.

Here is an example that will completely hide the storybook Canvas tab and replace it with our custom documentation page

Hide storybookjs Canvas

.storybook/manager.js

import { addons } from '@storybook/addons';
addons.setConfig({
  previewTabs: {
    canvas: {
      //hide storybooks Canvas tab
      hidden: true,
    },
    'CUSTOM_PAGE_ADDON/canvas': {
      //place our custom Canvas page first in order of tabs
      index: 0,
    },

  },
});

Create custom Canvas page

.storybook/canvas-page.tsx

import React from 'react';
import { CanvasPage } from '@component-controls/pages';
import { DocsContainer } from '@component-controls/storybook';

export default {
  key: 'canvas',
  title: 'Canvas',
  render: ({ active }: { active: boolean }) => (
    <DocsContainer active={active}>
      <CanvasPage />
    </DocsContainer>
  ),
};

Configure '@component-controls/storybook' to load out custom page only

.storybook/main.tsx

module.exports = {
  addons: [
    '@storybook/addon-docs',
    {
      name: '@component-controls/storybook',
      options: {
        pages: [require.resolve('./canvas-page.tsx')],
      }
    },
  ],
};

List of components

ComponentSource

ComponentSource source code

properties

NameTypeDescription
onSelect((name: string, component: Component) => boolean | void) & ((event: SyntheticEvent<HTMLDivElement, Event>) => void)callback to be called when the tab changes if the function returns false, it can stop chabging to the new tab
ref((instance: HTMLDivElement) => void) | RefObject<HTMLDivElement>
titlestringoptional section title for the block. optional title to display for the code block. Usually used from MDX
sxThemeUIStyleObject
idstringoptional id to be used for the block if no id is provided, one will be calculated automatically from the title.
visibilityComponentVisibilityby default will show both controls and props tables user setting can display only props table or only controls
ofanySpecify the component(s), for which to have information displayed. The default, a value of `"."` will indicate to display information for the current component (associated with the current Story). If an array of components is specified, each component will be displayed in a separate tab.
namestringsome component-oriented ui components can also be driven by a story id (name). ie the PropsTable can display component props, or story controls
descriptionstringoptional markdown description.
collapsiblebooleanif false, will nothave a collapsible frame.
data-testidstringtesting id
plainbooleaninner container variant or plain if plain, skip the border and spacing around the children
actionsActionItem[]optional actions provided to the component
themePrismThemeoptional `PrismTheme` theme provided to the component. Themes can be imported from `prism-react-renderer/themes`.
languageLanguagesource lnguage used, by default "jsx".
renderFn(props: RenderProps, other: { theme: PrismTheme; }) => ReactNodecustom function to render the source code.
darkbooleanused to specify a "dark" color theme - applcable only if no custom theme prop is provided. if dark: true, duotoneDark theme is used. if dark: false, duotoneLight theme is used.
metastringstringcode configuration string passed from MDX

Description

Description source code

properties

NameTypeDescription
components{ [key: string]: ComponentOverride<any, any>; a?: ComponentOverride<any, any>; br?: ComponentOverride<any, any>; button?: ComponentOverride<any, any>; ... 27 more ...; ul?: ComponentOverride<...>; }components to customize the markdown display.
ofanySpecify the component(s), for which to have information displayed. The default, a value of `"."` will indicate to display information for the current component (associated with the current Story). If an array of components is specified, each component will be displayed in a separate tab.
namestringsome component-oriented ui components can also be driven by a story id (name). ie the PropsTable can display component props, or story controls

Meta

empty component for storybook addon-docs compatibility

Meta source code

Playground

Playground source code

properties

NameTypeDescription
scalenumberdefault scale for the zoom feature. If scale is set to 0, the zoom feature will be disabled.
sourcestringplayground source option - valid when a Story is not embedded inside the Playground.
darkbooleanwhether to use the dark theme for the story source component.
titlestringoptional section title for the block.
descriptionstringoptional markdown description.
idstringoptional id to be used for the block if no id is provided, one will be calculated automatically from the title.
collapsiblebooleanif false, will nothave a collapsible frame.
data-testidstringtesting id
plainbooleaninner container variant or plain if plain, skip the border and spacing around the children
sxThemeUIStyleObject
ref((instance: HTMLDivElement) => void) | RefObject<HTMLDivElement>
openTabReactNodeby default, which tab to have open.
visibleTabsbooleanif true, the tabs on the panels will be visible
backgroundBackgroundTypebackground pattern type
directionDirectionTypedirection type
actionsActionItem[]optional actions provided to the component

PropsTable

PropsTable source code

properties

NameTypeDescription
extraColumnsColumn<{}>[]extra custom columns passed to the PropsTable.
flatbooleanif true, will flatten the group by
onSelect((name: string, component: Component) => boolean | void) & ((event: SyntheticEvent<HTMLDivElement, Event>) => void)callback to be called when the tab changes if the function returns false, it can stop chabging to the new tab
ref((instance: HTMLDivElement) => void) | RefObject<HTMLDivElement>
titlestringoptional section title for the block.
sxThemeUIStyleObject
idstringoptional id to be used for the block if no id is provided, one will be calculated automatically from the title.
visibilityComponentVisibilityby default will show both controls and props tables user setting can display only props table or only controls
ofanySpecify the component(s), for which to have information displayed. The default, a value of `"."` will indicate to display information for the current component (associated with the current Story). If an array of components is specified, each component will be displayed in a separate tab.
namestringsome component-oriented ui components can also be driven by a story id (name). ie the PropsTable can display component props, or story controls
descriptionstringoptional markdown description.
collapsiblebooleanif false, will nothave a collapsible frame.
data-testidstringtesting id
plainbooleaninner container variant or plain

Stories

Stories source code

properties

NameTypeDescription
darkbooleanwhether to display the dark theme storysource code component whether to use the dark theme for the story source component.
idstringoptional id to be used for the block if no id is provided, one will be calculated automatically from the title.
namestring
storyPropsany
scalenumberdefault scale for the zoom feature. If scale is set to 0, the zoom feature will be disabled.
sourcestringplayground source option - valid when a Story is not embedded inside the Playground.
titlestringoptional section title for the block.
descriptionstringoptional markdown description.
collapsiblebooleanif false, will nothave a collapsible frame.
data-testidstringtesting id
plainbooleaninner container variant or plain if plain, skip the border and spacing around the children
sxThemeUIStyleObject
ref((instance: HTMLDivElement) => void) | RefObject<HTMLDivElement>
openTabReactNodeby default, which tab to have open.
visibleTabsbooleanif true, the tabs on the panels will be visible
backgroundBackgroundTypebackground pattern type
directionDirectionTypedirection type
actionsActionItem[]optional actions provided to the component

Story

Story source code

properties

NameTypeDescription
refRef<HTMLDivElement>ref can be used by blocks embedding Story - ie ally plugin
onRender() => voidused by other blocks ie ally plugin uses it launch a new ally test on re-render
wrapperStoryWrapperTypewrapper type - can be an iframe or just regular react
iframeStyleCSSPropertiesif an iframe wrapper - this is additional iframe style
idstringoptional id to be used for the block if no id is provided, one will be calculated automatically from the title.
namestring
titlestringoptional section title for the block.
descriptionstringoptional markdown description.
collapsiblebooleanif false, will nothave a collapsible frame.
data-testidstringtesting id
plainbooleaninner container variant or plain
sxThemeUIStyleObject

StoryConfig

StoryConfig source code

properties

NameTypeDescription
titlestringoptional section title for the block.
descriptionstringoptional markdown description.
idstringoptional id to be used for the block if no id is provided, one will be calculated automatically from the title.
collapsiblebooleanif false, will nothave a collapsible frame.
data-testidstringtesting id
plainbooleaninner container variant or plain
sxThemeUIStyleObject
ref((instance: HTMLDivElement) => void) | RefObject<HTMLDivElement>
sourcePropsSourceProps
namestring

StorySource

StorySource source code

properties

NameTypeDescription
viewStyleViewStyleinitial view mode
sourcePropsSourcePropssource code options
titlestringoptional section title for the block.
descriptionstringoptional markdown description.
idstringoptional id to be used for the block if no id is provided, one will be calculated automatically from the title.
collapsiblebooleanif false, will nothave a collapsible frame.
data-testidstringtesting id
plainbooleaninner container variant or plain
sxThemeUIStyleObject
ref((instance: HTMLDivElement) => void) | RefObject<HTMLDivElement>
namestring

Subtitle

Subtitle source code

properties

NameTypeDescription
idstring
namestring
childrenstring | (string & {}) | (string & ReactElement<any, string | ((props: any) => ReactElement<any, any>) | (new (props: any) => Component<any, any, any>)>) | (string & ReactNodeArray) | (string & ReactPortal)text to be displayed in the component.
as"h2" | "h1" | "h3" | "h4" | "h5"DOM node type to render as. By default h3.
ref((instance: HTMLHeadingElement) => void) | RefObject<HTMLHeadingElement>
sxThemeUIStyleObject

Title

Title source code

properties

NameTypeDescription
contributorsboolean
idstring
namestring
sxThemeUIStyleObject
ref((instance: HTMLDivElement) => void) | RefObject<HTMLDivElement>

BlockContextProvider

BlockContextProvider source code

properties

NameTypeDescription
idstring

ControlsProvider

ControlsProvider source code

ThemeProvider

ThemeProvider source code

PageContextContainer

PageContextContainer source code

DocsContainer

DocsContainer source code

properties

NameTypeDescription
activeboolean

AddonPanel

AddonPanel source code

properties

NameTypeDescription
activeboolean
api*API

PropsTablePanel

PropsTablePanel source code

properties

NameTypeDescription
activeboolean
api*API

StoryConfigPanel

StoryConfigPanel source code

properties

NameTypeDescription
activeboolean
api*API

StorySourcePanel

StorySourcePanel source code

properties

NameTypeDescription
activeboolean
api*API
3.15.0

3 years ago

3.13.1

3 years ago

3.12.0

3 years ago

3.14.1

3 years ago

3.14.0

3 years ago

3.14.3

3 years ago

3.14.2

3 years ago

3.14.5

3 years ago

3.14.4

3 years ago

3.14.6

3 years ago

3.13.0

3 years ago

3.11.4

3 years ago

3.11.3

3 years ago

3.9.1

3 years ago

3.9.0

3 years ago

3.10.1

3 years ago

3.8.0

3 years ago

3.10.0

3 years ago

3.10.3

3 years ago

3.10.2

3 years ago

3.8.3

3 years ago

3.8.2

3 years ago

3.8.1

3 years ago

3.11.0

3 years ago

3.7.0

3 years ago

3.11.2

3 years ago

3.11.1

3 years ago

3.10.4

3 years ago

3.6.3

3 years ago

3.6.2

3 years ago

3.6.1

3 years ago

3.6.0

3 years ago

3.5.5

3 years ago

3.5.4

3 years ago

3.5.3

3 years ago

3.5.2

3 years ago

3.5.1

3 years ago

3.5.0

3 years ago

3.4.4

3 years ago

3.4.3

3 years ago

3.4.5

3 years ago

3.4.2

3 years ago

3.4.1

3 years ago

3.4.0

3 years ago

3.2.0

3 years ago

3.1.3

3 years ago

3.1.6

3 years ago

3.1.5

3 years ago

3.1.4

3 years ago

3.3.0

3 years ago

3.1.2

3 years ago

3.1.1

3 years ago

3.1.0

3 years ago

2.13.0

3 years ago

2.12.0

3 years ago

2.11.3

3 years ago

2.11.2

3 years ago

2.11.0

3 years ago

2.11.1

3 years ago

2.10.5

3 years ago

2.10.4

3 years ago

2.10.2

3 years ago

2.10.3

3 years ago

2.10.1

3 years ago

2.10.0

3 years ago

2.9.1

3 years ago

2.9.0

3 years ago

2.8.1

3 years ago

2.8.0

3 years ago

2.7.0

3 years ago

2.6.5

3 years ago

2.6.4

3 years ago

2.6.3

3 years ago

2.6.2

3 years ago

2.6.1

3 years ago

2.6.0

3 years ago

2.5.3

3 years ago

2.5.2

3 years ago

2.5.1

3 years ago

2.5.0

3 years ago

2.4.1

3 years ago

2.4.0

3 years ago

2.4.2

3 years ago

2.3.0

3 years ago

2.2.4

3 years ago

2.2.3

3 years ago

2.2.1

3 years ago

2.2.0

3 years ago

2.1.0

3 years ago

2.0.1

3 years ago

2.0.0

3 years ago

1.44.0

3 years ago

1.44.1

3 years ago

1.43.0

3 years ago

1.42.12

3 years ago

1.42.4

3 years ago

1.42.6

3 years ago

1.42.9

3 years ago

1.41.1

3 years ago

1.42.0

3 years ago

1.42.2

3 years ago

1.42.1

3 years ago

1.41.0

3 years ago

1.40.5

3 years ago

1.40.4

3 years ago

1.40.3

3 years ago

1.40.2

3 years ago

1.40.1

3 years ago

1.39.4

3 years ago

1.39.3

3 years ago

1.39.2

3 years ago

1.39.0

3 years ago

1.38.2

3 years ago

1.38.0

4 years ago

1.37.0

4 years ago

1.36.14

4 years ago

1.36.12

4 years ago

1.36.11

4 years ago

1.36.13

4 years ago

1.36.8

4 years ago

1.36.6

4 years ago

1.36.7

4 years ago

1.36.4

4 years ago

1.36.5

4 years ago

1.36.3

4 years ago

1.36.2

4 years ago

1.36.1

4 years ago

1.36.0

4 years ago

1.35.1

4 years ago

1.35.0

4 years ago

1.34.0

4 years ago

1.33.1

4 years ago

1.32.1

4 years ago

1.32.4

4 years ago

1.32.5

4 years ago

1.32.2

4 years ago

1.32.3

4 years ago

1.31.3

4 years ago

1.31.2

4 years ago

1.30.0

4 years ago

1.29.0

4 years ago

1.28.0

4 years ago

1.27.3

4 years ago

1.27.2

4 years ago

1.27.0

4 years ago

1.27.1

4 years ago

1.26.0

4 years ago

1.25.3

4 years ago

1.25.2

4 years ago

1.25.1

4 years ago

1.25.0

4 years ago

1.24.7

4 years ago

1.24.6

4 years ago

1.24.5

4 years ago

1.24.3

4 years ago

1.24.1

4 years ago

1.24.2

4 years ago

1.24.0

4 years ago

1.23.0

4 years ago

1.22.0

4 years ago

1.22.1

4 years ago

1.21.0

4 years ago

1.20.0

4 years ago

1.19.5

4 years ago

1.19.4

4 years ago

1.19.3

4 years ago

1.19.2

4 years ago

1.19.1

4 years ago

1.19.0

4 years ago

1.18.1

4 years ago

1.18.0

4 years ago

1.18.3

4 years ago

1.18.2

4 years ago

1.17.0

4 years ago

1.16.3

4 years ago

1.16.2

4 years ago

1.16.1

4 years ago

1.16.0

4 years ago

1.15.0

4 years ago

1.14.1

4 years ago

1.14.0

4 years ago

1.14.4

4 years ago

1.14.3

4 years ago

1.14.2

4 years ago

1.13.4

4 years ago

1.13.2

4 years ago

1.13.1

4 years ago

1.13.3

4 years ago

1.12.0

4 years ago

1.11.2

4 years ago

1.11.0

4 years ago

1.11.1

4 years ago

1.10.4

4 years ago

1.10.3

4 years ago

1.10.2

4 years ago

1.10.1

4 years ago

1.10.0

4 years ago

1.9.0

4 years ago

1.8.0

4 years ago

1.7.1

4 years ago

1.7.0

4 years ago

1.6.0

4 years ago

1.5.7

4 years ago

1.5.5

4 years ago

1.5.4

4 years ago

1.5.6

4 years ago

1.5.3

4 years ago

1.5.2

4 years ago

1.5.1

4 years ago

1.5.0

4 years ago

1.4.0

4 years ago

1.3.0

4 years ago

1.2.0

4 years ago

1.1.0

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

0.9.0

4 years ago

0.8.2

4 years ago

0.8.1

4 years ago

0.8.0

4 years ago

0.7.9

4 years ago

0.7.8

4 years ago

0.7.6

4 years ago

0.7.5

4 years ago

0.7.7

4 years ago

0.7.4

4 years ago

0.7.3

4 years ago

0.7.2

4 years ago

0.7.1

4 years ago

0.7.0

4 years ago

0.6.0

4 years ago

0.5.1

4 years ago

0.3.5

4 years ago

0.5.0

4 years ago

0.4.0

4 years ago

0.3.2

4 years ago

0.3.4

4 years ago

0.3.3

4 years ago

0.3.1

4 years ago

0.1.11

4 years ago

0.1.9

4 years ago