Addon for storybook wich wrap material-ui components into MuiThemeProvider. 📃 This helps and simplifies development of material-ui based components.
Clone or download
Latest commit 84907ea Aug 3, 2018
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.scripts Update scripts Jul 16, 2017
.storybook v0.7.10 Jun 26, 2017
docs upd readme Dec 24, 2016
example Get rid of react-tap-event-plugin Oct 3, 2017
src add link to v1 Jun 30, 2018
test lintfix Sep 28, 2016
.babelrc v0.6.0 github init Sep 18, 2016
.eslintrc lintfix Sep 28, 2016
.gitignore v 0.7.6 Feb 7, 2017
.npmignore deleted dist Oct 15, 2016
CHANGELOG.md v 0.7.8 May 6, 2017
CODE_OF_CONDUCT.md Contributor Covenant Oct 10, 2016
LICENSE Create LICENSE Oct 4, 2017
REACT-THEMING.md v0.8.11 Jul 5, 2018
README.md fix: Getting Started Aug 3, 2018
mochacfg.js lintfix Sep 28, 2016
package-lock.json v0.8.10 Jul 5, 2018
package.json v0.8.11 Jul 5, 2018
storybook.md Demo Sep 18, 2016
twitter_button.png twitter Oct 10, 2016
yarn.lock v0.8.11 Jul 5, 2018

README.md

GitHub version npm version Live demo

Storybook Addon Material-UI

The core of React Theming project

Announcement Material-UI v1 support

storybook-addon-material-ui@0.9.0-alpha.2 now supports Material-UI v1 themes. It has only basic functionality since v.1 themes are very different from the previous version. We would appreciate if you give us your feedback about the most needed features which we will reimplement.

You can do it with this anonymous survey.

It contains only 10 questions and helps us to provide you with the best DX. You are always welcome to submit an issue as well 😄

To install alpha version type:

npm i storybook-addon-material-ui@next --save-dev

then you can create themes and add them to the panel this way:

// addons.js

import 'storybook-addon-material-ui/register';
// stories.js

import { createMuiTheme } from '@material-ui/core/styles';

const customTheme1 = createMuiTheme({
    palette: {
        primary: {
            light: accentGreen,
            main: primaryGreen,
            dark: darkGreen,
            contrastText: '#fff',
        },
        secondary: {
            light: accentPurple,
            main: primaryPurple,
            dark: darkPurple,
            contrastText: '#fff',
        },
    },
    themeName: 'Custom Light Theme',
});

storiesOf('Material Custom theme', module)
    .addDecorator(
        muiTheme([customTheme1]),
    )
    /* your stories */

thanks @laruiss for helping to make this release happen


Storybook Addon Provides development environment which helps creating Material-UI Components. This is addon for React Storybook wich wraps your components into MuiThemeProvider. This accelerates and simplifies the development process for Material-UI based applications.

You can use this project's demo page to discover Material-UI Theme Settings for any component and create your own new themes right online. But to take full advantage of this project run it locally in your work environment.

screen1

Features 💫

Live demo

  • Wrapped in the theme provider. Just start to develop with base light theme.
  • Injected TapEvent Plugin. Test on mobile devices.
  • Switching themes. See how it looks in one click.
  • Creating your custom theme. By code or in visual editor.
  • Dynamic visual themes editing. Discover the all avalibale theme properties.
  • Google material color palette picker
  • Save made changes and download in JSON file
  • Part of React Theming. Create themable React Components.
  • Works with Storybook 3.0

Quick Start

The fastest and easiest way to start hacking Material-UI from scratch is to clone Storybook Boilerplate Project. You need to have NodeJS and Git installed in your machine.

git clone https://github.com/sm-react/storybook-boilerplate.git
cd storybook-boilerplate
npm i
npm start
Few short steps to create your themable `Material-UI` Components 👆

Open http://localhost:9001/ in your browser.

Press Ctrl-Shft-F to exit from Full screen mode.

Select Material-UI at the left panel. You'll see two stories with Material-UI Components: Components and Card.

Select Material-UI at the bottom panel. You can switch themes from drop-down menu. Out of the box you have tree themes: Light Theme (Material-UI default), Dark Theme (Material-UI), Grey Theme (React Theming Complimentary 🎁),

Open you project folder. Find src/MaterialUI/ directory. You'll find JSX files with Material-UI based React Components. You can use them as a starting point to create your own components.

In oder to see your components in storybook add them to src/MaterialUI/index.story.jsx. You can do it this way. You can read more about writing stories in their documentation.

Your themes files are located in the src/.themes folder as a JSON files. Please note that all JSON files from this folder are imported automatically. So you can change them or add the new ones and you'll see this themes in your Storybook.

