How to use @open-wc/storybook - 10 common examples

To help you get started, we’ve selected a few @open-wc/storybook 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 open-wc / open-wc / packages / generator-open-wc / generators / scaffold-demoing / templates / static / stories / example.stories.js View on Github external
el.foo = 'bar';
    el.addEventListener('click', e => alert(e.target.foo));
    return el;
  })
  .add('lit-html', () => html`
    <button> alert(e.target.foo)}&gt;click me</button>
  `);


const globalParameter = 'globalParameter';
const chapterParameter = 'chapterParameter';
const storyParameter = 'storyParameter';

addParameters({ globalParameter });

storiesOf('Core|Parameters', module)
  .addParameters({ chapterParameter })
  .add('passed to story', ({ parameters: { fileName, ...parameters } }) =&gt; `
    <div>Parameters are ${JSON.stringify(parameters)}</div>
  `, {
    storyParameter,
  });

// disable until https://github.com/storybooks/storybook/issues/4321 is resolved
// storiesOf('Addon|Knobs', module)
//   .addDecorator(withKnobs)
//   .add('button label', () =&gt; html`
//     <button>${text('Button label', 'You can change me in the tab KNOBS')}</button>
//   `)
//   .add('complex', () =&gt; {
//     const name = text('Name', 'Jane');
//     const stock = number('Stock', 20, {
github open-wc / open-wc / packages / generator-open-wc / generators / scaffold-demoing / templates / static / stories / example.stories.js View on Github external
withBackgrounds,
  withNotes,
  document,
  // disable until https://github.com/storybooks/storybook/issues/4321 is resolved
  // withKnobs,
  // text,
  // button,
  // number,
  // select,
  // date,
  // color,
  // array,
  // boolean,
} from '@open-wc/storybook';

storiesOf('Addon|Actions', module)
  .add('Action only', () =&gt; html`
    <button>click me</button>
  `)
  .add('Action and method', () =&gt; html`
    <button> action('log2')(e.target)}&gt;click me</button>
  `);


storiesOf('Addon|Links', module)
  .add('To Welcome', () =&gt; html`
    <button>Go to welcome</button>
  `);


storiesOf('Addon|Backgrounds', module)
  .addDecorator(
github open-wc / open-wc / packages / generator-open-wc / generators / scaffold-demoing / templates / static / stories / example.stories.js View on Github external
// date,
  // color,
  // array,
  // boolean,
} from '@open-wc/storybook';

storiesOf('Addon|Actions', module)
  .add('Action only', () =&gt; html`
    <button>click me</button>
  `)
  .add('Action and method', () =&gt; html`
    <button> action('log2')(e.target)}&gt;click me</button>
  `);


storiesOf('Addon|Links', module)
  .add('To Welcome', () =&gt; html`
    <button>Go to welcome</button>
  `);


storiesOf('Addon|Backgrounds', module)
  .addDecorator(
    withBackgrounds([
      { name: 'twitter', value: '#00aced', default: true },
      { name: 'facebook', value: '#3b5998' },
    ]),
  )
  .add('Button with text', () =&gt; `
    <button>Click me</button>
    <p>See tab "Backgrounds" at the bottom</p>
  `);
github open-wc / open-wc / packages / generator-open-wc / generators / publish-storybook / templates / static / stories / index.stories.options.js View on Github external
import { unsafeStatic } from '@open-wc/storybook';

// eslint-disable-next-line import/no-mutable-exports
export let opts = {
  tag: unsafeStatic('&lt;%= tagName %&gt;'),
  header: '&lt;&lt;%= tagName %&gt;&gt;',
};

export function setOptions(newOptions) {
  opts = newOptions;
}
github open-wc / example-vanilla-set-game / stories / index.stories.js View on Github external
import { storiesOf, html } from '@open-wc/storybook';

import '../set-game.js';
import { generateDeck, generateCard } from '../helpers';

storiesOf('Set Game', module)
  .add(
    'Welcome',
    () =&gt; html`
      <h1>Welcome the Set Game</h1>
      <p>
        It's a demo project showing everything
        <a href="http://open-wc.org">open-wc</a> has to offer
      </p>
      <p>
        Using open-wc's generators and guidelines creating something like this should be a peace of
        cake
      </p>
      <p>This includes:</p>
      <ul>
        <li>Code Quality</li>
        <li>Testing</li></ul>
github open-wc / open-wc / packages / generator-open-wc / generators / scaffold-demoing / templates / static / stories / example.stories.js View on Github external
storiesOf('Addon|Actions', module)
  .add('Action only', () =&gt; html`
    <button>click me</button>
  `)
  .add('Action and method', () =&gt; html`
    <button> action('log2')(e.target)}&gt;click me</button>
  `);


storiesOf('Addon|Links', module)
  .add('To Welcome', () =&gt; html`
    <button>Go to welcome</button>
  `);


storiesOf('Addon|Backgrounds', module)
  .addDecorator(
    withBackgrounds([
      { name: 'twitter', value: '#00aced', default: true },
      { name: 'facebook', value: '#3b5998' },
    ]),
  )
  .add('Button with text', () =&gt; `
    <button>Click me</button>
    <p>See tab "Backgrounds" at the bottom</p>
  `);


storiesOf('Addon|Notes', module)
  .addDecorator(withNotes)
  .add('Simple note', () =&gt; `
    <p><strong>See tab "notes" at the bottom.</strong></p>
