1
- import { useState } from 'react' ;
2
-
3
1
import { useBoolean } from '@koobiq/react-core' ;
4
2
import type { StoryObj } from '@storybook/react' ;
5
3
6
4
import { Button } from '../Button' ;
5
+ import { FlexBox } from '../FlexBox' ;
7
6
import { Input } from '../Input' ;
8
- import { flex , spacing } from '../layout' ;
7
+ import { spacing } from '../layout' ;
9
8
import { Textarea } from '../Textarea' ;
10
9
import { Toggle } from '../Toggle' ;
11
10
@@ -14,9 +13,7 @@ import {
14
13
ModalContent ,
15
14
ModalFooter ,
16
15
ModalHeader ,
17
- type ModalPropControl ,
18
16
type ModalProps ,
19
- type ModalPropSize ,
20
17
} from './index' ;
21
18
import { modalPropSize } from './index.js' ;
22
19
@@ -72,37 +69,27 @@ export const Base: Story = {
72
69
73
70
export const Size : Story = {
74
71
render : function Render ( args : ModalProps ) {
75
- const [ size , setSize ] = useState < ModalPropSize > ( ) ;
76
-
77
- const control : ModalPropControl = ( { onClick, ...other } ) => (
78
- < div className = { flex ( { gap : 'l' } ) } >
72
+ return (
73
+ < FlexBox gap = "l" >
79
74
{ modalPropSize . map ( ( size ) => (
80
- < Button
81
- onClick = { ( e ) => {
82
- onClick ?.( e ) ;
83
- setSize ( size ) ;
84
- } }
75
+ < Modal
85
76
key = { size }
86
- { ...other }
77
+ size = { size }
78
+ control = { ( props ) => < Button { ...props } > size = { size } </ Button > }
79
+ { ...args }
87
80
>
88
- size = { size }
89
- </ Button >
81
+ { ( { close } ) => (
82
+ < >
83
+ < ModalHeader > I have a { size } size</ ModalHeader >
84
+ < ModalContent > But there's nothing to say…</ ModalContent >
85
+ < ModalFooter >
86
+ < Button onPress = { close } > Ok</ Button >
87
+ </ ModalFooter >
88
+ </ >
89
+ ) }
90
+ </ Modal >
90
91
) ) }
91
- </ div >
92
- ) ;
93
-
94
- return (
95
- < Modal size = { size } control = { control } { ...args } >
96
- { ( { close } ) => (
97
- < >
98
- < ModalHeader > I have a { size } size</ ModalHeader >
99
- < ModalContent > But there's nothing to say…</ ModalContent >
100
- < ModalFooter >
101
- < Button onClick = { close } > Ok</ Button >
102
- </ ModalFooter >
103
- </ >
104
- ) }
105
- </ Modal >
92
+ </ FlexBox >
106
93
) ;
107
94
} ,
108
95
} ;
@@ -167,7 +154,7 @@ export const Settings: Story = {
167
154
< >
168
155
< ModalHeader > Adjust me</ ModalHeader >
169
156
< ModalContent >
170
- < div className = { flex ( { direction : ' column' , gap : 'l' } ) } >
157
+ < FlexBox gap = "l" direction = " column" >
171
158
< Toggle
172
159
checked = { hideBackdrop }
173
160
onChange = { setHideBackdrop . toggle }
@@ -192,7 +179,7 @@ export const Settings: Story = {
192
179
>
193
180
Disable the exit by pressing ESC key
194
181
</ Toggle >
195
- </ div >
182
+ </ FlexBox >
196
183
</ ModalContent >
197
184
< ModalFooter >
198
185
< Button onClick = { close } > Ok</ Button >
0 commit comments