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

mymedmen-web-storybook

v0.0.10003

Published

Library of UI components for medmen-next

Downloads

14

Readme

MedMen Web Storybook

Scripts

  • npm run storybook - starts Storybook in dev mode with hot reloading
  • npm run storybook:build - statically build Storybook
  • npm run build - builds npm package with rollup.js
  • npm test - runs all tests
  • npm run test:watch - runs tests in watch mode

Using package

Until it will be published use npm link mentioned bellow.

Local development

Writing components

Storybook can run in dev mode with hot-reloading - use npm run storybook. Than you can write components in same way as in CRA.

All components are in ./src folder and than separated by Atomic Design methodology.

Don't forget to list new components in ./src/index.js.

// Atoms
export Button from './atoms/button';
export Loader from './atoms/loader';

Writing stories

Files with stories live next to components and have *.stories.js extension.

└─┬ src
  └─┬ atoms
    ├── button.js
    └── button.stories.js

You can see example of stories in official docs.

Some basic rules:

  • use .addWithJSX instead of .add - this function generates JSX preview,
  • if there are several versions of component modified by props, each should have own story,
  • for more complicated props use knobs.

npm link

npm link is CLI tool that allows to link local folder as npm package.

How to use it:

  • call npm link in mymedmen-web-storybook folder (where is package.json located),
  • in project where you want to use package call npm link mymedmen-web-storybook.

Testing

Jest with react-testing-library and custom-jest-matchers is used for testing.

Try to write tests for every component.

npm test runs in pre-push host.

For imports from react-testing-library use test-utils that provides theme:

import { render, fireEvent } from 'test-utils';
import Button from './button';

describe('Button', () => {
  test('click on button', () => {
    const handleClick = jest.fn();
    const { getByText } = render(
      <Button onClick={handleClick}>Some button</Button>,
    );
  })
})

Deploy Storybook as web site

Storybook produces static html files, which can be served as any website.

Storybook is listed as devDependencies (to prevent installing it with package), therefore run npm install without NODE_ENV=production or --production.

Than call npm run build, static website is located in ./storybook-static.