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

storybook-addon-rem-v8

v2.1.0

Published

A storybook addon which helps you to test how your REM sized components behave.

Downloads

4,305

Readme

Storybook Addon REM

Storybook REM preview

A storybook addon which helps you to test how your REM sized components behave.

Why and when to use REM

Aleksandr Hovhannisyan wrote an awesome article about rems for font size. Check it out if you want to learn more about this CSS unit.

Getting started

Install the addon:

npm i storybook-addon-rem --dev

Add following content to .storybook/main.(js|mjs|cjs):

module.exports = {
  addons: ['storybook-addon-rem']
};

Add some css rem declerations to your component styling, e.g.:

.your-component-button {
  font-size: 1rem;
}

Run your storybook instance. You should be able to see and use this addon in the toolbar 🚀

Configuration

Custom sizes

If you want to pass custom sizes you can do this by adding something like this in the .storybook/preview.(js|mjs|cjs) file:

export const parameters = {
  // ...
  rem: {
    // ...
    sizes: [
      { value: 6, title: 'Tiny' },
      { value: 12, title: 'Standard' },
      { value: 72, title: 'Huge' },
    ]
  },
}

Default paddings

By default storybook-rem-addon removes storybooks rem paddings on the canvas and docs pages. If you want to keep the rem padding you can configure this in the .storybook/preview.(js|mjs|cjs) file:

export const parameters = {
  // ...
  rem: {
    // ...
    canvasRemPadding: true,
    docsRemPadding: true,
  }
};

Events

You can listen for the rem-update event via the addons channel:

const channel = api.getChannel();

// On mount
useEffect(() => {
  channel.addListener( 'rem-update', onRemUpdate );

  return () => {

    // On unmount
    channel.removeListener( 'rem-update', onRemUpdate );
  };
});

const onRemUpdate = ( data ) => {
  console.log( data.title, data.value );
}

Storybook addon REM development

run the build:watch process:

npm build:watch

open a second terminal. Go to examples/basic:

cd example/basic/

this is a plain storybook setup where this addon has been integrated. Install dependencies with

npm i

then start storybook with

npm run storybook

Notice: This storybook instance requires a lower node version than 18. If needed: Install NVM and switch to a lower version of nodejs e.g. v16.19.0 also known as lts/gallium:

nvm i lts/gallium
nvm use lts/gallium

Roadmap

  • ~~Integrate Storybook events~~
  • Update icon(s)

Notes