Coder Social home page Coder Social logo

storybook-addon-versions's Introduction

storybook-addon-versions

This addon allows you to navigate different versions of your components, if you have a setup that produces a different static Storybook build for each of your versions. As such, if you build a static Storybook and host it in, say, the following directory structure:

- static-storybook
|-- 0.0.1
|-- 0.0.2
|-- 0.1.2
|-- 0.2.5

the addon will allow you to navigate the various versions via the Versions panel:

Versions demo

Configuration

The addon attempts to get a list of available style guide versions from the root of your host. If they are found it will show a dropdown which then lets you navigate to the various versions, as such allowing users to see how a component may have changed over different versions.

The versions are expected to be in a configuration file storybook-config.json at the root of your host. You can also mock this in local dev by adding a storybook-config.json in your local .storybook/ folder. Here's some sample content:

{
  "storybook": {
    "versions": {
      "availableVersions": [
        "0.0.1",
        "0.0.2",
        "0.1.2",
        "0.2.5"
      ],
      "hostname": "localhost:8000",
      "localhost": "localhost:9001",
      "regex": "\/([^\/]+?)\/?$"
    }
  }
}

The options are:

  • availableVersions: An array of available versions.
  • hostname: The hostname of where the static builds are. For now you need to add the path if you are expecting links to work in a local dev build but not in your normal hosted config.
  • localhost: Where the local dev build is, when running in dev mode
  • regex: This is for a regular expression that will extract the version number for your URL. This is dependant on the way you store the static storybook builds. The example above will work for the format http://localhost:port/<version>/ so for example, version 0.1.2 would be expected to be found like this http://mystorybook/0.1.2/.

The config format is the same as for blabbr.

storybook-addon-versions's People

Contributors

orir avatar panosvoudouris avatar shahzainb avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

storybook-addon-versions's Issues

dev flag not working properly

When reloading a page after the dev flag is enabled it gets out of sync and needs pressing 3 times to start responding correctly.

Add versions into a panel

We can add the versions into a panel vs just the decorator. We should explore what other things we may be able to add in the panel (eg dev options?).

When no host provided just pickup current hostname

The config is expected to include the correct hostname. This is problematic as you may want to just pick up the current hostname serving the app. This way you can have a single config for different environments.

Question: Version per component

Hello.

I'm wondering if this plugin can be used to add documentation for different versions on a per-component basis (i.e. Button v1 v2 v3, Accordion v1.5 v2.2) or if all the components would share version numbers (i.e. Button v1 v2 v3, Accordion v1 v2 v3)? If it can be done per component, how would the version differences be specified?

Add command-line utility for adding new versions to config file

Presumably, whatever CI/CD setup people have to build and host per-version StoryBook instances needs to fill in the list of available versions in storybook-config.json.

Not a big deal, I know, but nonetheless would it be worth including a command-line script (maybe something that goes into node_modules/.bin/ when you NPM install) that automates it somehow?

E.g. something like

$ storybook-versions add

...could read the current project's version from package.json and append it to the list of available versions in the config file.

Then, it would easier for people to automate this in their builds.

Unable to use this addon with Storybook v5

Hi, I'm trying to use this addon with Storybook v5, but there's an error loading the styles, when running start-storybook.

ModuleParseError: Module parse failed: Unexpected token (1:0)
You may need an appropriate loader to handle this file type.
> .versions-panel-container {
|   width: 100%;
|   font-family: -apple-system, ".SFNSText-Regular", "San Francisco",
    at handleParseError (/Users/daniel/Dev/dimebox/storybook-test/node_modules/webpack/lib/NormalModule.js:448:19)
    at doBuild.err (/Users/daniel/Dev/dimebox/storybook-test/node_modules/webpack/lib/NormalModule.js:482:5)
    at runLoaders (/Users/daniel/Dev/dimebox/storybook-test/node_modules/webpack/lib/NormalModule.js:343:12)
    at /Users/daniel/Dev/dimebox/storybook-test/node_modules/loader-runner/lib/LoaderRunner.js:373:3
    at iterateNormalLoaders (/Users/daniel/Dev/dimebox/storybook-test/node_modules/loader-runner/lib/LoaderRunner.js:214:10)
    at Array.<anonymous> (/Users/daniel/Dev/dimebox/storybook-test/node_modules/loader-runner/lib/LoaderRunner.js:205:4)
    at Storage.finished (/Users/daniel/Dev/dimebox/storybook-test/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:43:16)
    at provider (/Users/daniel/Dev/dimebox/storybook-test/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:79:9)
    at /Users/daniel/Dev/dimebox/storybook-test/node_modules/graceful-fs/graceful-fs.js:90:16
    at FSReqWrap.readFileAfterClose [as oncomplete] (internal/fs/read_file_context.js:53:3)

Link to versions in dev

Would be good to be able to navigate to deployed versions even when in local dev mode. However, how do we get back to local?

Links don't track story

The version links do not track the current story. The links are generated when the page first loads and do not update as stories change, as such when the user clicks they get taken to the right version but whatever story was loaded when they first entered the currently viewed version.

Versions tab overlaps other tabs

As title states, the content of the versions tab is shown under the content of the other tabs. This can be seen on the screenshot.

image

UI improvement

How should the different versions be listed. Just a dropbox? Should it be moved to the right or somewhere else? What happens with other addons with decorators (eg info addon).

Storybook v4 support

I managed to migrate my current [email protected] to [email protected] and the only thing that's broken is this addon.

When I remove this addon (mostly) everything works as expected.

When I keep this addon I get an error message in the browser Cannot GET /.

Are there any plans to support v4? I know they're also working hard on v5 now - but that's mostly a UI overhaul.

Hosting storybook using Github Pages

I'm using storybook and I'm hosting it in my Github (enterprise) Pages.
The url goes something like this https://pages.<enterprise-domain>/<org>/<repo>/<version> which means that at best I can only put the configuration file here https://pages.<enterprise-domain>/<org>/<repo>/storybook-config.json and not at the root here https://pages.<enterprise-domain>/ as described in the docs.

Is there a way to support something like this? arbitrary location for the configuration file?
even one step further, avoid the configuration file altogether and have this configuration defined in the code via a configurator function or something similar?

Vue support

Hello, our team would love to use this. Are there any plans of supporting Vue?
Haven't tested it myself yet, but thought I'd ask if you know of any known bugs.

Best,
andreas

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.