|
1 |
| -import styled from 'styled-components'; |
2 |
| -import { AutoScalingInput as Input } from './AutoScalingInput'; |
3 |
| -import { Meta } from '@storybook/react'; |
4 |
| - |
5 |
| -const Wrapper = styled.div` |
6 |
| - display: flex; |
7 |
| - flex: 1; |
8 |
| - flex-direction: column; |
9 |
| -`; |
10 |
| - |
11 |
| -const BorderAutoScalingInput = styled(Input)` |
12 |
| - padding: 1px 5px; |
13 |
| - border-radius: 3px; |
14 |
| - border-style: solid; |
15 |
| - border-width: 1px; |
16 |
| -`; |
17 |
| - |
18 |
| -const BorderlessAutoScalingInput = styled(Input)` |
19 |
| - padding: 1px 5px; |
20 |
| - border-style: solid; |
21 |
| - border-width: 0; |
22 |
| - background-color: #ccc; |
23 |
| -`; |
| 1 | +import { ForwardRefExoticComponent, RefAttributes } from 'react'; |
| 2 | +import { AutoScalingInput as AutoScalingInputComponent, Props } from './AutoScalingInput'; |
| 3 | +import { Meta, StoryObj } from '@storybook/react'; |
24 | 4 |
|
25 | 5 | const meta: Meta = {
|
26 | 6 | title: 'Form/AutoScalingInput',
|
| 7 | + component: AutoScalingInputComponent, |
27 | 8 | };
|
28 | 9 | export default meta;
|
29 | 10 |
|
30 |
| -export const AutoScalingInput = { |
31 |
| - render: () => ( |
32 |
| - <> |
33 |
| - <Wrapper> |
34 |
| - <div>Border</div> |
35 |
| - <BorderAutoScalingInput minWidth={130} /> |
36 |
| - <BorderAutoScalingInput |
37 |
| - minWidth={120} |
38 |
| - placeholder="Chancellor on the Brink of Second Bailout for Banks" |
39 |
| - /> |
40 |
| - <div>Borderless</div> |
41 |
| - <BorderlessAutoScalingInput minWidth={130} /> |
42 |
| - <BorderlessAutoScalingInput |
43 |
| - minWidth={120} |
44 |
| - placeholder="Chancellor on the Brink of Second Bailout for Banks" |
45 |
| - /> |
46 |
| - </Wrapper> |
47 |
| - </> |
48 |
| - ), |
| 11 | +export const AutoScalingInput: StoryObj< |
| 12 | + ForwardRefExoticComponent<Omit<Props, 'ref'> & RefAttributes<HTMLInputElement>> |
| 13 | +> = { |
| 14 | + render: props => <AutoScalingInputComponent {...props} />, |
| 15 | + args: { |
| 16 | + value: undefined, |
| 17 | + minWidth: 120, |
| 18 | + placeholder: 'Chancellor on the Brink of Second Bailout for Banks', |
| 19 | + disabled: false, |
| 20 | + }, |
| 21 | + argTypes: { |
| 22 | + value: { |
| 23 | + control: { type: 'text' }, |
| 24 | + }, |
| 25 | + minWidth: { |
| 26 | + control: { type: 'number' }, |
| 27 | + }, |
| 28 | + placeholder: { |
| 29 | + control: { type: 'text' }, |
| 30 | + }, |
| 31 | + disabled: { |
| 32 | + control: { |
| 33 | + type: 'boolean', |
| 34 | + }, |
| 35 | + }, |
| 36 | + }, |
49 | 37 | };
|
0 commit comments