How to use the @storybook/addon-knobs.array function in @storybook/addon-knobs

To help you get started, we’ve selected a few @storybook/addon-knobs 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 / examples / official-storybook / stories / addon-knobs.stories.js View on Github external
// General
    const name = text('Name', 'Storyteller', GROUP_IDS.GENERAL);
    const age = number('Age', 70, { range: true, min: 0, max: 90, step: 5 }, GROUP_IDS.GENERAL);
    const birthday = date('Birthday', defaultBirthday, GROUP_IDS.GENERAL);
    const dollars = number(
      'Account Balance',
      12.5,
      { min: 0, max: 100, step: 0.01 },
      GROUP_IDS.GENERAL
    );
    const years = number('Years in NY', 9, {}, GROUP_IDS.GENERAL);

    // Favorites
    const nice = boolean('Nice', true, GROUP_IDS.FAVORITES);
    const fruit = select('Fruit', fruits, 'apple', GROUP_IDS.FAVORITES);
    const items = array('Items', ['Laptop', 'Book', 'Whiskey'], ',', GROUP_IDS.FAVORITES);

    // Display
    const backgroundColor = color('Color', 'rgba(126, 211, 33, 0.22)', GROUP_IDS.DISPLAY);
    const otherStyles = object(
      'Styles',
      {
        border: '2px dashed silver',
        borderRadius: 10,
        padding: '10px',
      },
      GROUP_IDS.DISPLAY
    );

    const style = { backgroundColor, ...otherStyles };

    const salutation = nice ? 'Nice to meet you!' : 'Leave me alone!';
github storybookjs / storybook / examples / html-kitchen-sink / stories / react / addon-knobs.stories.js View on Github external
const name = text('Name', 'Storyteller', GROUP_IDS.GENERAL);
    const age = number('Age', 70, { range: true, min: 0, max: 90, step: 5 }, GROUP_IDS.GENERAL);
    const birthday = date('Birthday', defaultBirthday, GROUP_IDS.GENERAL);
    const dollars = number(
      'Account Balance',
      12.5,
      { min: 0, max: 100, step: 0.01 },
      GROUP_IDS.GENERAL
    );
    const years = number('Years in NY', 9, {}, GROUP_IDS.GENERAL);

    // Favorites
    const nice = boolean('Nice', true, GROUP_IDS.FAVORITES);
    const fruit = select('Fruit', fruits, 'apple', GROUP_IDS.FAVORITES);
    const otherFruit = radios('Other Fruit', otherFruits, 'watermelon', GROUP_IDS.FAVORITES);
    const items = array('Items', ['Laptop', 'Book', 'Whiskey'], ',', GROUP_IDS.FAVORITES);

    // Display
    const backgroundColor = color('Color', 'rgba(126, 211, 33, 0.22)', GROUP_IDS.DISPLAY);
    const otherStyles = object(
      'Styles',
      {
        border: '2px dashed silver',
        borderRadius: 10,
        padding: '10px',
      },
      GROUP_IDS.DISPLAY
    );

    const style = { backgroundColor, ...otherStyles };

    const salutation = nice ? 'Nice to meet you!' : 'Leave me alone!';
github strapi / buffet / buffet / stories / Combined / General.stories.js View on Github external
Banana: 'banana',
      Cherry: 'cherry',
    };
    const fruit = select('Fruit', fruits, 'apple');

    const otherFruits = {
      Kiwi: 'kiwi',
      Guava: 'guava',
      Watermelon: 'watermelon',
    };
    const otherFruit = radios('Other Fruit', otherFruits, 'watermelon');
    const dollars = number('Dollars', 12.5, { min: 0, max: 100, step: 0.01 });
    const years = number('Years in NY', 9);

    const backgroundColor = color('background', '#dedede');
    const items = array('Items', ['Laptop', 'Book', 'Whiskey']);
    const otherStyles = object('Styles', {
      border: '2px dashed silver',
      borderRadius: 10,
      padding: '10px',
    });
    const nice = boolean('Nice', true);
    const images = files('Happy Picture', 'image/*', [
      'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAQAAAC1+jfqAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAAmJLR0QA/4ePzL8AAAAHdElNRQfiARwMCyEWcOFPAAAAP0lEQVQoz8WQMQoAIAwDL/7/z3GwghSp4KDZyiUpBMCYUgd8rehtH16/l3XewgU2KAzapjXBbNFaPS6lDMlKB6OiDv3iAH1OAAAAJXRFWHRkYXRlOmNyZWF0ZQAyMDE4LTAxLTI4VDEyOjExOjMzLTA3OjAwlAHQBgAAACV0RVh0ZGF0ZTptb2RpZnkAMjAxOC0wMS0yOFQxMjoxMTozMy0wNzowMOVcaLoAAAAASUVORK5CYII=',
    ]);

    // NOTE: the default value must not change - e.g., do not do date('Label', new Date()) or date('Label')
    const defaultBirthday = new Date('Jan 20 2017 GMT+0');
    const birthday = date('Birthday', defaultBirthday);

    const intro = `My name is ${name}, I'm ${age} years old, and my favorite fruit is ${fruit}. I also enjoy ${otherFruit}.`;
    const style = { backgroundColor, ...otherStyles };
