How to use the @storybook/addons.getElements function in @storybook/addons

To help you get started, we’ve selected a few @storybook/addons 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 storybookjs / storybook / app / react-native / src / preview / components / OnDeviceUI / addons / index.js View on Github external
constructor() {
    super();

    addons.loadAddons({});
    this.panels = addons.getElements('panel');

    this.state = {
      addonSelected: Object.keys(this.panels)[0] || null,
    };
  }
github storybookjs / storybook / lib / ui / src / app.stories.js View on Github external
getElements(type) {
    return addons.getElements(type);
  }
github storybookjs / storybook / app / react-native / src / preview / components / OnDeviceUI / addons / index.tsx View on Github external
import AddonWrapper from './wrapper';
import { Label } from '../../Shared/text';

const NoAddonContainer = styled.View({
  flex: 1,
  alignItems: 'center',
  justifyContent: 'center',
});

const Container = styled.View(({ theme }) => ({
  flex: 1,
  backgroundColor: theme.backgroundColor,
}));

export default class Addons extends PureComponent<{}, { addonSelected: string }> {
  panels = addons.getElements('panel');

  constructor(props: {}) {
    super(props);

    this.state = {
      addonSelected: Object.keys(this.panels)[0] || null,
    };
  }

  onPressAddon = (addonSelected: string) => {
    this.setState({ addonSelected });
  };

  render() {
    const { addonSelected } = this.state;