Skip to content
This repository was archived by the owner on Jan 9, 2024. It is now read-only.

A Storybook addon that extracts and displays compiled syntax-highlighted HTML

License

Notifications You must be signed in to change notification settings

lmestel/storybook-addon-html

This branch is 12 commits ahead of, 109 commits behind whitespace-se/storybook-addon-html:main.

Folders and files

NameName
Last commit message
Last commit date

Latest commit

e4f55d8 Â· Jan 9, 2024
Jan 7, 2021
Jun 5, 2023
Jun 5, 2023
Jul 26, 2021
Dec 2, 2019
May 3, 2021
Dec 2, 2019
Jul 26, 2021
Aug 21, 2020
Mar 26, 2021
Aug 21, 2020
Dec 2, 2019
Jan 9, 2024
Dec 10, 2020
Jun 5, 2023
Jul 26, 2021
Dec 10, 2020
Sep 26, 2022

Repository files navigation

Moved to https://github.com/kickstartDS/storybook-addon-html


Storybook Addon HTML

This addon for Storybook adds a tab that displays the compiled HTML for each story. It uses highlight.js for syntax highlighting.

Animated preview

Getting Started

With NPM:

npm i --save-dev @whitespace/storybook-addon-html

With Yarn:

yarn add -D @whitespace/storybook-addon-html

Register addon

// .storybook/main.js

module.exports = {
  // ...
  addons: [
    '@whitespace/storybook-addon-html',
    // ...
  ],
};

Usage

The HTML is formatted with Prettier. You can override the Prettier config (except parser and plugins) by providing an object following the Prettier API override format in the html parameter:

// .storybook/preview.js

export const parameters = {
  // ...
  html: {
    prettier: {
      tabWidth: 4,
      useTabs: false,
      htmlWhitespaceSensitivity: 'strict',
    },
  },
};

You can override the showLineNumbers and wrapLines settings for the syntax highlighter by using the highlighter parameter:

export const parameters = {
  html: {
    highlighter: {
      showLineNumbers: true, // default: false
      wrapLines: false, // default: true
    },
  },
};

You can add a decorator to wrap the story:

export const parameters = {
  html: {
    decorator: (Story, context) => (
      <MyProvider>
        <Story {...context}>
      </MyProvider>
    )
  },
};

Supported frameworks

As of version 4.0.0 all frameworks are supported per default 🎉

About

A Storybook addon that extracts and displays compiled syntax-highlighted HTML

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%