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

@locofy/storybook-addon

v0.3.6

Published

Export Storybook components to Locofy

Downloads

930

Readme

Bring your Storybook components to Locofy

With Storybook integration, you can now bring your own components from Storybook into the Locofy Plugin. Simply drag and drop the components into your design file, then get a live preview and export code for it.

What is Storybook?

Storybook is a tool that allows development teams to document and manage their UI system. After writing code for your component (eg. a button), Storybook lets you easily display that component in different states and configurations. (eg. warning, pressed, disabled, etc)

Each configuration is called a “Story” and you can further toggle different properties to see different variations of the component.

This helps developers and designers to easily manage and visualise all the components and variations, without needing to run any code.

Using your Storybook components in Locofy

Now with Storybook integration, the components and variations that you’ve set up in your Storybook can be used from the Locofy plugin drag & drop widget.

  1. Ensure that you’ve connected your Storybook with Locofy. To learn how to set up the integration, view the “Setting up” section.
  2. Once you’re connected, you’ll see the pink Storybook icon in the top left corner of the Drag & Drop Pre-built Component widget. Click on the Storybook icon.

Running your exported code

The generated code is written to run using your own code components, hence after exporting, you will need to ensure that your components are imported as dependencies to run the code. Here are the steps to do so:

  1. Unzip the downloaded file
  2. Copy the exported code and assets into your existing repository
  3. Ensure that required packages are imported. Locofy adds todos to remind you to import your code components that are being used. Screenshot
  4. You can now run your project.

Setting up: Bring your Storybook components to Locofy

Here’s how to connect your Storybook with Locofy and bring your components into the Locofy plugin.

  1. In the Drag & Drop widget, select the “+ Add Storybook” icon
  1. You will be shown a personal Access Token and steps to install the Locofy Addon for your storybook. Ensure that you have copied the token for later use.

  2. Now, get the Locofy Storybook Addon by installing the package in your repository

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

    OR

     yarn add -D @locofy/storybook-addon
  3. Once the package has been installed, you will need to register the addon in .storybook/main.js

    module.exports = {
       stories: [],
       addons: [
       // Other Storybook addons
          '@locofy/storybook-addon', //👈 The addon registered here
       ,
    }; `
  4. Finally, you’ll need to add an environment variable called STORYBOOK_LOCOFY_TOKEN to store the access token you had copied earlier in Step 2. If your repository does not have an existing .env file, you can create a new one in the root of your project:

Screenshot

  1. You’ve successfully installed the Locofy addon. Upon running Storybook, you should see the Locofy icon added as a new item in the Addons bar Screenshot

  2. Click on the Locofy addon to export your selected components to the Locofy Plugin.

  1. You’re done! You can now drag and drop these components from the Locofy Plugin onto your design and export code that uses your own code components.

Requirements and Limitations

Supported Frameworks

The Locofy Storybook addon currently supports React components. Support for components from other frameworks is coming soon.

Structuring your Storybook code

Please ensure that your Storybook is structured in the following way:

  • Component names must be unique.
  • Each story should contain a single example of the component. Avoid including documentations as well as multiple examples in a single story.
  • The customisable props and their argTypes must be exposed to Storybook. View the Storybook documentation on writing args here.

Limitations

These are the current limitations for the addon:

  • Exported component should not contain any children components.
  • The following argTypes controls are currently not supported:
    • object
    • file