npm.io
1.5.1 • Published 6 years ago

storybook-multiple-themeprovider

Licence
MIT
Version
1.5.1
Deps
3
Size
37 kB
Vulns
0
Weekly
0
Stars
1

Storybook SC ThemeProvider

GitHub package.json version CircleCI (all branches) GitHub last commit npm GitHub Greenkeeper badge Semantic Release

Added new features

v1.2.0 - Added preview of the theme selected


The ThemeProvider storybook addon let's you show your Emotion theme on your favourite Storybook UI at runtime.

Screenshot

Getting Started

First, install the addon

yarn add themeprovider-storybook --dev
npm install --save-dev themeprovider-storybook

Add this line to your addons.js file (create this file inside your storybook config directory if needed).

import 'themeprovider-storybook/register';
Set options globally

Import and use the addDecorator in your config.js file.

import { addDecorator, configure } from '@storybook/react';
import { withThemesProvider } from "themeprovider-storybook";

// Options:
const themes = [
  {
    name: 'Theme1' // Required it's used for displaying the button label,
    backgroundColor: '#fff' // Optional, it's used for setting dynamic background color on storybook
    ..., // Your theme keys (Check example if you need some help)
  },
  {
    name: 'Theme2' // Required it's used for displaying the button label,
    backgroundColor: '#000'// Optional, it's used for setting dynamic background color on storybook
    ..., // Your theme keys (Check example if you need some help)
  }
]
addDecorator(withThemesProvider(themes));

configure(() => require('./stories'), module);

Keywords