Skip to content

Commit 16bff6d

Browse files
rique223dougfabristassoevan
authored
feat(fuselage): Empty Badge and small variants (#876)
* feat: ✨ Create badge small variant Created a smaller variant for the Badge component that will, initially, be used in the Rocket Chat marketplace. * Introduce separate small prop * fix: review * fix review Co-authored-by: dougfabris <devfabris@gmail.com> Co-authored-by: Tasso Evangelista <tasso.evangelista@rocket.chat>
1 parent a16a786 commit 16bff6d

File tree

3 files changed

+28
-4
lines changed

3 files changed

+28
-4
lines changed

packages/fuselage/src/components/Badge/Badge.stories.tsx

+14-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export default {
3636

3737
const Template: ComponentStory<typeof Badge> = (args) => (
3838
<Box display='inline-flex'>
39-
<Badge {...args}>99</Badge>
39+
<Badge {...args} />
4040
</Box>
4141
);
4242

@@ -66,3 +66,16 @@ export const Disabled = Template.bind({});
6666
Disabled.args = {
6767
disabled: true,
6868
};
69+
70+
export const WithValue = Template.bind({});
71+
WithValue.args = {
72+
children: '99',
73+
variant: 'primary',
74+
};
75+
76+
export const Small = Template.bind({});
77+
Small.args = {
78+
children: '',
79+
variant: 'primary',
80+
small: true,
81+
};

packages/fuselage/src/components/Badge/Badge.styles.scss

+6
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ $badge-colors-disabled-background-color: theme(
6363

6464
width: fit-content;
6565
min-width: lengths.size(16);
66+
min-height: lengths.size(16);
6667

6768
padding: lengths.padding(2) lengths.padding(4);
6869

@@ -108,4 +109,9 @@ $badge-colors-disabled-background-color: theme(
108109
color: $badge-colors-disabled-color;
109110
background-color: $badge-colors-disabled-background-color;
110111
}
112+
113+
&--small {
114+
min-width: lengths.size(8);
115+
min-height: lengths.size(8);
116+
}
111117
}

packages/fuselage/src/components/Badge/Badge.tsx

+8-3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { prependClassName } from '../../helpers/prependClassName';
66
export type BadgeProps = {
77
is?: ElementType;
88
variant?: 'secondary' | 'primary' | 'danger' | 'warning' | 'ghost';
9+
small?: boolean;
910
disabled?: boolean;
1011
className?: string;
1112
children?: any;
@@ -15,17 +16,21 @@ export type BadgeProps = {
1516
export function Badge({
1617
is: Tag = 'span',
1718
variant = 'secondary',
19+
small,
1820
className,
1921
disabled,
2022
...props
2123
}: BadgeProps) {
24+
const modifiers = [variant, small && 'small', disabled && 'disabled']
25+
.filter(Boolean)
26+
.map((modifier) => `rcx-badge--${modifier}`)
27+
.join(' ');
28+
2229
return (
2330
<Tag
2431
className={prependClassName(
2532
className,
26-
`rcx-box rcx-box--full rcx-badge ${
27-
disabled ? 'rcx-badge--disabled' : ''
28-
} rcx-badge--${variant}`
33+
`rcx-box rcx-box--full rcx-badge ${modifiers}`
2934
)}
3035
{...props}
3136
/>

0 commit comments

Comments
 (0)