|
10 | 10 | * governing permissions and limitations under the License.
|
11 | 11 | */
|
12 | 12 | import {action} from '@storybook/addon-actions';
|
| 13 | +import {ActionButton} from '@react-spectrum/button'; |
| 14 | +import {Flex} from '@react-spectrum/layout'; |
13 | 15 | import {Item, Picker} from '@react-spectrum/picker';
|
14 |
| -import React from 'react'; |
| 16 | +import React, {useState} from 'react'; |
15 | 17 | import {SearchField} from '@react-spectrum/searchfield';
|
16 | 18 | import {SearchFieldProps} from '@react-types/searchfield';
|
17 | 19 | import {SearchWithin} from '../';
|
@@ -45,11 +47,32 @@ function renderReverse(props: Omit<SpectrumSearchWithinProps, 'children'> = {},
|
45 | 47 | <Item key="audiences">Audiences</Item>
|
46 | 48 | <Item key="tags">Tags</Item>
|
47 | 49 | </Picker>
|
48 |
| - <SearchField placeholder="Search" {...searchFieldProps} {...searchFieldProps} onChange={action('change')} onSubmit={action('submit')} /> |
| 50 | + <SearchField placeholder="Search" {...searchFieldProps} onChange={action('change')} onSubmit={action('submit')} /> |
49 | 51 | </SearchWithin>
|
50 | 52 | );
|
51 | 53 | }
|
52 | 54 |
|
| 55 | +function ResizeSearchWithinApp(props) { |
| 56 | + const [state, setState] = useState(true); |
| 57 | + |
| 58 | + return ( |
| 59 | + <Flex direction="column" gap="size-200" alignItems="start"> |
| 60 | + <div style={{width: state ? '300px' : '400px'}}> |
| 61 | + <SearchWithin label="Search" {...props} width="100%"> |
| 62 | + <SearchField placeholder="Search" onChange={action('change')} onSubmit={action('submit')} /> |
| 63 | + <Picker defaultSelectedKey="all" onSelectionChange={action('selectionChange')}> |
| 64 | + <Item key="all">All</Item> |
| 65 | + <Item key="campaigns">Campaigns</Item> |
| 66 | + <Item key="audiences">Audiences</Item> |
| 67 | + <Item key="tags">Tags</Item> |
| 68 | + </Picker> |
| 69 | + </SearchWithin> |
| 70 | + </div> |
| 71 | + <ActionButton onPress={() => setState(!state)}>Toggle size</ActionButton> |
| 72 | + </Flex> |
| 73 | + ); |
| 74 | +} |
| 75 | + |
53 | 76 | export const Default = () => render({});
|
54 | 77 |
|
55 | 78 | export const ValueControlled = () => render({}, {value: 'Controlled'});
|
@@ -96,3 +119,7 @@ export const AutoFocusPicker = () => render({}, {}, {autoFocus: true});
|
96 | 119 | AutoFocusPicker.storyName = 'autoFocus: true on Picker';
|
97 | 120 |
|
98 | 121 | export const ReverseChildrenOrder = () => renderReverse({});
|
| 122 | + |
| 123 | +export const ResizeSearchWithin = () => <ResizeSearchWithinApp />; |
| 124 | + |
| 125 | +export const ResizeSearchWithinNoLabel = () => <ResizeSearchWithinApp label={null} />; |
0 commit comments