@@ -87,113 +87,6 @@ export const WithCss = ({width, height, subtitle}: DialogStoryProps) => {
8787 )
8888}
8989
90- function SxHeader ( { title, subtitle, dialogLabelId} : React . PropsWithChildren < DialogProps & { dialogLabelId : string } > ) {
91- if ( typeof title === 'string' && typeof subtitle === 'string' ) {
92- return (
93- < Dialog . Header sx = { { color : 'accent.emphasis' } } >
94- < h1 id = { dialogLabelId } > { title . toUpperCase ( ) } </ h1 >
95- </ Dialog . Header >
96- )
97- }
98- return null
99- }
100- function SxBody ( { children} : React . PropsWithChildren < DialogProps > ) {
101- return < Dialog . Body sx = { { color : 'danger.emphasis' } } > { children } </ Dialog . Body >
102- }
103- function SxFooter ( { footerButtons} : React . PropsWithChildren < DialogProps > ) {
104- return (
105- < Dialog . Footer sx = { { fontFamily : 'Times New Roman' } } >
106- { footerButtons ? < Dialog . Buttons buttons = { footerButtons } /> : null }
107- </ Dialog . Footer >
108- )
109- }
110- export const WithSx = ( { width, height, subtitle} : DialogStoryProps ) => {
111- const [ isOpen , setIsOpen ] = useState ( true )
112- const onDialogClose = useCallback ( ( ) => setIsOpen ( false ) , [ ] )
113- return (
114- < >
115- < Button onClick = { ( ) => setIsOpen ( ! isOpen ) } > Show dialog</ Button >
116- { isOpen && (
117- < Dialog
118- title = "My Dialog"
119- subtitle = { subtitle ? 'This is a subtitle!' : undefined }
120- width = { width }
121- height = { height }
122- renderHeader = { SxHeader }
123- renderBody = { SxBody }
124- renderFooter = { SxFooter }
125- onClose = { onDialogClose }
126- footerButtons = { [
127- { buttonType : 'danger' , content : 'Delete the universe' , onClick : onDialogClose } ,
128- { buttonType : 'primary' , content : 'Proceed' } ,
129- ] }
130- sx = { { borderColor : 'accent.emphasis' , borderWidth : '1px' , borderStyle : 'solid' , animation : 'none !important' } }
131- >
132- { lipsum }
133- </ Dialog >
134- ) }
135- </ >
136- )
137- }
138-
139- function SxAndCssHeader ( {
140- title,
141- subtitle,
142- dialogLabelId,
143- } : React . PropsWithChildren < DialogProps & { dialogLabelId : string } > ) {
144- if ( typeof title === 'string' && typeof subtitle === 'string' ) {
145- return (
146- < Dialog . Header sx = { { color : 'accent.emphasis' } } className = "testCustomClassnameColor" >
147- < h1 id = { dialogLabelId } > { title . toUpperCase ( ) } </ h1 >
148- </ Dialog . Header >
149- )
150- }
151- return null
152- }
153- function SxAndCssBody ( { children} : React . PropsWithChildren < DialogProps > ) {
154- return (
155- < Dialog . Body sx = { { color : 'danger.emphasis' } } className = "testCustomClassnameColor" >
156- { children }
157- </ Dialog . Body >
158- )
159- }
160- function SxAndCssFooter ( { footerButtons} : React . PropsWithChildren < DialogProps > ) {
161- return (
162- < Dialog . Footer sx = { { fontFamily : 'Times New Roman' } } className = "testCustomClassnameMono" >
163- { footerButtons ? < Dialog . Buttons buttons = { footerButtons } /> : null }
164- </ Dialog . Footer >
165- )
166- }
167- export const WithSxAndCss = ( { width, height, subtitle} : DialogStoryProps ) => {
168- const [ isOpen , setIsOpen ] = useState ( true )
169- const onDialogClose = useCallback ( ( ) => setIsOpen ( false ) , [ ] )
170- return (
171- < >
172- < Button onClick = { ( ) => setIsOpen ( ! isOpen ) } > Show dialog</ Button >
173- { isOpen && (
174- < Dialog
175- title = "My Dialog"
176- subtitle = { subtitle ? 'This is a subtitle!' : undefined }
177- width = { width }
178- height = { height }
179- renderHeader = { SxAndCssHeader }
180- renderBody = { SxAndCssBody }
181- renderFooter = { SxAndCssFooter }
182- onClose = { onDialogClose }
183- footerButtons = { [
184- { buttonType : 'danger' , content : 'Delete the universe' , onClick : onDialogClose } ,
185- { buttonType : 'primary' , content : 'Proceed' } ,
186- ] }
187- sx = { { borderColor : 'border.accent' , borderWidth : '1px' , borderStyle : 'solid' , animation : 'none !important' } }
188- className = "testCustomClassnameBorder"
189- >
190- { lipsum }
191- </ Dialog >
192- ) }
193- </ >
194- )
195- }
196-
19790export const WithScrollBody = ( ) => {
19891 const [ isOpen , setIsOpen ] = useState ( false )
19992 const buttonRef = useRef < HTMLButtonElement > ( null )
0 commit comments