Skip to content

Commit 7ab5ee0

Browse files
committed
Badge: Label as children
1 parent 651212b commit 7ab5ee0

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

src/Badge.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export type BadgeProps = {
1111
severity?: AlertProps.Severity | "new";
1212
small?: boolean;
1313
noIcon?: boolean;
14-
label: NonNullable<ReactNode>;
14+
children: NonNullable<ReactNode>;
1515
};
1616

1717
/** @see <https://react-dsfr-components.etalab.studio/?path=/docs/components-badge> */
@@ -20,9 +20,9 @@ export const Badge = memo(
2020
const {
2121
className,
2222
severity,
23-
label,
2423
small: isSmall = false,
2524
noIcon = false,
25+
children,
2626
...rest
2727
} = props;
2828

@@ -42,7 +42,7 @@ export const Badge = memo(
4242
ref={ref}
4343
{...rest}
4444
>
45-
{label}
45+
{children}
4646
</p>
4747
);
4848
})

stories/Badge.stories.tsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ const { meta, getStory } = getStoryFactory<BadgeProps>({
3030
"type": { "name": "boolean" },
3131
"description": "Set small badge size (`sm`) when true"
3232
},
33-
"label": {
33+
"children": {
3434
"type": { "name": "string", "required": true },
3535
"description": "Label to display on the badge"
3636
}
@@ -42,12 +42,12 @@ export default meta;
4242

4343
export const Default = getStory({
4444
"severity": "success",
45-
"label": "Label badge"
45+
"children": "Label badge"
4646
});
4747

4848
export const BadgeWithoutSeverity = getStory(
4949
{
50-
"label": "Label"
50+
"children": "Label"
5151
},
5252
{
5353
"description": "Medium info `Badge` with icon"
@@ -57,7 +57,7 @@ export const BadgeWithoutSeverity = getStory(
5757
export const InfoBadge = getStory(
5858
{
5959
"severity": "info",
60-
"label": "Label info"
60+
"children": "Label info"
6161
},
6262
{
6363
"description": "Medium info `Badge` with icon"
@@ -68,7 +68,7 @@ export const WarningBadge = getStory(
6868
{
6969
"severity": "warning",
7070
"noIcon": false,
71-
"label": 'Label "warning"'
71+
"children": 'Label "warning"'
7272
},
7373
{
7474
"description": "Medium warning `Badge` with icon"
@@ -79,7 +79,7 @@ export const SuccessBadge = getStory(
7979
{
8080
"severity": "success",
8181
"noIcon": true,
82-
"label": "Label success"
82+
"children": "Label success"
8383
},
8484
{
8585
"description": "Medium success `Badge` without icon"
@@ -90,7 +90,7 @@ export const ErrorBadge = getStory(
9090
{
9191
"severity": "error",
9292
"noIcon": true,
93-
"label": "Label error"
93+
"children": "Label error"
9494
},
9595
{
9696
"description": "Medium error `Badge` without icon"
@@ -101,7 +101,7 @@ export const NewBadge = getStory(
101101
{
102102
"severity": "new",
103103
"small": true,
104-
"label": "Label new"
104+
"children": "Label new"
105105
},
106106
{
107107
"description": "Small new `Badge` with icon"

0 commit comments

Comments
 (0)