11import * as Icons from '@tabler/icons-react'
22import classNames from '~/lib/classNames'
33import DynamicIcon from './DynamicIcon'
4+ import StyledButton , { StyledButtonProps } from './StyledButton'
45
56export type AlertProps = React . HTMLAttributes < HTMLDivElement > & {
67 title : string
@@ -11,6 +12,7 @@ export type AlertProps = React.HTMLAttributes<HTMLDivElement> & {
1112 onDismiss ?: ( ) => void
1213 icon ?: keyof typeof Icons
1314 variant ?: 'standard' | 'bordered' | 'solid'
15+ buttonProps ?: StyledButtonProps
1416}
1517
1618export default function Alert ( {
@@ -22,6 +24,7 @@ export default function Alert({
2224 onDismiss,
2325 icon,
2426 variant = 'standard' ,
27+ buttonProps,
2528 ...props
2629} : AlertProps ) {
2730 const getDefaultIcon = ( ) : keyof typeof Icons => {
@@ -56,7 +59,7 @@ export default function Alert({
5659 }
5760
5861 const getVariantStyles = ( ) => {
59- const baseStyles = 'rounded-md transition-all duration-200'
62+ const baseStyles = 'rounded-lg transition-all duration-200'
6063 const variantStyles : string [ ] = [ ]
6164
6265 switch ( variant ) {
@@ -72,20 +75,20 @@ export default function Alert({
7275 ? 'border-desert-stone'
7376 : ''
7477 )
75- return classNames ( baseStyles , 'border-2 bg-desert-white' , ...variantStyles )
78+ return classNames ( baseStyles , 'border-2 bg-desert-white shadow-md ' , ...variantStyles )
7679 case 'solid' :
7780 variantStyles . push (
7881 type === 'warning'
79- ? 'bg-desert-orange text-desert-white border-desert-orange-dark'
82+ ? 'bg-desert-orange text-desert-white border border -desert-orange-dark'
8083 : type === 'error'
81- ? 'bg-desert-red text-desert-white border-desert-red-dark'
84+ ? 'bg-desert-red text-desert-white border border -desert-red-dark'
8285 : type === 'success'
83- ? 'bg-desert-olive text-desert-white border-desert-olive-dark'
86+ ? 'bg-desert-olive text-desert-white border border -desert-olive-dark'
8487 : type === 'info'
85- ? 'bg-desert-green text-desert-white border-desert-green-dark'
88+ ? 'bg-desert-green text-desert-white border border -desert-green-dark'
8689 : ''
8790 )
88- return classNames ( baseStyles , 'shadow-sm ' , ...variantStyles )
91+ return classNames ( baseStyles , 'shadow-lg ' , ...variantStyles )
8992 default :
9093 variantStyles . push (
9194 type === 'warning'
@@ -98,7 +101,7 @@ export default function Alert({
98101 ? 'bg-desert-green bg-opacity-20 border-desert-green-light'
99102 : ''
100103 )
101- return classNames ( baseStyles , 'border shadow-sm' , ...variantStyles )
104+ return classNames ( baseStyles , 'border-l-4 border-y border-r shadow-sm' , ...variantStyles )
102105 }
103106 }
104107
@@ -156,36 +159,44 @@ export default function Alert({
156159 }
157160
158161 return (
159- < div { ...props } className = { classNames ( getVariantStyles ( ) , 'p-4' , props . className ) } role = "alert" >
160- < div className = "flex gap-3" >
161- < DynamicIcon icon = { getDefaultIcon ( ) } className = { getIconColor ( ) + ' size-5 shrink-0' } />
162+ < div { ...props } className = { classNames ( getVariantStyles ( ) , 'p-5' , props . className ) } role = "alert" >
163+ < div className = "flex gap-4 items-center" >
164+ < div className = "flex-shrink-0 mt-0.5" >
165+ < DynamicIcon icon = { icon || getDefaultIcon ( ) } className = { classNames ( getIconColor ( ) , 'size-6' ) } />
166+ </ div >
162167
163168 < div className = "flex-1 min-w-0" >
164- < h3 className = { classNames ( 'text-sm font-semibold' , getTitleColor ( ) ) } > { title } </ h3 >
169+ < h3 className = { classNames ( 'text-base font-semibold leading-tight ' , getTitleColor ( ) ) } > { title } </ h3 >
165170 { message && (
166- < div className = { classNames ( 'mt-1 text-sm' , getMessageColor ( ) ) } >
171+ < div className = { classNames ( 'mt-2 text-sm leading-relaxed ' , getMessageColor ( ) ) } >
167172 < p > { message } </ p >
168173 </ div >
169174 ) }
170175 { children && < div className = "mt-3" > { children } </ div > }
171176 </ div >
172177
178+ { buttonProps && (
179+ < div className = "flex-shrink-0 ml-auto" >
180+ < StyledButton { ...buttonProps } />
181+ </ div >
182+ ) }
183+
173184 { dismissible && (
174185 < button
175186 type = "button"
176187 onClick = { onDismiss }
177188 className = { classNames (
178- 'shrink-0 rounded-md p-1.5 transition-colors duration-150 ' ,
189+ 'flex- shrink-0 rounded-lg p-1.5 transition-all duration-200 ' ,
179190 getCloseButtonStyles ( ) ,
180- 'focus:outline-none focus:ring-2 focus:ring-offset-2 ' ,
191+ 'focus:outline-none focus:ring-2 focus:ring-offset-1 ' ,
181192 type === 'warning' ? 'focus:ring-desert-orange' : '' ,
182193 type === 'error' ? 'focus:ring-desert-red' : '' ,
183194 type === 'success' ? 'focus:ring-desert-olive' : '' ,
184195 type === 'info' ? 'focus:ring-desert-stone' : ''
185196 ) }
186197 aria-label = "Dismiss alert"
187198 >
188- < DynamicIcon icon = "IconX" className = "size-5 " />
199+ < DynamicIcon icon = "IconX" className = "size-4 " />
189200 </ button >
190201 ) }
191202 </ div >
0 commit comments