• Stars
    star
    115
  • Rank 305,916 (Top 7 %)
  • Language
    TypeScript
  • License
    MIT License
  • Created over 4 years ago
  • Updated 8 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Storybook addon to view Zeplin resources in story panel
Zeplin Storybook Addon

npm version Monthly download GitHub license Netlify Status Open Collective


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

Links

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 [email protected];

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

3. Linking components

There are two ways to do this, you can link your entire Zeplin project or styleguide to your global story parameters (recommended) or link individual components one by one.

Option A: Linking entire project or styleguide (Recommended)

Add zeplinLink to .storybook/preview.js file. This value is a link to the project or styleguide that contains correspondent designs in Zeplin as shown below examples.

When this parameter is provided, you will automatically view Zeplin components linked to your stories on the addon panel using the Storybook integration.

Using a Zeplin web link

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

Using a Zeplin app link

//.storybook/preview.js
export const parameters = {
    zeplinLink: "zpl://project?pid=61f164b064e363a52fbb295f",
};

When the addon setup is done, go and check out below articles to learn more about how to initialize Storybook integration on Zeplin.

Option B: Linking individual stories manually

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",
            },
        ],
    },
};

4. 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

More Repositories

1

zeplin-extension-documentation

Documentation for Zeplin extensions βš—οΈπŸ“š
236
star
2

zeplin-sketch-plugin

Zeplin Sketch plugin πŸ’Žβš‘οΈ
150
star
3

emoji-autocomplete-sketch-plugin

Type β€œ:” followed by the first few letters to autocomplete emojis. πŸ’
Objective-C
149
star
4

connected-components-docs

Documentation for Connected Components
140
star
5

zeplin-html-to-pdf

AWS Lambda function that converts HTML pages to PDF documents
JavaScript
123
star
6

zem

Create, test and publish Zeplin extensions with no build configuration βš—οΈπŸ¦„
JavaScript
81
star
7

fastlane-plugin-notarize

fastlane plugin to notarize a macOS app πŸ›‚
Ruby
68
star
8

react-native-extension

React Native JavaScript snippets from colors, text styles and layers βš›οΈπŸ“±
JavaScript
67
star
9

zeplin-palette

38
star
10

vscode-extension

Zeplin for Visual Studio Code πŸ”Œ
TypeScript
34
star
11

cli

Command-line interface for Zeplin
TypeScript
31
star
12

stylesheet-extensions

Zeplin stylesheet extensions monorepo βš—οΈπŸ–Œ
JavaScript
30
star
13

cli-connect-storybook-plugin

Zeplin CLI plugin to generate Storybook links for Zeplin components
JavaScript
20
star
14

zeplin-workbook

15
star
15

microsoft-teams-app

Bring all the important updates from your Zeplin workspace to the Microsoft Teams conversations.
TypeScript
15
star
16

cli-connect-react-plugin

Zeplin CLI plugin for React components
TypeScript
13
star
17

color-picker

macOS color picker that lets you select colors from the project/styleguide you have open in Zeplin
Swift
9
star
18

cli-connect-swift-plugin

Zeplin CLI plugin for Swift
TypeScript
8
star
19

zeplin-prism-extras

Language extras for Prism ✏️
JavaScript
8
star
20

zeplin-popout-extension

Zeplin Popout tool allows you to compare your code output with Zeplin screens for better design-development workflow.
JavaScript
6
star
21

javascript-sdk

Zeplin API client for JavaScript
TypeScript
6
star
22

cli-connect-angular-plugin

Zeplin CLI plugin for Angular components
TypeScript
3
star
23

community-crew-sdk-scripts

Zeplin Node SDK scripts used by Community Crew
JavaScript
3
star
24

openapi

An OpenAPI description for the Zeplin API
2
star