How to use the @storybook/addon-knobs.optionsKnob 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 tidepool-org / viz / stories / data / DataUtil.js View on Github external
const getMetaData = () => {
    const queryFormat = getMetaDataQueryFormat();
    const selectedMetaData = options(
      'Metadata',
      metadata,
      [],
      { display: 'check' },
      GROUP_DATA,
    );

    if (!selectedMetaData.length) return undefined;

    return queryFormat === 'string' ? selectedMetaData.join(',') : selectedMetaData;
  };
github DivanteLtd / storefront-ui / packages / react / src / components / atoms / SfPrice / SfPrice.stories.js View on Github external
.add('Special', () => (
    {text('special (prop)', '$100.00')}}
    />
  ))
  .add('Old', () => (
github DivanteLtd / storefront-ui / packages / vue / src / components / molecules / SfSearchBar / SfSearchBar.stories.js View on Github external
.add("Common", () => ({
    components: { SfSearchBar },
    props: {
      customClass: {
        default: options(
          "CSS modifiers",
          {
            "sf-search-bar--secondary": "sf-search-bar--secondary",
            "sf-search-bar--position-right": "sf-search-bar--position-right",
            "sf-search-bar--position-right-mobile":
              "sf-search-bar--position-right-mobile",
            "sf-search-bar--position-right-desktop":
              "sf-search-bar--position-right-desktop",
            "sf-search-bar--no-icon": "sf-search-bar--no-icon"
          },
          "null",
          { display: "multi-select" },
          "CSS Modifiers"
        )
      },
      placeholder: {
github tidepool-org / viz / stories / data / DataUtil.js View on Github external
const getBGPrefs = () => {
    const bgUnits = options('BG Units', { [MGDL_UNITS]: MGDL_UNITS, [MMOLL_UNITS]: MMOLL_UNITS, ...noneOption }, MGDL_UNITS, { display: 'select' }, GROUP_UNITS);

    return bgUnits !== 'None' ? {
      bgUnits,
      bgBounds: DEFAULT_BG_BOUNDS[bgUnits],
    } : undefined;
  };
github hackoregon / civic / packages / component-library / stories / BarChart.story.js View on Github external
"Subtitle",
          "Dogs in Portland with a net worth greater than $1,000",
          GROUP_IDS.LABELS
        );
        const xLabel = text("X-axis label", "Year", GROUP_IDS.LABELS);
        const xFormatterOptions = getKeyNames(civicFormat);
        const optionSelectX = options(
          "X-axis value format",
          xFormatterOptions,
          "year",
          { display: "select" },
          GROUP_IDS.LABELS
        );
        const yLabel = text("Y-axis label", "Dogs", GROUP_IDS.LABELS);
        const yFormatterOptions = getKeyNames(civicFormat);
        const optionSelectY = options(
          "Y-axis value format",
          yFormatterOptions,
          "numeric",
          { display: "select" },
          GROUP_IDS.LABELS
        );
        const dataKey = text("Data key", "ye", GROUP_IDS.DATA);
        const dataValue = text("Data values", "population", GROUP_IDS.DATA);
        const dataSeries = text("Data series", "breed", GROUP_IDS.DATA);
        const data = object(
          "Data",
          [
            { ye: 1994, population: 2000, breed: "poodle" },
            { ye: 1995, population: 8000, breed: "poodle" },
            { ye: 1995, population: 8000, breed: "poodle" },
            { ye: 1996, population: 6000, breed: "poodle" },
github hackoregon / civic / packages / component-library / stories / MultiLayerMap.story.js View on Github external
const PATH_MAP_SCALE_TYPE_COLOR_OPTIONS = {
          none: "",
          threshold: "threshold",
          ordinal: "ordinal",
          equal: "equal"
        };

        const lineColor = select(
          "CIVIC Color:",
          CIVIC_COLORS,
          CIVIC_COLORS.civicGreen,
          GROUP_IDS.DESIGN
        );

        const scaleTypeColor = options(
          "Scale Type:",
          PATH_MAP_SCALE_TYPE_COLOR_OPTIONS,
          "",
          {
            display: "inline-radio"
          },
          GROUP_IDS.DESIGN
        );

        const fieldName = text("Field Name:", "shape_leng", GROUP_IDS.DESIGN);

        const dataRange = object("Data Range:", [], GROUP_IDS.DESIGN);

        const colorRange = object("Color Range:", [], GROUP_IDS.DESIGN);

        const pathMapAPIURL =
github tidepool-org / viz / stories / data / DataUtil.js View on Github external
    const getSortField = t => options(`${t} sort field`, { ...fieldsByType[t], ...noneOption }, 'normalTime', { display: 'select' }, GROUP_SORTS);
    const getSortOrder = t => options(`${t} sort order`, sorts, 'asc', { display: 'select' }, GROUP_SORTS);
github storybookjs / storybook / examples / html-kitchen-sink / stories / react / addon-knobs.stories.js View on Github external
display: 'multi-select',
    });

    const valuesCheck = {
      Corn: 'corn',
      Carrot: 'carrot',
      Cucumber: 'cucumber',
    };
    const optionsCheck = options('Check', valuesCheck, ['carrot'], { display: 'check' });

    const valuesInlineCheck = {
      Milk: 'milk',
      Cheese: 'cheese',
      Butter: 'butter',
    };
    const optionsInlineCheck = options('Inline Check', valuesInlineCheck, ['milk'], {
      display: 'inline-check',
    });

    return (
      <div>
        <p>Weekday: {optionRadio}</p>
        <p>Weekend: {optionInlineRadio}</p>
        <p>Month: {optionSelect}</p>
        <p>Fruit:</p>
        <ul>
          {optionsMultiSelect.map(item =&gt; (
            <li>{item}</li>
          ))}
        </ul>
        <p>Vegetables:</p>
        <ul></ul></div>
github DivanteLtd / storefront-ui / packages / vue / src / components / atoms / SfProperty / SfProperty.stories.js View on Github external
.add("Common", () => ({
    components: { SfProperty },
    props: {
      customClass: {
        default: options(
          "CSS modifiers",
          {
            "sf-property--full-width": "sf-property--full-width"
          },
          "",
          { display: "multi-select" },
          "CSS Modifiers"
        )
      },
      name: {
        default: text("name", "Material", "Props")
      },
      value: {
        default: text("value", "Cotton", "Props")
      }
    },
github kalmhq / kalm / frontend / src / _stories / data / application.ts View on Github external
POST: "POST",
    PUT: "PUT",
    PATCH: "PATCH",
    DELETE: "DELETE",
    OPTIONS: "OPTIONS",
    HEAD: "HEAD",
    TRACE: "TRACE",
    CONNECT: "CONNECT",
  };
  const defaultValue = ["GET"];
  const optionsObj: OptionsKnobOptions = {
    display: "check",
  };
  const groupId = namespace;

  const methods = optionsKnob(label, valuesObj, defaultValue, optionsObj, groupId);

  const hosts = array("Hosts", ["bookinfo.demo.com"], ",", namespace);
  const schemes = optionsKnob(
    "Schemes",
    { http: "http", https: "https" },
    ["http"],
    {
      display: "check",
    },
    namespace,
  );

  const paths = array("Paths", ["/"], ",", namespace);

  const destinationOptions = [
    { host: "productV1page", weight: 1 },