How to use the @storybook/addons.addons.register 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 / addons / cssresources / src / register.tsx View on Github external
import React from 'react';
import { addons, types } from '@storybook/addons';

import { ADDON_ID, PANEL_ID, PARAM_KEY } from './constants';
import { CssResourcePanel } from './css-resource-panel';

addons.register(ADDON_ID, api => {
  // Need to cast as any as it's not matching Addon type, to investigate
  addons.add(PANEL_ID, {
    type: types.PANEL,
    title: 'CSS resources',
    render: ({ active }) => ,
    paramKey: PARAM_KEY,
  });
});
github storybookjs / storybook / addons / live-edit / src / register.tsx View on Github external
import React from 'react';
import { addons, types } from '@storybook/addons';
import { AddonPanel } from '@storybook/components';

import Editor from './Editor';
import { API } from '@storybook/api';

// @ts-ignore
addons.register('editor', (api: API) => {
  addons.add('editor', {
    type: types.PANEL,
    title: 'editor',
    paramKey: 'storysource',
    render: ({ active, key}) => {
      return (
        
          
        
      );
    },
  });
});
github petyosi / react-virtuoso / .storybook / ga.js View on Github external
import { addons } from '@storybook/addons'
import { STORY_CHANGED, STORY_ERRORED, STORY_MISSING } from '@storybook/core-events'

import ReactGA from 'react-ga'

addons.register('storybook/google-analytics', api => {
  ReactGA.initialize('UA-140068800-1')

  api.on(STORY_CHANGED, () => {
    const { path } = api.getUrlState()
    ReactGA.pageview(path)
  })
  api.on(STORY_ERRORED, ({ description }) => {
    ReactGA.exception({
      description,
      fatal: true,
    })
  })
})
github storybookjs / storybook / addons / a11y / src / register.tsx View on Github external
/>
          
          
        
      
    
  
);

addons.register(ADDON_ID, api => {
  addons.add(PANEL_ID, {
    title: '',
    type: types.TOOL,
    match: ({ viewMode }) => viewMode === 'story',
    render: () => ,
  });

  addons.add(PANEL_ID, {
    title: 'Accessibility',
    type: types.PANEL,
    render: ({ active, key }) => ,
  });

  addons.add(PANEL_ID, {
    title: '',
    type: types.PREVIEW,
github storybookjs / storybook / addons / docs / src / register.ts View on Github external
import { addons, types } from '@storybook/addons';
import { ADDON_ID, PANEL_ID } from './shared';

addons.register(ADDON_ID, () => {
  addons.add(PANEL_ID, {
    type: types.TAB,
    title: 'Docs',
    route: ({ storyId }) => `/docs/${storyId}`,
    match: ({ viewMode }) => viewMode === 'docs',
    render: () => null,
  });
});
github storybookjs / storybook / addons / graphql / src / register.js View on Github external
export function register() {
  addons.register(ADDON_ID, () => {
    addons.add(ADDON_ID, {
      title: 'GraphiQL',
      type: types.TAB,
      route: ({ storyId }) => `/graphql/${storyId}`,
      match: ({ viewMode }) => viewMode === 'graphql',
      render: GQL,
    });
  });
}
github storybookjs / storybook / addons / design-assets / src / register.tsx View on Github external
import * as React from 'react';

import { addons, types } from '@storybook/addons';
import { AddonPanel } from '@storybook/components';
import { ADDON_ID, PANEL_ID, PARAM_KEY } from './constants';
import { Panel } from './panel';

addons.register(ADDON_ID, () => {
  addons.add(PANEL_ID, {
    title: 'design assets',
    type: types.PANEL,
    render: ({ active, key }) => (
      
        
      
    ),
    paramKey: PARAM_KEY,
  });
});
github storybookjs / storybook / dev-kits / addon-parameter / src / register.tsx View on Github external
const results = useParameter(PARAM_KEY, []);

  return useMemo(
    () =>
      results.length ? (
        <ol>
          {results.map((i: string) =&gt; (
            <li>{i}</li>
          ))}
        </ol>
      ) : null,
    [results]
  );
};

addons.register(ADDON_ID, () =&gt; {
  addons.add(PANEL_ID, {
    title: 'parameter',
    type: types.PANEL,
    render: ({ active, key }) =&gt; (
      
        <content>
      </content>
    ),
  });
});
github storybookjs / addon-jsx / src / register.tsx View on Github external
import { ADDON_ID, ADDON_PANEL, EVENTS } from './constants';

export interface Listener {
  next(
    scope: 'current' | 'jsx'
  ): typeof scope extends 'current'
    ? (id: string) =&gt; void
    : (id: string, jsx: string) =&gt; void;
}

const Observable = (channel: Channel, api: any) =&gt; (listener: Listener) =&gt; {
  channel.on(EVENTS.ADD_JSX, listener.next('jsx'));
  api.on(STORY_RENDERED, listener.next('current'));
};

addons.register(ADDON_ID, api =&gt; {
  const ob = Observable(addons.getChannel(), api);

  addons.addPanel(ADDON_PANEL, {
    title: 'JSX',
    render: ({ active }) =&gt; 
  });
});
github storybookjs / storybook / addons / a11y / src / register.tsx View on Github external
/&gt;
          
          
        
      
    
  
);

addons.register(ADDON_ID, api =&gt; {
  addons.add(PANEL_ID, {
    title: '',
    type: types.TOOL,
    match: ({ viewMode }) =&gt; viewMode === 'story',
    render: () =&gt; ,
  });

  addons.add(PANEL_ID, {
    title: 'Accessibility',
    type: types.PANEL,
    render: ({ active, key }) =&gt; ,
    paramKey: PARAM_KEY,
  });

  addons.add(PANEL_ID, {
    title: '',