File tree Expand file tree Collapse file tree
apps/docs/src/components/Badge Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -3,18 +3,33 @@ import React from 'react';
33
44interface BadgeProps {
55 title : string ;
6- icon ?: string | null ;
7- variant ?: 'primary' | 'secondary' ;
6+ icon ?: string | null | React . ReactNode ;
7+ variant ?: 'primary' | 'secondary' | 'light' | 'dark' ;
88}
99
10+ const getVariantClasses = ( variant : BadgeProps [ 'variant' ] ) : string => {
11+ switch ( variant ) {
12+ case 'primary' :
13+ return 'bg-violet text-white!' ;
14+ case 'secondary' :
15+ return 'bg-secondary text-dark-text!' ;
16+ case 'light' :
17+ return 'bg-white text-violet' ;
18+ case 'dark' :
19+ return 'bg-white/10 text-white' ;
20+ default :
21+ return 'bg-violet text-white!' ;
22+ }
23+ } ;
24+
1025const Badge : React . FC < BadgeProps > = ( { title, icon, variant = 'primary' } ) => (
1126 < div
1227 className = { clsx (
1328 'flex items-center justify-center gap-2.5 px-2.5 py-0.5 rounded-full' ,
14- variant === 'primary' ? 'bg-violet text-white!' : 'bg-secondary text-dark-text!' ,
29+ getVariantClasses ( variant ) ,
1530 ) }
1631 >
17- { icon && < img src = { icon } alt = { title + ' logo' } className = "w-4 h-4" /> }
32+ { icon && typeof icon === 'string' ? < img src = { icon } alt = { title + ' logo' } className = "w-4 h-4" /> : icon }
1833 < span className = { clsx ( 'text-sm' , variant === 'primary' ? '' : 'font-semibold' ) } > { title } </ span >
1934 </ div >
2035) ;
You can’t perform that action at this time.
0 commit comments