JSPM

@rmiller61/storybook-zeplin

1.7.2
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • 0
  • Score
    100M100P100Q20684F
  • License MIT

Zeplin addon for Storybook

Package Exports

  • @rmiller61/storybook-zeplin
  • @rmiller61/storybook-zeplin/dist/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@rmiller61/storybook-zeplin) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Zeplin Storybook Addon

npm version Monthly download GitHub license Netlify Status


Storybook Zeplin addon

Storybook addon that embeds Zeplin resources such as screens and components in the addon panel for better design-development workflow.

Zeplin Storybook Addon

Requirements

  • Storybook@>=5.0.0

This addon should work with any framework. If you find a case that the addon does not work, please open an issue.

Getting started

1. Install

npm install --save-dev storybook-zeplin
# yarn add -D storybook-zeplin

2. Register the addon in main.js

// .storybook/main.js
module.exports = {
    addons: ["storybook-zeplin/register"],
};

If you're using Storybook@5.0.x;

// .storybook/addons.js
import "storybook-zeplin/register";

3. Add a Zeplin link to your story

Storybook Zeplin takes parameter zeplinLink as an array of elements containing a name and a link or just a string for the link. For the link, you can use full web URL or app URI of Zeplin components/screens.

Example of adding Zeplin link to all stories in a file:

export default {
    title: "Button",
    component: Button,
    parameters: {
        zeplinLink: "https://app.zeplin.io/project/5e7a6d478204d59183a1c76b/styleguide/components?coid=5eac833c5f1f2f1cb19f4f19",
    },
};

export const Default = () => <Button>Click me</Button>;
export const Secondary = () => <Button secondary>Click me</Button>;

Default.story = {
    name: "Primary Button",
};

Secondary.story = {
    name: "Secondary Button",
};

Example of adding multiple Zeplin links to a story:

export default {
    title: "Button",
    component: Button,
};

export const Default = () => <Button>Click me</Button>;
export const Secondary = () => <Button secondary>Click me</Button>;

Default.story = {
    name: "Responsive Button",
    parameters: {
        zeplinLink: [
            {
                name: "Desktop",
                link: "zpl://components?pid=pid1&coid=coid1",
            },
            {
                name: "Tablet",
                link: "zpl://components?pid=pid1&coid=coid2",
            },
            {
                name: "Mobile",
                link: "zpl://components?pid=pid1&coid=coid3",
            },
        ],
    },
};

The addon shows connected components when a project or styleguide link is provided as zeplinLink. If you are using Zeplin's connected component feature, you can provide the link globally as in the example below.

//.storybook/preview.js
export const parameters = {
    zeplinLink: "https://app.zeplin.io/project/5e7a6d478204d59183a1c76b",
};

5. Set Zeplin access token

To access your Zeplin resources, you need to provide an access token with your Zeplin account permissions. You can create one from Developer tab in your profile page.

The addon prompts to set the token when you open the addon's tab. This token is kept in the browser storage, so each user needs to create and set their own token to access Zeplin resources via Storybook.

Setting Access Token

(Optional) Setting the access token using environment variable

If you want to skip creating tokens for each user, you can provide the access token as an environment variable called STORYBOOK_ZEPLIN_TOKEN. You can create .env file in your project's root folder, or you can provide the environment variable as a command line parameter when building or dynamically running Storybook.

⚠️ Disclaimer

Please note that access token can be viewed by anyone with access to the Storybook instance if you set it using environment variable. For security reasons, never use the environment variable, if the Storybook instance can be accessed by 3rd parties.

# .env
STORYBOOK_ZEPLIN_TOKEN="eyJhbGciOiJIUzI1N.."

Development

Run following commands in separate tabs to start development

npm run watch
npm run storybook

Notes

  • This addon extracts the Storybook data and sends to parent frame to make stories reachable from Zeplin apps. For more information: Zeplin Storybook integration

License

MIT © Mert Kahyaoğlu