All Projects â†’ chrisvxd â†’ Story2sketch

chrisvxd / Story2sketch

Licence: other
Convert Storybook into Sketch symbols 💎

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Story2sketch

Storybook
📓 The UI component explorer. Develop, document, & test React, Vue, Angular, Web Components, Ember, Svelte & more!
Stars: ✭ 67,445 (+17149.36%)
Mutual labels:  styleguide, design-systems, components, storybook
Kit
Tools for developing, documenting, and testing React component libraries
Stars: ✭ 1,201 (+207.16%)
Mutual labels:  styleguide, design-systems, components
Sync.sketchplugin
Keep your design team in sync!
Stars: ✭ 357 (-8.7%)
Mutual labels:  sketch, design-systems
gravity-ui-web
Library of styles, components and associated assets to build UIs for the web. Part of buildit's Gravity design system.
Stars: ✭ 20 (-94.88%)
Mutual labels:  styleguide, design-systems
Figma Html
Convert Figma designs to HTML, React, Vue, Angular, and more!
Stars: ✭ 382 (-2.3%)
Mutual labels:  design-systems, storybook
fyndiq-ui
Library of reusable web frontend components for Fyndiq
Stars: ✭ 39 (-90.03%)
Mutual labels:  design-systems, storybook
sketch wireframing kit
Quick Sketchapp wireframing tool for UK government digital services
Stars: ✭ 74 (-81.07%)
Mutual labels:  design-systems, sketch
design-tokens-plugin
Support end of life! Delivering consistent Design System. A Sketch plugin that exports Design Tokens to JSON format. You can export colors, typography, icons and utilis. A must-have tool for design system project.
Stars: ✭ 100 (-74.42%)
Mutual labels:  design-systems, sketch
shared-react-components-example
An example of a mono-repository of shared React components libraries!
Stars: ✭ 85 (-78.26%)
Mutual labels:  design-systems, storybook
foundational-design-system-proto
A prototype for a foundational design system at Shopify
Stars: ✭ 82 (-79.03%)
Mutual labels:  components, design-systems
papyrum
Papyrum is a tool that will help you in the creation of your design system, style guide or in the documentation of your project based on react
Stars: ✭ 19 (-95.14%)
Mutual labels:  styleguide, design-systems
elements
Lovingly crafted ui components based on web components. Works well with all Frameworks - including Angular, React and Vue.
Stars: ✭ 42 (-89.26%)
Mutual labels:  components, storybook
storybook-addon-blabbr
Component reviewer for React Storybook
Stars: ✭ 13 (-96.68%)
Mutual labels:  design-systems, storybook
storybook-talk
Storybook, the playground you need for your UI components! 🎨
Stars: ✭ 11 (-97.19%)
Mutual labels:  components, storybook
components
Reusable React components used by HospitalRun
Stars: ✭ 109 (-72.12%)
Mutual labels:  components, storybook
awesome-ux-design-styles
Curated list of UX styleguides and design systems
Stars: ✭ 66 (-83.12%)
Mutual labels:  styleguide, design-systems
fast-blazor
Blazor component library for FluentUI. Microsoft's official lightweight wrapper around the FluentUI Web Components for use with .NET 6.0 Blazor applications
Stars: ✭ 928 (+137.34%)
Mutual labels:  components, design-systems
Awesome List
Curated list of links on component-driven development and design systems
Stars: ✭ 271 (-30.69%)
Mutual labels:  design-systems, components
pattern-library
AXA CH UI component library. Please share, comment, create issues and work with us!
Stars: ✭ 103 (-73.66%)
Mutual labels:  styleguide, storybook
salsa
A tool for exporting iOS components into Sketch 📱💎
Stars: ✭ 62 (-84.14%)
Mutual labels:  design-systems, sketch

story2sketch 💎

NPM JavaScript Style Guide

Convert Storybook stories into Sketch symbols.

Uses the amazing html-sketchapp. Only supports web.

Quickstart

Firstly, get Sketch and npm. Then install asketch2sketch.sketchplugin into Sketch:

Installing Sketch plugin

Install story2sketch:

npm i story2sketch -g

Run story2sketch, pointing towards a Storybook iframe URL. You can find an existing iframe URL in Storybook by clicking 'Open canvas in new tab':

Open canvas in new tab

See configuration for more options, or if you have a lot of stories.

story2sketch --url https://localhost:9001/iframe.html --output stories.asketch.json

Import the generated file into Sketch via Plugins > From *Almost* Sketch to Sketch in Sketch menu bar.

Using sketch plugin

Success!

Storybook 3.x

If you're using Storybook 3.3 or above (but not Storybook 4 or above), you'll want to take full control of your Storybook webpack.config.js if you haven't already done so, adding:

module.exports = (storybookBaseConfig, configType) => {
  const newConfig = {
    ...storybookBaseConfig
  };

  // Add this:
  // Export bundles as libraries so we can access them on page scope.
  newConfig.output.library = "[name]";

  return newConfig;
};

Manually export the getStorybook function in your ./config/storybook/config.js file:

import { getStorybook } from "@storybook/react";

...

export { getStorybook }

Run story2sketch:

story2sketch --url https://localhost:9001/iframe.html --output stories.asketch.json

Why?

