GithubHelp home page GithubHelp logo

impekable / storybook-addon-figma Goto Github PK

View Code? Open in Web Editor NEW

This project forked from swapkats/storybook-addon-figma

0.0 0.0 0.0 4.96 MB

Embed Figma designs in a storybook panel

JavaScript 100.00%

storybook-addon-figma's Introduction

storybook-addon-figma

Storybook Addon For Figma

Live Demo: https://swapkats.github.io/storybook-addon-figma

Quickstart

Install the addon

npm i --save-dev storybook-figma

Register the plugin

// in .storybook/addons.js
import '@storybook/addon-actions/register'
// register the Figma addon
import 'storybook-figma/register'

Link a Figma design to your story

import React from 'react'
import { storiesOf } from '@storybook/react'
import { WithFigma } from 'storybook-figma'

storiesOf('Button')
  .add('With Figma', () => (
    <WithFigma
      url={'https://www.figma.com/file/LbcvMJxDtshDmYtdyfJfkA72/Button-Primary'}
    >
      <button>My Button</button>
    </WithFigma>
  ))

Embed a different design on each story

import React from 'react'
import { storiesOf } from '@storybook/react'
import { WithFigma } from 'storybook-figma'

storiesOf('Button')
  .add('primary', () => (
    <WithFigma
      url={'https://www.figma.com/file/LbcvMJxDtshDmYtdyfJfkA72/Button-Primary'}
    >
      <button>My Button</button>
    </WithFigma>
  ))
  .add('secondary', () => (
    <WithFigma
      url={'https://www.figma.com/file/LbcvMJxDtshDmYtdyfJfkA72/Button-Secondary'}
    >
      <button>My Secondary Button</button>
    </WithFigma>
  ))

Or use the decorator to put the same design on each story

import React from 'react'
import { storiesOf } from '@storybook/react'
import figmaDecorator from 'storybook-figma'
import App from './components/App'

storiesOf('App')
  .addDecorator(figmaDecorator({
    url: 'https://www.figma.com/file/LKQ4FJ4bTnCSjedbRpk931/Sample-File',
  }))
  .add('My App', () => (
    <App />
  ))

Show Figma design in right panel

If you find that the Figma panel at the bottom is not big enough to fit your designs, it is possible to move the panel to the right of the window instead, where it is possible to give it more space. This requires the @storybook/addons-options addon. Note however that it is only possible to do this for all stories at once, and will move all addon panels to the right. A simple setup is shown here.

Install the addon

npm install --save-dev @storybook/addon-options

Register the options addon in your addons.js

// in .storybook/addons.js
import '@storybook/addon-actions/register'
import 'storybook-figma/register'
// register the options addon
import '@storybook/addon-options/register';

Import and use the setOptions function in your config.js file

// in .storybook/config.js
import * as storybook from '@storybook/react';
// import the options function
import { setOptions } from '@storybook/addon-options';

// set option to show panel in right side
setOptions({
  downPanelInRight: true,
});

storybook.configure(() => require('./stories'), module);

storybook-addon-figma's People

Contributors

hharnisc avatar swapkats avatar bcomerford avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.