Skip to content

Commit c33a175

Browse files
committed
react-native: BadgeCount – restore size-specific line-heights and correct twClassName precedence; remove invalid leading-0
1 parent 89130cc commit c33a175

2 files changed

Lines changed: 15 additions & 1 deletion

File tree

packages/design-system-react-native/src/components/BadgeCount/BadgeCount.constants.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,12 @@ export const TWCLASSMAP_BADGECOUNT_SIZE_CONTAINER: Record<
1818
[BadgeCountSize.Md]: 'min-w-4 h-3.5 py-0 px-1', // min-width 16px, height 14px, padding-vertical 0, padding-horizontal 4
1919
[BadgeCountSize.Lg]: 'min-w-6 h-5 py-0.5 px-1.5', // min-width 24px, height 20px, padding-vertical 2, padding-horizontal 6
2020
};
21+
22+
export const TWCLASSMAP_BADGECOUNT_SIZE_LINEHEIGHT: Record<
23+
BadgeCountSize,
24+
string
25+
> = {
26+
// Match text line-height to container height
27+
[BadgeCountSize.Md]: 'leading-[14px]',
28+
[BadgeCountSize.Lg]: 'leading-[16px]',
29+
};

packages/design-system-react-native/src/components/BadgeCount/BadgeCount.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { Text, TextColor, FontWeight } from '../Text';
88
import {
99
MAP_BADGECOUNT_SIZE_TEXTVARIANT,
1010
TWCLASSMAP_BADGECOUNT_SIZE_CONTAINER,
11+
TWCLASSMAP_BADGECOUNT_SIZE_LINEHEIGHT,
1112
} from './BadgeCount.constants';
1213
import type { BadgeCountProps } from './BadgeCount.types';
1314

@@ -38,8 +39,12 @@ export const BadgeCount = ({
3839
variant={MAP_BADGECOUNT_SIZE_TEXTVARIANT[size]}
3940
color={TextColor.ErrorInverse}
4041
fontWeight={FontWeight.Medium}
41-
twClassName="leading-0"
4242
{...textProps}
43+
twClassName={
44+
textProps?.twClassName
45+
? textProps.twClassName
46+
: TWCLASSMAP_BADGECOUNT_SIZE_LINEHEIGHT[size]
47+
}
4348
>
4449
{count > max ? `${max}+` : `${count}`}
4550
</Text>

0 commit comments

Comments
 (0)