123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162 |
- import {Button} from 'sentry/components/button';
- import DropdownAutoComplete from 'sentry/components/dropdownAutoComplete';
- import DropdownButton from 'sentry/components/dropdownButton';
- const items = [
- {
- value: 'apple',
- label: 'π Apple',
- },
- {
- value: 'bacon',
- label: 'π₯ Bacon',
- },
- {
- value: 'corn',
- label: 'π½ Corn',
- },
- ];
- const groupedItems = [
- {
- value: 'defaults',
- hideGroupLabel: true,
- items: [
- {
- value: 'recent thing',
- label: 'recent thing',
- },
- {
- value: 'other recent thing',
- label: 'other recent thing',
- },
- {
- value: 'yet another recent thing',
- label: 'yet another recent thing',
- },
- ],
- },
- {
- value: 'countries',
- label: (
- <div>
- Countries{' '}
- <a style={{float: 'right'}} href="#">
- + Add
- </a>
- </div>
- ),
- items: [
- {
- value: 'new zealand',
- label: <div>π¨π· New Zealand</div>,
- },
- {
- value: 'australia',
- label: <div>π¦πΊ Australia</div>,
- },
- {
- value: 'brazil',
- label: <div>π§π· Brazil</div>,
- },
- ],
- },
- {
- value: 'foods',
- label: 'Foods',
- items: [
- {
- value: 'apple',
- label: <div>π Apple</div>,
- },
- {
- value: 'bacon',
- label: <div>π₯ Bacon</div>,
- },
- {
- value: 'corn',
- label: <div>π½ Corn</div>,
- },
- ],
- },
- ];
- export default {
- title: 'Components/Buttons/Dropdowns/Dropdown Auto Complete',
- component: DropdownAutoComplete,
- };
- export const Ungrouped = () => (
- <DropdownAutoComplete items={items}>
- {({selectedItem}) => (selectedItem ? selectedItem.label : 'Click me!')}
- </DropdownAutoComplete>
- );
- Ungrouped.storyName = 'Ungrouped';
- Ungrouped.parameters = {
- docs: {
- description: {
- story: 'The item label can be a component or a string',
- },
- },
- };
- export const Grouped = () => (
- <DropdownAutoComplete
- items={groupedItems}
- virtualizedHeight={44}
- virtualizedLabelHeight={28}
- >
- {({selectedItem}) => (selectedItem ? selectedItem.label : 'Click me!')}
- </DropdownAutoComplete>
- );
- Grouped.storyName = 'Grouped';
- Grouped.parameters = {
- docs: {
- description: {
- story: 'Group labels can receive a component too',
- },
- },
- };
- export const WithDropdownButton = () => (
- <DropdownAutoComplete items={groupedItems}>
- {({isOpen, selectedItem}) => (
- <DropdownButton isOpen={isOpen}>
- {selectedItem ? selectedItem.label : 'Click me!'}
- </DropdownButton>
- )}
- </DropdownAutoComplete>
- );
- WithDropdownButton.storyName = 'With Dropdown Button';
- WithDropdownButton.parameters = {
- docs: {
- description: {
- story: 'Use it with dropdownbutton for maximum fun',
- },
- },
- };
- export const WithExtraAction = () => (
- <DropdownAutoComplete
- items={items}
- action={<Button priority="primary">Now click me!</Button>}
- >
- {({isOpen, selectedItem}) => (
- <DropdownButton isOpen={isOpen}>
- {selectedItem ? selectedItem.label : 'Click me!'}
- </DropdownButton>
- )}
- </DropdownAutoComplete>
- );
- WithExtraAction.storyName = 'With Extra Action';
- WithExtraAction.parameters = {
- docs: {
- description: {
- story: 'Add a call to action button',
- },
- },
- };
|