As stated by react-sketchapp, it's complicated to manage assets in a design system. Many teams building design systems or component libraries already produce Sketch files for distributing designs and use Storybook to prototype and present the developed components. It can become difficult to keep designs up to date with the latest components, with designers ever playing catchup. story2sketch generates a Sketch file from your components via Storybook, so your Sketch designs always stay up to date.

Configuration

You can configure story2sketch using the API via the CLI, configuring your package.json or adding a story2sketch.config.js file.

CLI

Simply call story2sketch with options from the API.

$ story2sketch --stories all --output dist/great-ui.asketch.json

package.json

Add the following to your package.json:

{
  "story2sketch": {
    "stories": "all",
    "output": "dist/great-ui.asketch.json"
  }
}

story2sketch.config.js

Create a file called story2sketch.config.js on the root of your project:

module.exports = {
  output: "dist/great-ui.asketch.json",
  stories: "all"
};

API

Parameter Explanation Input Type Default
output Specifies the filename for the generated asketch.json file or a folder when outputBy === 'kind'. string "dist/stories.asketch.json"
input The location of Storybook's generated iframe.html. Use this over url if possible for performance. string "dist/iframe.html"
url Storybook iframe URL. Will end in iframe.html. Prefer input for performance if possible. string "http://localhost:9001/iframe.html"
stories Stories to extract from Storybook. You should probably override the default. object/string "all"
concurrency Number of headless Chrome tabs to run in parallel. Defaults to number of threads available on your machine. integer dynamic
symbolGutter Gutter to place between symbols in Sketch. integer 100
viewports Viewport configuration. Will be arranged left-to-right by width. Try to avoid changing the key, as this is used to identify the symbol. object Mobile viewport (320px wide) and desktop viewport (1920px wide). See example below.
querySelector Query selector to select your node on each page. Uses document.querySelectorAll. string "#root"
verbose Verbose logging output. boolean false
fixPseudo Attempt to insert real elements in place of pseudo-elements boolean false
puppeteerOptions Options to be passed directly to puppeteer.launch. See puppeteer docs for usage. object {}
removePreviewMargin Remove preview margin from the iframe body. boolean true
layoutBy Group symbols in the sketch output by the "kind" or "group" key "kind" | "group" null
outputBy Write multiple sketch files by "kind" or the "group" key "kind" | "group" null

Example configurations

Basic

Automatically detect the stories, outputting two viewports for each story in a single Sketch file as symbols.

module.exports = {
  output: "dist/great-ui.asketch.json",
  input: "dist/iframe.html", // Same as default
  pageTitle: "great-ui"
};

Manual stories

Manually define stories to have granular control over what stories are output. This might help if you're getting empty output, since some stories may break story2sketch.

module.exports = {
  stories: [
    {
      kind: "Buttons/Button",
      stories: [
        {
          name: "Button"
        }
      ]
    },
    {
      kind: "Buttons/ButtonGroup",
      stories: [
        {
          name: "Default",
          displayName: "Horizontal"
        },
        {
          name: "Vertical"
        }
      ]
    },
    {
      kind: "Table",
      stories: [
        {
          name: "Table"
        }
      ]
    }
  ]
};

Custom viewports

Output symbols based on custom viewports:

module.exports = {
  viewports: {
    narrow: {
      width: 320,
      height: 1200,
      symbolPrefix: "Mobile/"
    },
    standard: {
      width: 1920,
      height: 1200,
      symbolPrefix: "Desktop/"
    }
  }
};

Split output into multiple files based on kind

Outputs one file for each Storybook "kind". Useful if managing large component libraries, allowing you to distribute smaller files.

module.exports = {
  output: "dist", // Define output directory. File names are defined by "kind"
  outputBy: "kind" // Also supports "group", see below.
};

Layout based on kind

Renders the sketch layout by kind, but keeps them in one file.

module.exports = {
  layoutBy: "kind" // Also supports "group", see below.
};

Split output into multiple files based on custom group

This example outputs two files based on a custom grouping: dist/Buttons.asketch.json and dist/Data.asketch.json.

module.exports = {
  output: "dist",
  outputBy: "group",
  stories: [
    {
      group: "Buttons",
      kind: "Buttons/Button",
      stories: [
        {
          name: "Button"
        }
      ]
    },
    {
      group: "Buttons",
      kind: "Buttons/ButtonGroup",
      stories: [
        {
          name: "Default",
          displayName: "Horizontal"
        },
        {
          name: "Vertical"
        }
      ]
    },
    {
      group: "Data",
      kind: "Table",
      stories: [
        {
          name: "Table"
        }
      ]
    }
  ]
};

Continuous Integration

If you want story2sketch to run in a CI environment you might have to add the following configuration to puppeteer in your story2sketch.config.js.

module.exports = {
  puppeteerOptions: {
    args: ['--no-sandbox', '--disable-setuid-sandbox']
  },
  ...
};

Questions

Why does my stuff look bad?

If your stuff looks bad, either it's not supported by html-sketchapp yet (see support here), or you need to configure story2sketch.

Why don't you use react-sketchapp instead of html-sketchapp?

react-sketchapp only supports React Native, or forces you to use React Native component naming conventions. html-sketchapp supports good ol' fashioned HTML, and doesn't care what web framework you're using.

Can I use this on anything other than Storybook?

Not yet, but we have plans to add support for multiple and custom adaptors.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].