1- import * as Icons from '@heroicons/ react/24/solid '
1+ import * as Icons from '@tabler/icons- react'
22import classNames from '~/lib/classNames'
3+ import DynamicIcon from './DynamicIcon'
34
45export type AlertProps = React . HTMLAttributes < HTMLDivElement > & {
56 title : string
@@ -26,26 +27,18 @@ export default function Alert({
2627 const getDefaultIcon = ( ) : keyof typeof Icons => {
2728 switch ( type ) {
2829 case 'warning' :
29- return 'ExclamationTriangleIcon '
30+ return 'IconAlertTriangle '
3031 case 'error' :
31- return 'XCircleIcon '
32+ return 'IconXboxX '
3233 case 'success' :
33- return 'CheckCircleIcon '
34+ return 'IconCircleCheck '
3435 case 'info' :
35- return 'InformationCircleIcon '
36+ return 'IconInfoCircle '
3637 default :
37- return 'InformationCircleIcon '
38+ return 'IconInfoCircle '
3839 }
3940 }
4041
41- const IconComponent = ( ) => {
42- const iconName = icon || getDefaultIcon ( )
43- const Icon = Icons [ iconName ]
44- if ( ! Icon ) return null
45-
46- return < Icon aria-hidden = "true" className = { classNames ( 'size-5 shrink-0' , getIconColor ( ) ) } />
47- }
48-
4942 const getIconColor = ( ) => {
5043 if ( variant === 'solid' ) return 'text-desert-white'
5144 switch ( type ) {
@@ -165,7 +158,7 @@ export default function Alert({
165158 return (
166159 < div { ...props } className = { classNames ( getVariantStyles ( ) , 'p-4' , props . className ) } role = "alert" >
167160 < div className = "flex gap-3" >
168- < IconComponent />
161+ < DynamicIcon icon = { getDefaultIcon ( ) } className = { getIconColor ( ) + ' size-5 shrink-0' } />
169162
170163 < div className = "flex-1 min-w-0" >
171164 < h3 className = { classNames ( 'text-sm font-semibold' , getTitleColor ( ) ) } > { title } </ h3 >
@@ -192,7 +185,7 @@ export default function Alert({
192185 ) }
193186 aria-label = "Dismiss alert"
194187 >
195- < Icons . XMarkIcon className = "size-5" />
188+ < DynamicIcon icon = "IconX" className = "size-5" />
196189 </ button >
197190 ) }
198191 </ div >
0 commit comments