How to use @storybook/addon-backgrounds - 10 common examples

To help you get started, we’ve selected a few @storybook/addon-backgrounds examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github isuvorov / storybox / sandbox5 / stories / Button.story.jsx View on Github external
boolean, number, text, withKnobs,
} from '@storybook/addon-knobs';

import readme from './README.md';

addDecorator(withKnobs);
addDecorator(withNotes);
addDecorator(
  withOptions({
    name: 'DEMO demo!!@@@',
    url: '#',
    // goFullScreen: true,
  }),
);
addDecorator((storyFn, context) => withConsole()(storyFn)(context));
addDecorator(withBackgrounds([
  { name: 'twitter', value: '#00aced' },
  { name: 'facebook', value: '#3b5998' },
]));

storiesOf('Button', module)

  .add('with text', () => (
    <div>
      <button> console.log(123)}
      &gt;
        console.log(123)
      </button>
      <button> console.log({
          some: { strong: [{ language: 123 }] },</button></div>
github isuvorov / storybox / src / wrapModule.js View on Github external
const createStoriesOf = ({ storybook, React, ...config }) => (...args) => {

  // if (DEBUG) console.log('storiesOf');
  const res = storybook.storiesOf(...args);

  if (config.notes) {
    res.addDecorator(require('@storybook/addon-notes').withNotes);
  }
  if (config.backgrounds) {
    res.addDecorator(require('@storybook/addon-backgrounds').default(config.backgrounds));
  }

  // if (config.info) {
  if (false) {
    res._add = res.add; // eslint-disable-line  no-underscore-dangle
    res.add = (...args2) => {
      if (DEBUG) console.log('res.add');

      if (res.inAdd) {
        return res._add(...args); // eslint-disable-line  no-underscore-dangle
      }
      res.inAdd = true;
      const result = res.addWithInfo ? res.addWithInfo(...args2) : res._add(...args2); // eslint-disable-line  no-underscore-dangle
      res.inAdd = false;
      return result;
    };
github alpcanaydin / githubist / src / components / LanguageCard / LanguageCard.stories.jsx View on Github external
// @flow

import React from 'react';
import { storiesOf } from '@storybook/react';
import backgrounds from '@storybook/addon-backgrounds';
import { MemoryRouter } from 'react-router-dom';

import LanguageCard from './LanguageCard';

storiesOf('LanguageCard', module)
  .addDecorator(backgrounds([{ name: 'light', value: '#fcfafa', default: true }]))
  .add('default', () =&gt; (
    
      <div style="{{">
        
      </div>
    
  ))
  .add('with rank', () =&gt; (
    
      <div style="{{">
        </div>
github alpcanaydin / githubist / src / components / Header / Header.stories.jsx View on Github external
// @flow

import React from 'react';
import { storiesOf } from '@storybook/react';
import backgrounds from '@storybook/addon-backgrounds';
import { MemoryRouter } from 'react-router-dom';
import { MockedProvider } from 'react-apollo/test-utils';

import Header from './Header';

storiesOf('Header', module)
  .addDecorator(backgrounds([{ name: 'dark', value: '#2d2e33', default: true }]))
  .add('default', () =&gt; (
    <div style="{{">
      
        
          <header>
        
      
    </header></div>
  ));
github alpcanaydin / githubist / src / components / DeveloperCard / DeveloperCard.stories.jsx View on Github external
// @flow

import React from 'react';
import { storiesOf } from '@storybook/react';
import backgrounds from '@storybook/addon-backgrounds';
import { MemoryRouter } from 'react-router-dom';

import DeveloperCard from './DeveloperCard';

storiesOf('DeveloperCard', module)
  .addDecorator(backgrounds([{ name: 'light', value: '#fcfafa', default: true }]))
  .add('default', () =&gt; (
    
      <div style="{{">
        
      </div>
    
  ))
github alpcanaydin / githubist / src / components / LocationCard / LocationCard.stories.jsx View on Github external
// @flow

import React from 'react';
import { storiesOf } from '@storybook/react';
import backgrounds from '@storybook/addon-backgrounds';
import { MemoryRouter } from 'react-router-dom';

import LocationCard from './LocationCard';

storiesOf('LocationCard', module)
  .addDecorator(backgrounds([{ name: 'light', value: '#fcfafa', default: true }]))
  .add('default', () =&gt; (
    
      <div style="{{">
        
      </div>
    
  ))
  .add('with rank', () =&gt; (
    
      <div style="{{"></div>
github alpcanaydin / githubist / src / components / LinkBar / LinkBar.stories.jsx View on Github external
// @flow

import React from 'react';
import { storiesOf } from '@storybook/react';
import backgrounds from '@storybook/addon-backgrounds';
import { MemoryRouter } from 'react-router-dom';

import LinkBar from './LinkBar';
import Item from './Item';

storiesOf('LinkBar', module)
  .addDecorator(backgrounds([{ name: 'dark', value: '#2d2e33', default: true }]))
  .add('default', () =&gt; (
    <div style="{{">
      
        
           true}&gt;
            Link 1
          
          Link 2
          Link 3
        
      
    </div>
  ))
  .add('with outside link', () =&gt; (
    <div style="{{">
      </div>
github alpcanaydin / githubist / src / components / RepoCard / RepoCard.stories.jsx View on Github external
// @flow

import React from 'react';
import { storiesOf } from '@storybook/react';
import backgrounds from '@storybook/addon-backgrounds';
import { MemoryRouter } from 'react-router-dom';

import RepoCard from './RepoCard';

storiesOf('RepoCard', module)
  .addDecorator(backgrounds([{ name: 'light', value: '#fcfafa', default: true }]))
  .add('default', () =&gt; (
    
      <div style="{{">
        
      </div>
    
  ))
  .add('with rank', () =&gt; (
    
      <div style="{{"></div>
github s-coimbra21 / react-hextech / .storybook / config.js View on Github external
import React from 'react';
import { configure } from '@storybook/react';
import { setOptions } from '@storybook/addon-options';
import { addDecorator } from '@storybook/react';
import { ThemeProvider } from 'styled-components';
import { withBackgrounds } from '@storybook/addon-backgrounds';
import { checkA11y } from '@storybook/addon-a11y';

import './index.css';
import theme from '../src/theme';

addDecorator(checkA11y);
addDecorator(
  withBackgrounds([
    { name: 'LCU', value: 'var(--lcu-bg)', default: true },
    { name: 'Universe', value: 'var(--universe-bg)' },
    { name: 'twitter', value: '#00aced' },
  ])
);
// addDecorator(
//   withCssResources({
//     cssresources: [
//       // {
//       //   name: 'LCU',
//       //   code: `<style> body {background-image: var(--lcu-bg); } </style>`,
//       //   picked: true,
//       // },
//       {
//         name: 'Universe',
//         code: `<style> body {background-image: url(${require('../src/assets/universe-bg.jpg')}); } </style>`,
github storybookjs / storybook / examples / official-storybook / stories / addon-backgrounds.stories.js View on Github external
],
  })
  .add('disabled via []', () =&gt; , {
    backgrounds: [],
  })
  .add(
    'skipped via disable:true',
    () =&gt; ,
    {
      backgrounds: { disable: true },
    }
  );

storiesOf('Addons|Backgrounds.deprecated', module)
  .addDecorator(
    backgrounds([
      { name: 'twitter', value: '#00aced' },
      { name: 'facebook', value: '#3b5998', default: true },
    ])
  )
  .add('story 1', () =&gt; (
    
  ))
  .add('story 2', () =&gt; )
  .add(
    'overriden',
    backgrounds([
      { name: 'red', value: '#F44336' },
      { name: 'blue', value: '#2196F3', default: true },
    ])(() =&gt; )
  );

@storybook/addon-backgrounds

Switch backgrounds to view components in different settings

MIT
Latest version published 2 days ago

Package Health Score

95 / 100
Full package analysis