This repository was archived by the owner on Feb 19, 2025. It is now read-only.
File tree 3 files changed +37
-21
lines changed
3 files changed +37
-21
lines changed Original file line number Diff line number Diff line change @@ -79,6 +79,13 @@ export const Closable = (args: any) => (
79
79
</ Alert >
80
80
)
81
81
82
+ export const WithAction = ( args : any ) => (
83
+ < Alert { ...args } >
84
+ Lorem ipsum dolor sit amet consectetur adipisicing elit. Consequatur amet
85
+ labore.
86
+ </ Alert >
87
+ )
88
+
82
89
Neutral . args = {
83
90
title : 'Success alert with icon' ,
84
91
withIcon : true ,
@@ -132,3 +139,10 @@ Closable.args = {
132
139
title : 'Closable alert' ,
133
140
closable : true ,
134
141
}
142
+
143
+ WithAction . args = {
144
+ title : 'Alert with action' ,
145
+ variant : 'warning' ,
146
+ withIcon : true ,
147
+ actions : < div > Hello</ div > ,
148
+ }
Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ interface Props {
18
18
closable ?: boolean
19
19
children ?: React . ReactNode
20
20
icon ?: React . ReactNode
21
+ actions ?: React . ReactNode
21
22
}
22
23
23
24
const icons : Record <
@@ -39,6 +40,7 @@ function Alert({
39
40
closable,
40
41
children,
41
42
icon,
43
+ actions,
42
44
} : Props ) {
43
45
let __styles = styleHandler ( 'alert' )
44
46
@@ -59,30 +61,33 @@ function Alert({
59
61
< >
60
62
{ visible && (
61
63
< div className = { containerClasses . join ( ' ' ) } >
62
- { withIcon ? (
63
- < div className = { __styles . variant [ variant ] . icon } >
64
- { withIcon && icons [ variant ] }
64
+ < div className = "flex space-x-4" >
65
+ { withIcon ? (
66
+ < div className = { __styles . variant [ variant ] . icon } >
67
+ { withIcon && icons [ variant ] }
68
+ </ div >
69
+ ) : null }
70
+ { icon && icon }
71
+ < div >
72
+ < h3
73
+ className = { [
74
+ __styles . variant [ variant ] . header ,
75
+ __styles . header ,
76
+ ] . join ( ' ' ) }
77
+ >
78
+ { title }
79
+ </ h3 >
80
+ < div className = { descriptionClasses . join ( ' ' ) } > { children } </ div >
65
81
</ div >
66
- ) : null }
67
- { icon && icon }
68
- < div >
69
- < h3
70
- className = { [
71
- __styles . variant [ variant ] . header ,
72
- __styles . header ,
73
- ] . join ( ' ' ) }
74
- >
75
- { title }
76
- </ h3 >
77
- < div className = { descriptionClasses . join ( ' ' ) } > { children } </ div >
78
82
</ div >
83
+ { actions }
79
84
{ closable && (
80
85
< button
81
86
aria-label = "Close alert"
82
87
onClick = { ( ) => setVisible ( false ) }
83
88
className = { closeButtonClasses . join ( ' ' ) }
84
89
>
85
- < IconX strokeWidth = { 1.5 } size = { 14 } />
90
+ < IconX strokeWidth = { 2 } size = { 16 } />
86
91
</ button >
87
92
) }
88
93
</ div >
Original file line number Diff line number Diff line change @@ -252,11 +252,8 @@ export default {
252
252
253
253
alert : {
254
254
base : `
255
- relative
256
- rounded
257
- py-4 px-6
258
- flex space-x-4 items-start
259
- border
255
+ relative rounded border py-4 px-6
256
+ flex justify-between space-x-4 items-start
260
257
` ,
261
258
header : 'block text-sm font-normal mb-1' ,
262
259
description : `text-xs` ,
You can’t perform that action at this time.
0 commit comments