2.0.6 • Published 5 months ago

@lullabot/storybook-drupal-addon v2.0.6

Weekly downloads
-
License
MIT
Repository
github
Last release
5 months ago

Drupal Storybook Addon

A library for best-practice Drupal integration addons in Storybook:

  • Easy-to-use locale configuration
  • Simple drop-down menu
  • URL-linkable state for sharing

Screenshot

Addon authors

As an addon author, you can use this library by adding it as a dependency and adding the following to your /preset.js file:

function config(entry = []) {
  return [
    ...entry,
    require.resolve('@lullabot/storybook-drupal-addon/preview'), // <-- library's preview preset
    require.resolve('./dist/esm/preset/preview'), // <-- your addon's preview preset (if present)
  ];
}

function managerEntries(entry = []) {
  return [
    ...entry,
    require.resolve('@lullabot/storybook-drupal-addon/manager'),
    require.resolve('./dist/esm/preset/manager'), // <-- your addon's manager (if present)
  ];
}

module.exports = {config, managerEntries};

The currently selected theme is available in the drupalTheme global, so you can access it in a decorator using the following snippet:

import { MyProvider } from 'your-drupal-library';
import { useGlobals } from '@storybook/client-api';

const myDecorator = (story, context) => {
  const [{drupalTheme}] = useGlobals();
  return <MyProvider theme={drupalTheme}>;
};

End users

End users configure the supportedDrupalThemes and drupalTheme parameters in .storybook/preview.js.

supportedDrupalThemes is an object where the keys are the machine name of the Drupal themes and the values are the plain text name of that Drupal theme you want to use. This is what will appear in the dropdown in the toolbar.

export const parameters = {
  drupalTheme: 'umami',
  supportedDrupalThemes: {
    umami: {title: 'Umami'},
    bartik: {title: 'Bartik'},
    claro: {title: 'Claro'},
    seven: {title: 'Seven'},
  }
};
2.0.3

6 months ago

2.0.2

8 months ago

2.0.5

6 months ago

2.0.4

6 months ago

2.0.6

6 months ago

2.0.1

11 months ago

2.0.0

11 months ago

1.0.28

11 months ago

1.0.27

1 year ago

1.0.26

2 years ago

1.0.25

2 years ago

1.0.24

2 years ago

1.0.23

2 years ago

1.0.22

2 years ago

1.0.21

2 years ago

1.0.20

2 years ago

1.0.19

2 years ago

1.0.18

2 years ago

1.0.17

2 years ago

1.0.16

2 years ago

1.0.11

2 years ago

1.0.15

2 years ago

1.0.14

2 years ago

1.0.13

2 years ago

1.0.12

2 years ago

1.0.10

2 years ago

1.0.9

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago