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

sb-figma-comparator

v0.1.7

Published

Overlay the Figma design over the stories to detect irregularities in the implemented UI

Downloads

650

Readme

Storybook Addon Figma Comparator

Compare components with Figma Components

How to install

npm install --dev storybook-addon-figma-comparator

# or

yarn add -D storybook-addon-figma-comparator
// .storybook/main.js

// ...
module.exports = {
  // ...
  addons: [
    // ...
    'storybook-addon-figma-comparator',
  ],
}

You need to add your Figma token with access to the Figma files to the environment variable STORYBOOK_FIGMA_ACCESS_TOKEN.

How to use

Basic usage:

// ...
export default {
  title: "Example/Button",
  component: Button,
  // ...
}

const Template = (args) => <Button {...args} />;

export const Primary = Template.bind({});
Primary.args = {
  primary: true,
  label: "Button",
};
Primary.parameters = {
  figma: {
    component:
      "https://www.figma.com/file/ZZZ/file-name?node-id=XXX%3AYYY",
  } as FigmaParams,
};

Figma Parameter

figma = {
  component: FigmaComponent | FigmaComponentSet;
  options?: {
    style?: React.CSSProperties;
    componentStyle?: React.CSSProperties;
    opacity?: number;
  };
}

FigmaComponentNode = {
  fileId: string;
  nodeId: string;
}

FigmaComponent = string | FigmaComponentNode;

FigmaComponentSet = {
  [key: number]: FigmaComponent;
};

The component can be a string indicating the URL of the Figma component, a Figma node indicating the file id and the node id (component id) or it can be a Component set in cases where the component changes in different viewpoints.

Component set example

// ...
Primary.parameters = {
  figma: {
    component: {
        0: node1,
        768: node2,
        1440: node3
    }
  },
};

// the nodes can have any of the following formats:
node1 = "https://www.figma.com/file/ZZZ/file-name?node-id=XXX%3AYYY";
node2 = {
  fileId: "ZZZ",
  nodeId: "XXX:YYY"
}
node3 = {
  // the component can be a string or a FigmaComponentNode like `node1` or `node2`
  component: "https://www.figma.com/file/ZZZ/file-name?node-id=XXX%3AYYY",
  // this options will override the component `options`
  options: {
    style: {
      // figma component options
      padding: 12,
    },
    componentStyle: {
      // story component options. This way you can set a fixed width to match exactly with the Figma image
      width: 650,
    },
  }
}

In the previous example, the Figma comparator will fetch the Figma image of the component if the viewport width is between 0 and 767, the image from node 2 if the viewport width is between 768 and 1439 and the image from the node 3 if the viewport width is greater than 1440.

Development scripts

  • yarn start runs babel in watch mode and starts Storybook
  • yarn build build and package your addon code