Download wp-calypso/packages/components/src/segmented-control/index.stories.js from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 2.25 kB
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/packages/components/src/segmented-control/index.stories.js
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/wp-calypso/packages/components/src/segmented-control/index.stories.js
-
curl -L -o index.stories.js https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/packages/components/src/segmented-control/index.stories.js
2.25 kB
| /* eslint-disable no-console */ | |
| import { useState } from 'react'; | |
| import SimplifiedSegmentedControl from './simplified'; | |
| import SegmentedControl from './'; | |
| export default { | |
| title: 'Unaudited/SegmentedControl', | |
| component: SegmentedControl, | |
| argTypes: { | |
| compact: { control: 'boolean' }, | |
| }, | |
| }; | |
| export const Default = ( { compact } ) => { | |
| const [ selected, setSelected ] = useState( 'all' ); | |
| const options = [ | |
| { value: 'all', label: 'All' }, | |
| { value: 'unread', label: 'Unread' }, | |
| { value: 'comments', label: 'Comments' }, | |
| { value: 'follows', label: 'Follows' }, | |
| { value: 'likes', label: 'Likes' }, | |
| ]; | |
| const controlDemoStyles = { maxWidth: 386 }; | |
| const selectChildSegment = ( childSelected, event ) => { | |
| event.preventDefault(); | |
| setSelected( childSelected ); | |
| console.log( 'Segmented Control (selected):', childSelected ); | |
| }; | |
| const selectSegment = ( option ) => { | |
| console.log( 'Segmented Control (selected):', option ); | |
| }; | |
| return ( | |
| <div> | |
| <h3>Items passed as options prop</h3> | |
| <SimplifiedSegmentedControl | |
| options={ options } | |
| onSelect={ selectSegment } | |
| style={ controlDemoStyles } | |
| compact={ compact } | |
| /> | |
| <h3 style={ { marginTop: 20 } }>Primary version</h3> | |
| <SegmentedControl | |
| selectedText={ selected } | |
| style={ controlDemoStyles } | |
| primary | |
| compact={ compact } | |
| > | |
| <SegmentedControl.Item | |
| selected={ selected === 'all' } | |
| onClick={ selectChildSegment.bind( this, 'all' ) } | |
| > | |
| All | |
| </SegmentedControl.Item> | |
| <SegmentedControl.Item | |
| selected={ selected === 'unread' } | |
| onClick={ selectChildSegment.bind( this, 'unread' ) } | |
| > | |
| Unread | |
| </SegmentedControl.Item> | |
| <SegmentedControl.Item | |
| selected={ selected === 'comments' } | |
| onClick={ selectChildSegment.bind( this, 'comments' ) } | |
| > | |
| Comments | |
| </SegmentedControl.Item> | |
| <SegmentedControl.Item | |
| selected={ selected === 'follows' } | |
| onClick={ selectChildSegment.bind( this, 'follows' ) } | |
| > | |
| Follows | |
| </SegmentedControl.Item> | |
| <SegmentedControl.Item | |
| selected={ selected === 'likes' } | |
| onClick={ selectChildSegment.bind( this, 'likes' ) } | |
| > | |
| Likes | |
| </SegmentedControl.Item> | |
| </SegmentedControl> | |
| </div> | |
| ); | |
| }; | |