Skip to content

Commit f11f809

Browse files
ariellalgilmore2nikhiltomannawen1
authored
feat(badge-indicators): new component (#18342)
* feat(badge-indicators): new component * fix(badge): clean up stories and add imports * test(avt): badge indicator * fix(button): revert * fix(Styles): badge * chore(test): update * fix(badge-indicator): make internal and add prop * fix(badgeIndicator): add badgeCountLabel * refactor: combines label and badgeLabel props * fix: updates SR announcement & stories * fix(iconButton): default is really lg and label * fix(badgeIndicator): remove badgeCountLabel use aria-describedby * fix(button): cleanup * fix(icon-button): badgeId and label description * feat: badge compononent for WC * chore: revert tabs changes * fix(badge-indicator): remove when disabled * fix: adds warnings for invalid prop usage * fix: cleanup in iconbutton * chore: clean up on IconButton * chore(test): add avt/e2e * fix(button): align wc stories * Update packages/react/src/index.ts --------- Co-authored-by: Nikhil Tomar <nikhiltomar753@gmail.com> Co-authored-by: Nikhil Tomar <63502271+2nikhiltom@users.noreply.github.com> Co-authored-by: Anna Wen <54281166+annawen1@users.noreply.github.com>
1 parent 2dd87e0 commit f11f809

File tree

32 files changed

+568
-27
lines changed

32 files changed

+568
-27
lines changed

e2e/components/Button/Button-test.avt.e2e.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,17 @@ test.describe('@avt Button', () => {
5555
await expect(page).toHaveNoACViolations('Button-icon-button');
5656
});
5757

58+
test('@avt-advanced-states icon-button with badge', async ({ page }) => {
59+
await visitStory(page, {
60+
component: 'Button',
61+
id: 'components-button--icon-button-with-badge',
62+
globals: {
63+
theme: 'white',
64+
},
65+
});
66+
await expect(page).toHaveNoACViolations('Button-icon-button-with-badge');
67+
});
68+
5869
test('@avt-advanced-states secondary', async ({ page }) => {
5970
await visitStory(page, {
6071
component: 'Button',

e2e/components/Button/Button-test.e2e.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,14 @@ test.describe('Button', () => {
6262
});
6363
});
6464

65+
test('icon button with badge indicator @vrt', async ({ page }) => {
66+
await snapshotStory(page, {
67+
component: 'Button',
68+
id: 'components-button--icon-button-with-badge',
69+
theme,
70+
});
71+
});
72+
6573
test('set of buttons @vrt', async ({ page }) => {
6674
await snapshotStory(page, {
6775
component: 'Button',
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// Code generated by carbon-components-react. DO NOT EDIT.
2+
//
3+
// Copyright IBM Corp. 2018, 2023
4+
//
5+
// This source code is licensed under the Apache-2.0 license found in the
6+
// LICENSE file in the root directory of this source tree.
7+
//
8+
9+
@forward '@carbon/styles/scss/components/badge-indicator/badge-indicator';
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// Code generated by carbon-components-react. DO NOT EDIT.
2+
//
3+
// Copyright IBM Corp. 2018, 2023
4+
//
5+
// This source code is licensed under the Apache-2.0 license found in the
6+
// LICENSE file in the root directory of this source tree.
7+
//
8+
9+
@forward '@carbon/styles/scss/components/badge-indicator';
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// Code generated by carbon-components. DO NOT EDIT.
2+
//
3+
// Copyright IBM Corp. 2018, 2023
4+
//
5+
// This source code is licensed under the Apache-2.0 license found in the
6+
// LICENSE file in the root directory of this source tree.
7+
//
8+
9+
@forward '@carbon/styles/scss/components/badge-indicator/badge-indicator';
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// Code generated by carbon-components. DO NOT EDIT.
2+
//
3+
// Copyright IBM Corp. 2018, 2023
4+
//
5+
// This source code is licensed under the Apache-2.0 license found in the
6+
// LICENSE file in the root directory of this source tree.
7+
//
8+
9+
@forward '@carbon/styles/scss/components/badge-indicator';

packages/react/__tests__/__snapshots__/PublicAPI-test.js.snap

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4240,6 +4240,9 @@ Map {
42404240
"autoAlign": Object {
42414241
"type": "bool",
42424242
},
4243+
"badgeCount": Object {
4244+
"type": "number",
4245+
},
42434246
"children": Object {
42444247
"type": "node",
42454248
},
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// Code generated by @carbon/react. DO NOT EDIT.
2+
//
3+
// Copyright IBM Corp. 2018, 2023
4+
//
5+
// This source code is licensed under the Apache-2.0 license found in the
6+
// LICENSE file in the root directory of this source tree.
7+
//
8+
9+
@forward '@carbon/styles/scss/components/badge-indicator/badge-indicator';
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// Code generated by @carbon/react. DO NOT EDIT.
2+
//
3+
// Copyright IBM Corp. 2018, 2023
4+
//
5+
// This source code is licensed under the Apache-2.0 license found in the
6+
// LICENSE file in the root directory of this source tree.
7+
//
8+
9+
@forward '@carbon/styles/scss/components/badge-indicator';
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// /**
2+
// * Copyright IBM Corp. 2016, 2023
3+
// *
4+
// * This source code is licensed under the Apache-2.0 license found in the
5+
// * LICENSE file in the root directory of this source tree.
6+
// */
7+
8+
import { render, screen } from '@testing-library/react';
9+
import React from 'react';
10+
import BadgeIndicator from '../index';
11+
12+
describe('BadgeIndicator', () => {
13+
it('should set a count', () => {
14+
render(<BadgeIndicator count={3} />);
15+
expect(screen.getByText('3')).toBeInTheDocument();
16+
});
17+
18+
it('should truncate the count over 999', () => {
19+
render(<BadgeIndicator count={2342} />);
20+
expect(screen.getByText('999+')).toBeInTheDocument();
21+
});
22+
23+
it('should support a custom class name on the outermost element', () => {
24+
const { container } = render(<BadgeIndicator className="custom-class" />);
25+
expect(container.firstChild).toHaveClass('custom-class');
26+
});
27+
28+
it('should support a ref on the outermost element', () => {
29+
const ref = jest.fn();
30+
const { container } = render(<BadgeIndicator ref={ref} />);
31+
expect(ref).toHaveBeenCalledWith(container.firstChild);
32+
});
33+
});

0 commit comments

Comments
 (0)