Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Socket
Sign inDemoInstall

@storybook/addon-ondevice-backgrounds

Package Overview
Dependencies
Maintainers
10
Versions
460
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@storybook/addon-ondevice-backgrounds

A storybook addon to show different backgrounds for your preview


Version published
Weekly downloads
60K
increased by8.96%
Maintainers
10
Weekly downloads
 
Created
Source

Storybook Addon On Device Backgrounds

Storybook On Device Background Addon can be used to change background colors inside the the simulator in Storybook.

Framework Support

Storybook Addon Backgrounds Demo

Installation

npm i -D @storybook/addon-ondevice-backgrounds

Configuration

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

Add following content to it:

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

Then import rn-addons.js next to your getStorybookUI call.

import './rn-addons';

Usage

Then write your stories like this:

import React from 'react';
import { storiesOf } from '@storybook/react-native';
import { withBackgrounds } from '@storybook/addon-ondevice-backgrounds';

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

You can add the backgrounds to all stories with addDecorator in .storybook/config.js:

import { addDecorator } from '@storybook/react-native'; // <- or your storybook framework
import { withBackgrounds } from '@storybook/addon-ondevice-backgrounds';

addDecorator(
  withBackgrounds([
    { name: 'twitter', value: '#00aced', default: true },
    { name: 'facebook', value: '#3b5998' },
  ])
);

If you want to override backgrounds for a single story or group of stories, pass the backgrounds parameter:

import React from 'react';
import { storiesOf } from '@storybook/react-native';

storiesOf('Button', module)
  .addParameters({
    backgrounds: [
      { name: 'red', value: '#F44336' },
      { name: 'blue', value: '#2196F3', default: true },
    ],
  })
  .add('with text', () => <button>Click me</button>);

If you don't want to use backgrounds for a story, you can set the backgrounds parameter to [], or use { disable: true } to skip the addon:

import React from 'react';
import { storiesOf } from '@storybook/react-native';

storiesOf('Button', module).add('with text', () => <button>Click me</button>, {
  backgrounds: { disable: true },
});

Keywords

FAQs

Package last updated on 22 Oct 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc