GithubHelp home page GithubHelp logo

storybook-eol / addon-backgrounds Goto Github PK

View Code? Open in Web Editor NEW
74.0 24.0 9.0 4.02 MB

REPO/PACKAGE MOVED - A Storybook addon to customize the background of your preview

Home Page: https://github.com/storybooks/storybook/tree/master/addons/background

License: MIT License

JavaScript 100.00%
storybook react vue development-tools addon-backgrounds background

addon-backgrounds's Introduction

addon-backgrounds

Build Status

React Storybook Screenshot

Getting Started

npm i --save @storybook/addon-backgrounds

Then create a file called addons.js in your storybook config.

Add following content to it:

import '@storybook/addon-backgrounds/register';

Then write your stories like this:

import React from 'react';
import { storiesOf } from "@storybook/react";
import backgrounds from "@storybook/addon-backgrounds";

storiesOf("Button", module)
  .addDecorator(backgrounds([
    { name: "twitter", value: "#00aced", default: true },
    { name: "facebook", value: "#3b5998" },
  ]))
  .add("with text", () => <button>Click me</button>);

Development

This project is built using typescript and is tested with jest. To get started, clone this repo and run the following command:

$ npm install # install node deps

To run the project locally, run:

$ npm run storybook # for storybook testing
# (coming soon) $ npm run test-watch # for testing

To test the project run:

$ npm test

addon-backgrounds's People

Contributors

chris-verclytte avatar coobaha avatar edolyne avatar jakedawkins avatar ndelangen avatar psimyn 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  avatar  avatar  avatar

Watchers

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

addon-backgrounds's Issues

Is this project maintained?

I'm not sure if this package is still maintained, Do you need help?

I'm happy to integrate this into the storybook monorepo if you'd like?

There's a 3.0.0 release coming, and I'd like to make sure addons are maintained, we're willing to help where we can!

Can you join us in the storybook slack?
https://storybooks-slackin.herokuapp.com/

That way we can keep you updated on the upcoming 3.0.0 release!

โค๏ธ storybook team

Default bg should be the initial one to show

Right now, the default key prevents the default swatch from showing up.

I would think it makes more sense to have default: true make whatever background it is on be the first background to load.

Storybook 3.0 support

Hey there! Love this Storybook addon. Unfortunately, I'm running into some problems when upgrading to Storybook 3.0.

Here are the errors from my Webpack build:

ERROR in ./~/react-storybook-addon-backgrounds/dist/register.js
Module not found: Error: Can't resolve '@kadira/storybook-addons' in '/Users/mrayzis/projects/mls/ui-packages/packages/react-components/node_modules/react-storybook-addon-backgrounds/dist'
 @ ./~/react-storybook-addon-backgrounds/dist/register.js 3:25-60
 @ ./~/react-storybook-addon-backgrounds/register.js
 @ ./.storybook/addons.js
 @ multi ./.storybook/addons.js ./~/@storybook/react/dist/server/config/polyfills.js ./~/@storybook/react/dist/client/manager/index.js

ERROR in ./~/react-storybook-addon-backgrounds/dist/index.js
Module not found: Error: Can't resolve '@kadira/storybook-addons' in '/Users/mrayzis/projects/mls/ui-packages/packages/react-components/node_modules/react-storybook-addon-backgrounds/dist'
 @ ./~/react-storybook-addon-backgrounds/dist/index.js 8:25-60
 @ ./stories/match-extensions.js
 @ ./stories \.js$
 @ ./.storybook/config.js
 @ multi ./~/@storybook/react/dist/server/config/polyfills.js ./~/@storybook/react/dist/server/config/globals.js (webpack)-hot-middleware/client.js?reload=true ./.storybook/config.js

To fix it, I think you just have to rename the packages from @kadira to their new namespace @storybook as outlined in the migration guide. Thanks!

Feature request: Improve background transition effect and swatch value output

I love this Storybook addon, and I would like to make a feature request...

I'm using the background addon as follows:

storiesOf('MyComponent', module)
    .addDecorator(backgrounds([
        {
            name: 'Cape Town',
            value: 'url(cape-town.jpg) no-repeat center center',
            default: true,
        },
        { name: 'None', value: 'transparent' },
        { name: 'Light Blue', value: 'lightblue' },
        { name: 'Gray', value: 'lightgray' },
        {
            name: 'Stripey',
            value: 'repeating-linear-gradient(45deg, #606dbc, #606dbc 10px, #465298 10px, #465298 20px )',
        },
    ]))
    .add('MyComponent', () => (
        <MyComponent />
    ));

With the above, I can for set a background image, or pin stripe background image using repeating gradients as a background.

However, with the center center on background, the transition makes switching from background to background rather weird. Maybe transition should be set to background-color only, as it tries to sort of swoop into its location? Perhaps add a param to turn the transition on/off.

Another observation I have made, is that the Swatch panel shows all the CSS for the given swatch item next to the name, so in my example above, for the 'Stripey' background I can see the entire CSS snippet output next to the name, and due to it wrapping, it looks rather ugly.

Take a peek at the attached image.

screen shot 2017-08-28 at 4 49 38 pm

React warning

Hi,

When using this addon I get the following warning, is this normal?

Warning: Failed prop type: Invalid prop `context` of type `function` supplied to `Story`, expected `object`.

Not showing Background tab

Hi,
I just install the addon following the instructions on readme but nothing is happening, not even an error.

    "react": "15.0.1",
    "@kadira/storybook": "^2.21.0"
    "react-storybook-addon-backgrounds": "0.0.4",

rename to storybook-addon-backgrounds

Hey there!

Maintainer of storybook here, I find this addon pretty cool, perhaps you'd like it to become part of the core some day?
I'm building a mono-repo which will allow us to to better releases, and I'd welcome your team and repo!

I was hoping you'd be interested and possibly rename the package to storybook-addon-backgrounds. Perhaps one day we could autoload addons which are installed, and a common naming scheme would help with that ๐Ÿ‘ .

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.