All Projects → ArrayKnight → storybook-addon-headless

ArrayKnight / storybook-addon-headless

Licence: MIT license
A Storybook addon to preview content from a headless CMS in components

Programming Languages

typescript
32286 projects
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to storybook-addon-headless

storybook-addon-mock
This addon allows you to mock fetch or XMLHttpRequest in the storybook.
Stars: ✭ 67 (+191.3%)
Mutual labels:  addon, storybook, storybook-addon
storybook-xstate-addon
A storybook addon to assist with writing stories that rely on xstate
Stars: ✭ 48 (+108.7%)
Mutual labels:  addon, storybook, storybook-addon
storybook-addon-xd-designs
For adobe XD. Demo at https://morgs32.github.io/storybook-addon-xd-designs
Stars: ✭ 41 (+78.26%)
Mutual labels:  storybook, storybook-addon
storybook-addon-next
A no config Storybook addon that makes Next.js features just work in Storybook
Stars: ✭ 184 (+700%)
Mutual labels:  addon, storybook
awesome-medusajs
A curated list of awesome resources related to MedusaJS 😎
Stars: ✭ 113 (+391.3%)
Mutual labels:  headless, headless-cms
Addon Smart Knobs
🧠 This Storybook plugin uses @storybook/addon-knobs but creates the knobs automatically based on PropTypes.
Stars: ✭ 215 (+834.78%)
Mutual labels:  addon, storybook
FlexDotnetCMS
A powerful, flexible, decoupled and easy to use and Fully Featured ASP .NET CMS, it can also be used as a Headless CMS
Stars: ✭ 45 (+95.65%)
Mutual labels:  headless, headless-cms
vaahcms
VaahCMS is a laravel based open-source web application development platform shipped with a headless content management system (CMS).
Stars: ✭ 56 (+143.48%)
Mutual labels:  headless, headless-cms
Storybook Addon Styled Component Theme
storybook addon
Stars: ✭ 168 (+630.43%)
Mutual labels:  addon, storybook
storybook-graphql-kit
Write GraphQL queries and pass response data to your components
Stars: ✭ 19 (-17.39%)
Mutual labels:  storybook, storybook-addon
create-material-ui-app
create-react-app + storybook + storybook-addon-material-ui
Stars: ✭ 55 (+139.13%)
Mutual labels:  addon, storybook
startup-starter-kit
The Structured Content Startup Starter Kit
Stars: ✭ 42 (+82.61%)
Mutual labels:  headless, headless-cms
Addon Jsx
This Storybook addon show you the JSX / template of the story
Stars: ✭ 209 (+808.7%)
Mutual labels:  addon, storybook
statiq-starter-kontent-lumen
Lumen is a minimal, lightweight, and mobile-first starter for creating blogs using Statiq and Kontent by Kentico.
Stars: ✭ 22 (-4.35%)
Mutual labels:  headless, headless-cms
Storybook Addon Jest
REPO/PACKAGE MOVED - React storybook addon that show component jest report
Stars: ✭ 177 (+669.57%)
Mutual labels:  addon, storybook
laravel-storyblok
Make Laravel and Storyblok work together beautifully.
Stars: ✭ 45 (+95.65%)
Mutual labels:  headless, headless-cms
Storybook Addon
Develop themable components with Emotion/Styled Components/Material-UI with help of Storybook & React Theming
Stars: ✭ 122 (+430.43%)
Mutual labels:  addon, storybook
React Storybook Addon Props Combinations
Given possible values for each prop, renders your component with all combinations of prop values.
Stars: ✭ 130 (+465.22%)
Mutual labels:  addon, storybook
contentjet-api
Headless API-first content management system
Stars: ✭ 95 (+313.04%)
Mutual labels:  headless, headless-cms
yllet
Yllet is a set of packages for the WordPress API for both React and non-React projects
Stars: ✭ 46 (+100%)
Mutual labels:  headless, headless-cms

Storybook Addon Headless

Storybook Addon Headless allows you to preview data from a headless CMS inside stories in Storybook. It supports Restful and GraphQL APIs with the help of Axios and Apollo Client respectively. And each query can handle variables which are validated using Ajv.

Upgrading to v2

Dependencies Storybook@6 and Apollo@3 have been released!

Be aware of the change to Storybook's story parameters, StoryContext (where data is accessed) is now the second parameter.

Examples

Check out examples and detailed documentation:

Headless Story

Getting Started

Install

First of all, you need to install Headless into your project as a dev dependency.

npm install --save-dev storybook-addon-headless

Register

Then, configure it as an addon by adding it to your addons.js file (located in the Storybook config directory).

import 'storybook-addon-headless'

Or to the addons parameter in your main.js file (located in the Storybook config directory).

module.exports = {
    addons: ['storybook-addon-headless'],
    ...,
}

Decorate

Depending on the need of your project, you can either, add the withHeadless decorator:

  • Globally in config.js via addDecorator(withHeadless({ ... }))
  • Locally via storiesOf('Name', module).addDecorator(withHeadless({ ... }))
  • Locally to a story via CSF:
export default {
    ...,
    decorators: [withHeadless({ ... })],
    ...,
}

You can find options documented as HeadlessOptions and on the documentation site.

Options
{
    graphql?: GraphQLOptionsTypes
    restful?: RestfulOptionsTypes
    jsonDark?: ReactJsonViewThemeKey
    jsonLight?: ReactJsonViewThemeKey
}

Under the covers, this addon uses Axios for Restful queries and Apollo Client for GraphQL queries. These configs are optional, though you'll likely want to use one or both. The configs will also be merged with the optional configs being passed through the parameters.

Parameters

Parameters are added locally via:

  • storiesOf('Name', module).addParameters({ headless: { ... } })
  • add(name, storyFn, { headless: { ... } })
  • Via CSF:
export default {
    ...,
    parameters: {
        headless: { ... }
    },
    ...,
}

You can find parameters document as HeadlessParameters and on the documentation site.

{
    headless: {
        [name]: HeadlessParameter,
        ...,
    }
}

name is the string to represent the query and data. It will be shown in the tab for the query and be the accessor on the data object in the story context.

HeadlessParameter represents several different possible options:

  • string: Restful URL
  • PackedDocumentNode: A packed GraphQL Tag DocumentNode
  • GraphQLParameters: An object with a PackedDocumentNode as a query and some optional parameters
  • RestfulParameters: An object with a Restful URL string as a query and some optional parameters

Due to the way a DocumentNode is converted to JSON, to maintain the original source query use the pack utility method.

Components

To help provide a better user experience, there are Prompt and Loader helper components provided.

These components are entirely optional, but will help to direct users to the Headless tab if necessary and provide feedback about the state of active API requests.

You can find basic usage in the examples.

Experimental (read: untested):

There are also two methods for those of you not using React, but wanting to use these helper components. useHeadlessPrompt and useHeadlessLoader will render the React components as standalone apps, but you must provide an HTML element reference that has been rendered and mounted by your framework of choice.

Produced @ GenUI

This addon was developed while I was employed at GenUI, a software product development firm in Seattle, WA, USA. Interested in knowing more, starting a new project or working with us? Come check us out at https://www.genui.com/

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].