You can edit the theme settings in Theme.json files manually, but the power of this project is that you can do it in your browser and see all changes immediately on your Material-UI Components. See Usage details to learn about working with themes.

🚩 The Storybook Boilerplate contains many additional features for creating themable React Components, allows publishing your packages to npm and deploying your storybooks to Github Pages. It includes linting and testing scripts and other useful Storybook Addons.

If you already using React Storybook and have it installed in your project you can add this addon manually. Follow Getting Started section to install storybook-addon-material-ui and find detailes about using it. You can add React Storybook to your existing project as well, check the documentation for that.

Roadmap 🚠

We have many plans and ideas for further development. See projects about what kind of features we plan to implement in the future. We create this tool for your convenience and productivity, so we are always happy to hear your ideas and wishes.

Getting Started 📑

First, install the addon

npm i storybook-addon-material-ui --save-dev

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

import 'storybook-addon-material-ui/register';

Now, write your stories with Material-UI Addon. By default your stories will be provided with Light and Dark Themes

import React from 'react';
import { storiesOf, addDecorator } from '@storybook/react';
import {muiTheme} from 'storybook-addon-material-ui';

// Import some examples from material-ui
import CardExampleControlled from '../CardExampleControlled.jsx';
import RaisedButtonExampleSimple from '../RaisedButtonExampleSimple.jsx';
import DatePickerExampleSimple from '../DatePickerExampleSimple.jsx';

storiesOf('Material-UI', module)
// Add the `muiTheme` decorator to provide material-ui support to your stories.
// If you do not specify any arguments it starts with two default themes
// You can also configure `muiTheme` as a global decorator.
    .addDecorator(muiTheme())
    .add('Card Example Controlled', () => (
            <CardExampleControlled />
        ))
    .add('Raised Button Example Simple', () => (
            <RaisedButtonExampleSimple />
        ))
    .add('Date Picker Example Simple', () => (
            <DatePickerExampleSimple />
        ));

Note : You can switch between the loaded themes. Out of the box, you have two base themes, but you can simply add your custom themes like this:

import React from 'react';
import { storiesOf, addDecorator } from '@storybook/react';

import {muiTheme} from 'storybook-addon-material-ui';

import CardExampleControlled from '../CardExampleControlled.jsx';
import RaisedButtonExampleSimple from '../RaisedButtonExampleSimple.jsx';
import DatePickerExampleSimple from '../DatePickerExampleSimple.jsx';

// Create your own theme like this.
// Note: you can specify theme name in `themeName` field. Otherwise it will be displayed by the number.
// you can specify only required fields overriding the `Light Base Theme`
const newTheme = {
    themeName: 'Grey Theme',
    palette: {
        primary1Color: '#00bcd4',
        alternateTextColor: '#4a4a4a',
        canvasColor: '#616161',
        textColor: '#bdbdbd',
        secondaryTextColor: 'rgba(255, 255, 255, 0.54)',
        disabledColor: '#757575',
        accent1Color: '#607d8b',
    },
};



storiesOf('Material-UI', module)
    .addDecorator(muiTheme([newTheme]))
    .add('Card Example Controlled', () => (
            <CardExampleControlled />
        ))
    .add('Raised Button Example Simple', () => (
            <RaisedButtonExampleSimple />
        ))
    .add('Date Picker Example Simple', () => (
            <DatePickerExampleSimple />
        ));

Usage details

Select MATERIAL-UI panel. You can select the theme you need to see and you will have all theme settings in the right sidebar. You can toggle Theme editor with all theme settings in a editable table. It'll appear as a right sidebar.

You can edit the value manually as a text string or via picker tool (click the icon to the right of the input)

screen3

By default you see only assigned fields of selected theme. You can switch to Full settings and all available settings will appear. As you override one of them it will appear in the Theme setting mode and in the bottom panel JSON area.

screen6

After you have made changes in the theme, you can save it and download as *.JSON file.

You can continue to work with this file:

import greyTheme from './greyTheme.json';
addDecorator(greyTheme);

Query string parameters

As you select themes and other options it stores in adress bar line. So this state is retained when you refresh the page and you can use direct links to the desired states.

http://localhost:9001/?theme-ind=0&theme-sidebar=true&theme-full=true

CONTRIBUTING 🙋

@airbnb

Open Source Helpers

🔧 Developers:

Our team welcomes all contributions, tests, and bug fixes. If you would like to help contribute to the project feel free to make an issue, PR or get in touch with me.

🎀 Designers:

We would really welcome the involvement of designers in this project. We are very interested in your opinion about working with this tool, the possibility of joint work of the designer and developer as well as its appearance and capabilities

Credits

telegram:@usulpro (The quickest way to contact me ⚡️)

@UsulPro

@UsulPro

@react-theming