Skip to content

Commit f88c4e9

Browse files
author
Danish Ali
committed
feat: #242 updated v5 badge component with the PR review
1 parent 4e15ca8 commit f88c4e9

File tree

6 files changed

+60
-270
lines changed

6 files changed

+60
-270
lines changed

src/components/badge/__tests__/__snapshots__/badge.test.tsx.snap

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ exports[`Badge > should match snapshot 1`] = `
44
<DocumentFragment>
55
<div
66
class="mocked-styled-0 el-badge"
7-
data-reversed="false"
7+
data-isreversed="false"
88
role="status"
99
>
1010
<span
@@ -21,7 +21,7 @@ exports[`Badge > should match snapshot with icon only 1`] = `
2121
<div
2222
aria-label="label"
2323
class="mocked-styled-0 el-badge"
24-
data-reversed="false"
24+
data-isreversed="false"
2525
role="status"
2626
>
2727
<span
@@ -52,7 +52,7 @@ exports[`Badge > should match snapshot with icons and label 1`] = `
5252
<DocumentFragment>
5353
<div
5454
class="mocked-styled-0 el-badge"
55-
data-reversed="false"
55+
data-isreversed="false"
5656
role="status"
5757
>
5858
<span
@@ -108,7 +108,7 @@ exports[`Badge > should match snapshot with reversed badge 1`] = `
108108
<DocumentFragment>
109109
<div
110110
class="mocked-styled-0 el-badge"
111-
data-reversed="true"
111+
data-isreversed="true"
112112
role="status"
113113
>
114114
<span
@@ -124,7 +124,7 @@ exports[`Badge > should match snapshot with success variant and label 1`] = `
124124
<DocumentFragment>
125125
<div
126126
class="mocked-styled-0 el-badge"
127-
data-reversed="false"
127+
data-isreversed="false"
128128
data-variant="success"
129129
role="status"
130130
>

src/components/badge/__tests__/badge.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ describe('Badge', () => {
99
})
1010

1111
test('should match snapshot with reversed badge', () => {
12-
const { asFragment } = render(<Badge reversed>Label</Badge>)
12+
const { asFragment } = render(<Badge isReversed>Label</Badge>)
1313
expect(asFragment()).toMatchSnapshot()
1414
})
1515

src/components/badge/badge.mdx

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,36 +12,40 @@ Styled badge component with multiple flavours depending on use case.
1212

1313
## Default Usage
1414

15-
A button with no additional props / classes applied
15+
A badge with no additional props / classes applied
1616

1717
<Canvas of={BadgeStories.Default} />
1818

1919
<RenderHtmlMarkup of={BadgeStories.Default} />
2020

2121
## Badge Reversed
2222

23+
In order to reverse a badge you will just need to provide a prop called `isReversed`. If you have icon left and icon right with the badge it will be reversed as well.
24+
2325
<Canvas of={BadgeStories.BadgeReversed} />
2426
<RenderHtmlMarkup of={BadgeStories.BadgeReversed} />
2527

2628
## Badge with Label
2729

28-
Badge should always hava a label for accessibility and clear comprehension.
30+
Badge can hava a label with icons for with icons.
2931

3032
<Canvas of={BadgeStories.BadgeWithLabel} />
3133
<RenderHtmlMarkup of={BadgeStories.BadgeWithLabel} />
3234

33-
## Badge without Label
35+
## Badge with Icon
3436

35-
A badge without label can be used when not enogh space is available. It should always include a tooltip on hover to provide more context for the icon meaning.
37+
A badge can be with just an icon for accessibility you will need to add an `aria-label` with it. It should be wrapped with a tooltip component to provide more context for the icon meaning.
3638

37-
<Canvas of={BadgeStories.BadgeWithoutLabel} />
38-
<RenderHtmlMarkup of={BadgeStories.BadgeWithoutLabel} />
39+
<Canvas of={BadgeStories.BadgeWithIcon} />
40+
<RenderHtmlMarkup of={BadgeStories.BadgeWithIcon} />
3941

4042
## Badge Variants
4143

4244
Different variants are supported, to enable badge to be used in different contexts.
4345

44-
`Badge` only support `neutral`, `success`, `pending`, `warning`, `danger`, `inactive`, `accent_1` and `accent_2`, the `neutral` being the default.
46+
`Badge` only support `neutral`, `success`, `pending`, `warning`, `danger`, `inactive`, `accent_1` and `accent_2`.
47+
48+
The `neutral` is the default variant for the badge component.
4549

46-
<Canvas of={BadgeStories.BadgeWithVariant} />
47-
<RenderHtmlMarkup of={BadgeStories.BadgeWithVariant} />
50+
<Canvas of={BadgeStories.BadgeVariant} />
51+
<RenderHtmlMarkup of={BadgeStories.BadgeVariant} />

0 commit comments

Comments
 (0)