@@ -7,24 +7,21 @@ import { TriangleWarningIcon } from 'lib/icons/TriangleWarning.js'
77export interface AlertProps {
88 variant : 'warning' | 'error'
99 message : string
10- action ?: {
11- label : string
12- onClick : MouseEventHandler
13- }
10+ action ?: ActionProps
1411 className ?: string
1512}
1613
17- export function Alert ( props : AlertProps ) : JSX . Element {
18- const { variant, message, action, className, ...rest } = props
14+ interface ActionProps {
15+ label : string
16+ onClick : MouseEventHandler
17+ }
1918
20- const handleClick : MouseEventHandler < HTMLButtonElement > = ( ev ) => {
21- action ?. onClick ( ev )
22- }
19+ export function Alert ( props : AlertProps ) : JSX . Element {
20+ const { variant, message, className } = props
2321
2422 return (
2523 < div
2624 className = { classNames ( 'seam-alert' , `seam-${ variant } -alert` , className ) }
27- { ...rest }
2825 >
2926 < div className = 'seam-alert-content' >
3027 < div className = 'seam-alert-icon' >
@@ -34,19 +31,25 @@ export function Alert(props: AlertProps): JSX.Element {
3431 < ExclamationCircleIcon />
3532 ) }
3633 </ div >
37-
3834 < div className = 'seam-alert-message-wrap' >
3935 < p className = 'seam-alert-message' > { message } </ p >
4036 </ div >
4137 </ div >
38+ { props . action == null ? null : < Action { ...props . action } /> }
39+ </ div >
40+ )
41+ }
4242
43- { action != null && (
44- < div className = 'seam-alert-action-wrap' >
45- < button onClick = { handleClick } className = 'seam-alert-action' >
46- { action . label }
47- </ button >
48- </ div >
49- ) }
43+ function Action ( props : ActionProps ) : JSX . Element | null {
44+ const handleClick : MouseEventHandler < HTMLButtonElement > = ( event ) => {
45+ props . onClick ( event )
46+ }
47+
48+ return (
49+ < div className = 'seam-alert-action-wrap' >
50+ < button onClick = { handleClick } className = 'seam-alert-action' >
51+ { props . label }
52+ </ button >
5053 </ div >
5154 )
5255}
0 commit comments