Storybook Source

The Storybook source is used to pull individual stories from Storybook, based on tags.

The Mosaic source will filter your Storybook's stories, based on title or tags.

For each matching story, a page is created in the Mosaic file-system.

  • additional Mosaic tags can be added to each page using additionalTags
  • additional Mosaic metadata can be added to each page using additionalData

This information can be used to create a dynamic index of stories from Storybook.

Installation

yarn add @jpmorganchase/mosaic-source-storybook

Configuration

The Storybook source is an HttpSource and shares the same base configuration. The transformResponseToPagesModulePath prop has a default transformer which creates a page for each matching Story.

The stories option is an array of Storybook urls that are used as Sources. Each story is matched on title using the filter Regexp (or by filterTags).

If specified, additionalTags and additionalData can be added to any matching pages.

PropertyDescriptionRequired
options.storiesarray of story configsYes

stories is an array of Storybooks that you want to pull stories from

PropertyDescriptionRequired
storyUrlPrefixprefix url of the storybook deploymentYes
descriptiondescription of the storybook storiesYes
storiesUrlurl of the storybook's stories.jsonNo
filterRegExp filter to match onNo
filterTagsArray of Storybook tags to match onNo
metaadditional data to add to matching pagesNo

Example Local Folder Source Definition

sources: [
    {
      modulePath: '@jpmorganchase/mosaic-source-storybook',
      namespace: 'salt',
      options: {
        prefixDir: '/salt/internal/community-index/story-navigation',
        stories: [
          {
            storiesUrl: 'https://storybook.saltdesignsystem.com/stories.json',
            storyUrlPrefix: 'https://storybook.saltdesignsystem.com',
            description: 'Navigation patterns created in the Salt Labs',
            meta: { // can be any additional metadata you want added to the page's meta.data
              tags: ['some-tag'],
              data: {
                owner: 'Salt',
                source: 'STORYBOOK'
              }
            },
            filter: /Lab\/Tabs/ // this is a Regexp that matches on Storybook title
          }
        ]
      }
    }
]

Example story metadata format

{
  "type": "story",
  "id": "folder--story-1",
  "name": "Story 1",
  "title": "Folder/Story 1",
  "importPath": "./folder/story-1.stories.tsx",
  "tags": [
    "dev",
    "test"
  ]
}
Mosaic BETA

Coming soon