github open-wc / open-wc / packages / generator-open-wc / generators / scaffold-demoing / templates / static / stories / example.stories.js View on Github external
.add('Button with text', () =&gt; `
    <button>Click me</button>
    <p>See tab "Backgrounds" at the bottom</p>
  `);


storiesOf('Addon|Notes', module)
  .addDecorator(withNotes)
  .add('Simple note', () =&gt; `
    <p><strong>See tab "notes" at the bottom.</strong></p>
  `, {
    notes: 'My notes on some <strong>bold</strong> text',
  });


storiesOf('Core|Methods for rendering', module)
  .add('html string', () =&gt; '<div>Rendered with string</div>')
  .add('document.createElement', () =&gt; {
    const el = document.createElement('button');
    el.innerText = 'click me';
    el.foo = 'bar';
    el.addEventListener('click', e =&gt; alert(e.target.foo));
    return el;
  })
  .add('lit-html', () =&gt; html`
    <button> alert(e.target.foo)}&gt;click me</button>
  `);


const globalParameter = 'globalParameter';
const chapterParameter = 'chapterParameter';
const storyParameter = 'storyParameter';
github open-wc / open-wc / packages / generator-open-wc / generators / scaffold-demoing / templates / static / stories / example.stories.js View on Github external
storiesOf('Addon|Backgrounds', module)
  .addDecorator(
    withBackgrounds([
      { name: 'twitter', value: '#00aced', default: true },
      { name: 'facebook', value: '#3b5998' },
    ]),
  )
  .add('Button with text', () =&gt; `
    <button>Click me</button>
    <p>See tab "Backgrounds" at the bottom</p>
  `);


storiesOf('Addon|Notes', module)
  .addDecorator(withNotes)
  .add('Simple note', () =&gt; `
    <p><strong>See tab "notes" at the bottom.</strong></p>
  `, {
    notes: 'My notes on some <strong>bold</strong> text',
  });


storiesOf('Core|Methods for rendering', module)
  .add('html string', () =&gt; '<div>Rendered with string</div>')
  .add('document.createElement', () =&gt; {
    const el = document.createElement('button');
    el.innerText = 'click me';
    el.foo = 'bar';
    el.addEventListener('click', e =&gt; alert(e.target.foo));
    return el;
github open-wc / example-vanilla-set-game / stories / index.stories.js View on Github external
<ul>
        <li>Quantity: 2, 2, 3 ✗</li>
        <li>Color: different - red, green, blue ✓</li>
        <li>Shape: same- all skewed ✓</li>
        <li>Filling: different - empty, full, striped ✓</li>
      </ul>
    `,
  )
  .add(
    'Game',
    () =&gt; html`
      
    `,
  );

storiesOf('Game Parts', module)
  .add('Rigged Game', () =&gt; {
    const data = {
      quantity: 1,
      color: 'red',
      shape: 'bar',
      filling: 'empty',
    };
    const card1 = generateCard(data);
    const card2 = generateCard({ ...data, color: 'green' });
    const card3 = generateCard({ ...data, color: 'blue' });
    return html`
      
    `;
  })
  .add(
    'Card',
github open-wc / open-wc / packages / generator-open-wc / generators / scaffold-demoing / templates / static / stories / index.stories.js View on Github external
import {
  storiesOf,
  html,
} from '@open-wc/storybook';

import '../&lt;%= tagName %&gt;.js';

storiesOf('&lt;%= tagName %&gt;', module)
  .add('default', () =&gt; html`
    &lt;&lt;%= tagName %&gt;&gt;user content tag: &lt;%= tagName %&gt;&gt;
  `)
  .add('right', () =&gt; html`
    &lt;&lt;%= tagName %&gt; class="right"&gt;user content tag: &lt;%= tagName %&gt;&gt;
  `);

@open-wc/storybook

Storybook configuration following open-wc recommendations

MIT
Latest version published 6 years ago

Package Health Score

64 / 100
Full package analysis

Similar packages