import React, { useState } from 'react'; import _ from 'lodash'; import { Meta, Story } from '@storybook/react'; import DropMenu, { IDropMenuProps } from './DropMenu'; import TextField from '../TextField/TextField'; import ChevronIcon from '../Icon/ChevronIcon/ChevronIcon'; import Button from '../Button/Button'; export default { title: 'Helpers/DropMenu', component: DropMenu, parameters: { docs: { description: { component: DropMenu.peek.description, }, }, layout: 'centered', }, argTypes: { children: { control: false }, }, } as Meta; /* Basic */ export const Basic: Story = (args) => { const [selectedIndices, setSelectedIndices] = useState>( [] ); const { Control, Option } = DropMenu; const handleSelect = (optionIndex: any) => { setSelectedIndices((selectedIndices) => [...selectedIndices, optionIndex]); }; const options = [ 'MS-DOS', 'Windows', 'OS/2', 'Windows Phone', 'Windows Mobile', 'Pocket PC', ]; return ( handleSelect(i)}> {_.isEmpty(selectedIndices) ? 'Select OS' : options[_.last(selectedIndices) as any]} {_.map(options, (optionText, index) => ( ))} ); }; /* Button Menu */ export const ButtonMenu: Story = (args) => { const [selectedIndices, setSelectedIndices] = useState>( [] ); const { Control, Option } = DropMenu; const options = ['Red', 'Green', 'Blue']; const handleSelect = (optionIndex: any) => { setSelectedIndices((selectedIndices) => [...selectedIndices, optionIndex]); }; return ( handleSelect(i)}> {_.map(options, (optionText, index) => ( ))} ); }; /* Disabled Control */ export const DisabledControl: Story = (args) => { const { Control, Option } = DropMenu; return ( ); }; DisabledControl.args = { isDisabled: true, }; /* Disabled Options */ export const DisabledOptions: Story = (args) => { const { Control, Option } = DropMenu; const [selectedIndices, setSelectedIndices] = useState>( [] ); const options = ['Red', 'Green', 'Blue']; const handleSelect = (optionIndex: any) => { setSelectedIndices((selectedIndices) => [...selectedIndices, optionIndex]); }; return ( handleSelect(i)}> {_.isEmpty(selectedIndices) ? 'Select Color' : options[_.last(selectedIndices) as any]} {_.map(options, (optionText, index) => ( ))} ); }; /* Grouped Options */ export const GroupedOptions: Story = (args) => { const { Control, Option, OptionGroup } = DropMenu; return ( Screen Print ); }; /* Text Menu */ export const TextMenu: Story = (args) => { const [selectedIndices, setSelectedIndices] = useState>( [] ); const { Control, Option } = DropMenu; const options = ['Red', 'Green', 'Blue']; const handleSelect = (optionIndex: any) => { setSelectedIndices((selectedIndices) => [...selectedIndices, optionIndex]); }; return ( handleSelect(i)}> {_.isEmpty(selectedIndices) ? ( ) : ( options[_.last(selectedIndices) as any] )} {_.map(options, (optionText, index) => ( ))} ); }; /* Action Menu */ export const ActionMenu: Story = (args) => { const [selectedIndices, setSelectedIndices] = useState>( [] ); const { Control, Option } = DropMenu; const options = ['Select Color', 'Red', 'Green', 'Blue']; const handleSelect = (optionIndex: any) => { setSelectedIndices((selectedIndices) => [...selectedIndices, optionIndex]); }; return ( handleSelect(i)}> {_.isEmpty(selectedIndices) ? 'Select Color' : options[_.last(selectedIndices) as any]} {_.map(options, (optionText, index) => ( ))} ); }; /* No Wrapping */ export const NoWrapping: Story = (args) => { const options = [ 'Intentionally run off screen -- Adipisicing totam saepe officia repellat quo cupiditate ducimus hic? Quod temporibus corrupti eaque ullam quo nulla corporis !', 'Adipisicing totam provident excepturi officia non cum alias? Labore possimus adipisci id eveniet numquam tempora totam est. Explicabo recusandae quo tempore', 'Consectetur doloribus dignissimos exercitationem vel tempora praesentium nostrum eveniet inventore. Odit inventore quas optio id eum nisi. Minima consequuntur', ]; const { Control, Option } = DropMenu; const [selectedIndices, setSelectedIndices] = useState>( [] ); const handleSelect = (optionIndex: any) => { setSelectedIndices((selectedIndices) => [...selectedIndices, optionIndex]); }; return (
handleSelect(i)} alignment='center'> {_.map(options, (optionText, index) => ( ))}
); }; /* Stateless */ export const Stateless: Story = (args) => { const { Control, Option, OptionGroup } = DropMenu; return ( Preferred ); };