github gnosis / dx-react / stories / TokenOverlay.tsx View on Github external
.addWithJSX('open', () => {
    const approvedTokens = new Set(array('approvedTokens', ['ETH', 'GNO'])) as Set
    return (
       {}}
        resettable={boolean('resettable', true)}
        tokenList={array('tokenCodeList', [])}
        tokenBalances={object('tokenBalances', tokenBalances)}
        open={boolean('open', true)}
        mod={text('mod', 'sell') as TokenMod}
        approvedTokens={approvedTokens}
        availableAuctions={new Set()}
        WETHAddress=""
        MGNAddress=""
        tokenPair={{} as TokenPair}
     />
github propertybase / react-lds / stories / Grid.js View on Github external
Max Width: 1280px
      
      
        Width: 100%
      
      
        Left Aligned
      
      
        Center Aligned
github appbaseio / playground / stories / index.js View on Github external
sortBy: "desc"
          },
          {
            label: "Published - Most recent first",
            dataField: "original_publication_year",
            sortBy: "desc"
          },
          {
            label: "Published - Oldest first",
            dataField: "original_publication_year",
            sortBy: "asc"
          }
        ]}
        currentPage={number("currentPage", 1)}
        pagination={boolean("pagination", true)}
        includeFields={array("includeFields", ["*"])}
        excludeFields={array("excludeFields", [])}
        paginationAt={text("paginationAt", "bottom")}
      />
    )
  );
github influxdata / clockface / src / Components / IndexList / Documentation / IndexList.stories.tsx View on Github external
() => {
    const columnWidths = array('Column Widths', ['20%', '60%', '20%'])
    const exampleHeaders = array('Headers', ['Name', 'Description', ''])
    const exampleNames = array('Names', ['Apple', 'Banana', 'Orange'])
    const exampleDescriptions = array('Descriptions', [
      'Keeps doctors away',
      'A tropical yellow fruit with a creamy, starchy inside',
      'Spherical and protected by a thick peel',
    ])

    const disabledRows = array('Disabled Rows', ['Banana'])

    return (
      <div>
        
          
            {exampleHeaders.map((col, i) =&gt; (
              </div>
github getsentry / sentry / docs-ui / components / scoreBar.stories.js View on Github external
withInfo('Description')(() =&gt; {
      let palette = array('Palette', [
        color('Lower', 'pink'),
        color('Low', 'yellow'),
        color('Med', 'lime'),
        color('High', 'blue'),
        color('Higher', 'purple'),
      ]);

      return (
        <div style="{{backgroundColor:">
          </div>
github jamesmfriedman / rmwc / src / select / select.story.tsx View on Github external
.add('Select with array', () =&gt; (
    <select placeholder="{text('placeholder'," label="{text('label',">
  ))
</select>
github ulaval / modul-components / src / components / error-pages / error-config-not-supported / error-config-not-supported.stories.ts View on Github external
.add('hints', () =&gt; ({
        props: {
            hints: {
                default: array('Hints[Array]', ['My only custom hint', `My second (long) custom hint.Lorem ipsum dolor
                sit amet, consectetur adipiscing elit. Nulla egestas urna rhoncus ipsum congue lobortis. `])
            }
        },
        template: `<div style="border: solid 1px black; padding: 10px; width: 600px;">
                        
                   </div>`
    }));