UNPKG

wix-style-react

Version:
83 lines (73 loc) 2.8 kB
/* eslint-disable no-console */ import React from 'react'; import CodeExample from 'wix-storybook-utils/CodeExample'; import ExampleStandard from './ExampleStandard'; import ExampleStandardRaw from '!raw-loader!./ExampleStandard'; import ExampleControlled from './ExampleControlled'; import ExampleControlledRaw from '!raw-loader!./ExampleControlled'; import ExampleWithCustomValue from './ExampleWithCustomValue'; import ExampleWithCustomValueRaw from '!raw-loader!./ExampleWithCustomValue'; import Dropdown from 'wix-style-react/Dropdown'; import { storySettings } from './storySettings'; var options = [{ id: 0, value: 'Option 1' }, { id: 1, value: 'Option 2' }, { id: 2, value: 'Option 3' }, { id: 3, value: 'Option 4' }]; var optionsWithDivider = [{ id: 0, value: 'Option 1' }, { id: 1, value: 'Option 2' }, { id: -99, value: '-' }, { id: 2, value: 'Option 3' }, { id: 3, value: 'Option 4' }]; var optionsWithFooter = [{ id: 0, value: 'Option 1' }, { id: 1, value: 'Option 2' }, { id: 2, value: 'Option 3' }, { id: 3, value: 'Option 4' }, { id: 'footer', overrideStyle: true, value: React.createElement( 'div', { style: { height: '240px', padding: '20px', backgroundColor: '#F0F' } }, 'This is a footer with a ', React.createElement( 'a', { href: 'http://www.wix.com' }, 'link' ), '.' ) }]; export default { category: storySettings.kind, storyName: storySettings.storyName, component: Dropdown, componentPath: '../../../src/Dropdown', componentProps: { dataHook: storySettings.dataHook, placeholder: 'This is a placeholder', options: options, onSelect: function onSelect(option) { return console.log('option selected. ' + JSON.stringify(option) + '.'); }, upgrade: true }, exampleProps: { // FIXME: The following onSelect callback prop is commented out since it exposes a // bug in Dropdown, that the selectedId is not updated. Needs investigation. // onSelect: option => console.log(`${option.value} selected`), options: [{ label: 'normal', value: options }, { label: 'with divider', value: optionsWithDivider }, { label: 'with footer', value: optionsWithFooter }] }, examples: React.createElement( 'div', null, React.createElement( CodeExample, { title: 'Standard', code: ExampleStandardRaw }, React.createElement(ExampleStandard, null) ), React.createElement( CodeExample, { title: 'Controlled Dropdown', code: ExampleControlledRaw }, React.createElement(ExampleControlled, null) ), React.createElement( CodeExample, { title: 'Custom Values in Dropdown', code: ExampleWithCustomValueRaw }, React.createElement(ExampleWithCustomValue, null) ) ) };