@@ -29,15 +29,17 @@ interface BadgeProps extends Omit<HTMLProps<HTMLSpanElement>, "size"> {
29
29
}
30
30
* @returns {ReactElement }
31
31
*/
32
- export default function Badge ( { customStyle, value, size = "small" , className, testId = "badgeId" , ...props } : BadgeProps ) : ReactElement {
33
- const sizeClasses = useMemo (
34
- ( ) =>
35
- ( {
36
- medium : "w-6 h-6 text-sm" ,
37
- small : "h-4 w-4 text-xxs" ,
38
- } [ size ] ) ,
39
- [ size ]
40
- ) ;
32
+ export default function Badge ( { customStyle, value, size = "medium" , className, testId = "badgeId" , ...props } : BadgeProps ) : ReactElement {
33
+ const sizeClasses = useMemo ( ( ) => {
34
+ const expandedClasses = "w-7 h-7" ;
35
+ const defaultClasses = "w-6 h-6" ;
36
+
37
+ if ( value && value . toString ( ) . length >= 3 ) {
38
+ return expandedClasses ;
39
+ }
40
+ if ( size === "small" ) return "w-4 h-4" ;
41
+ return defaultClasses ;
42
+ } , [ value , size ] ) ;
41
43
42
44
const router = useRouter ( ) ;
43
45
const isCommunity : boolean = router . pathname . startsWith ( "communities-slug__" ) ;
@@ -50,7 +52,7 @@ export default function Badge({ customStyle, value, size = "small", className, t
50
52
data-testid = { testId }
51
53
{ ...props }
52
54
className = { classNames (
53
- " font-semibold leading-3 text-center inline-flex items-center justify-center rounded-full text-xxs",
55
+ ` font-semibold leading-3 text-center inline-flex items-center justify-center rounded-full ${ size === "small" ? " text-xxs": "text-sm" } ` ,
54
56
sizeClasses ,
55
57
className ,
56
58
{ "bg-white text-gray-900" : isCommunity } ,
0 commit comments