npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@harelpls/storybook-addon-materialui

v2.0.0

Published

A simple decorator to wrap your stories in a @mui-org material-ui theme

Downloads

15,297

Readme

@harelpls/storybook-addon-materialui

A simple storybook addon that provides a decorator to wrap your stories in the theme provider. storybook-addon-material-ui provided too many options for me and lacked the <CssBaseline /> injection.

@harelpls/storybook-addon-materialui demo

Installation

  1. Setup storybook
  2. yarn add --dev @harelpls/storybook-addon-materialui
  3. register the addon in main.js:
module.exports = {
  stories: [...],
  addons: ['@harelpls/storybook-addon-materialui']
}
  1. add the decorator:
import React from 'react';

import { addDecorator } from '@storybook/react';
import { withMuiTheme } from "@harelpls/storybook-addon-materialui";

import {lightTheme, darkTheme} from './theme';
import MyComponent from './MyComponent';

// globally with custom themes
addDecorator(withMuiTheme({
  "Custom light theme": lightTheme,
  "Custom dark theme": darkTheme
}))

// via CFS with default themes
export default = {
  title: "My/Component",
  decorators: [withMuiTheme()]
}

// for individual story with default themes
export const MyStory = () => <MyComponent />;
MyStory.story = {
  decorators: [withMuiTheme()]
}

Options

The only options are the themes you wish to inject. The withMuiTheme decorator takes an object that describes your custom themes. The key is the name and label for the select element. The value is the theme itself.

withMuiTheme({
  'Select Option': myCustomTheme,
});

Parameters

Disable ThemeProvider wrapper for a single story

You can disable the wrapper (essentailly the whole addon) for particular stories by adding the disable parameter to materialui:

// CFS export
export default {
  title: 'Disable parameter',
  parameters: {
    materialui: {
      disable: true,
    },
  },
};

Disable <CssBaseline />

You may be using @storybook/addon-backgrounds and not want the background controlled by this addon. Simply pass the cssbaseline: false parameter to prevent the <CssBaseline /> component from being injected.

// CFS export
export default {
  title: 'Disable parameter',
  parameters: {
    materialui: {
      cssbaseline: false,
    },
  },
};