Skip to content

Commit

Permalink
Feat: change CounterBadge to NumberBadge (#1027)
Browse files Browse the repository at this point in the history
closes #681

---------

Signed-off-by: Adham AboHasson <[email protected]>
  • Loading branch information
AdhamAH authored Dec 19, 2024
1 parent dff690f commit 5646634
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 27 deletions.
15 changes: 0 additions & 15 deletions packages/components-react/src/BadgeCounter.test.tsx

This file was deleted.

1 change: 0 additions & 1 deletion packages/components-react/src/BadgeCounter.tsx

This file was deleted.

28 changes: 28 additions & 0 deletions packages/components-react/src/NumberBadge.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import '@testing-library/jest-dom';

import { render, screen } from '@testing-library/react';
import { NumberBadge } from './NumberBadge';

describe('numberBadge', () => {
it('renders a visible element', () => {
const { container } = render(<NumberBadge />);

const numberBadge = container.querySelector(':only-child');

expect(numberBadge).toBeInTheDocument();
expect(numberBadge).toBeVisible();
});
it('renders a visible element with a number', () => {
render(<NumberBadge data-testid="test-id">5</NumberBadge>);
expect(screen.getByTestId('test-id').textContent).toBe('5');
});
it('render value en children', () => {
render(
<NumberBadge data-testid="test-id" value={'5555'}>
5,555
</NumberBadge>,
);
expect(screen.getByTestId('test-id').textContent).toBe('5,555');
expect(screen.getByTestId('test-id').getAttribute('value')).toBe('5555');
});
});
4 changes: 4 additions & 0 deletions packages/components-react/src/NumberBadge.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export {
BadgeCounter as NumberBadge,
type BadgeCounterProps as NumberBadgeProps,
} from '@utrecht/component-library-react';
2 changes: 1 addition & 1 deletion packages/components-react/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ export {
export { ActionGroup, type ActionGroupProps } from './ActionGroup';
export { Alert, type AlertProps } from './Alert';
export { Article } from './Article';
export { BadgeCounter } from './BadgeCounter';
export { Blockquote, type BlockquoteProps } from './Blockquote';
export {
BreadcrumbNav,
Expand Down Expand Up @@ -92,6 +91,7 @@ export {
} from './NavBar';
export { NavigationList, type NavigationListProps } from './NavigationList';
export { NavigationListItem, type NavigationListItemProps } from './NavigationListItem';
export { NumberBadge, type NumberBadgeProps } from './NumberBadge';
export { OrderedList, OrderedListItem, type OrderedListItemProps, type OrderedListProps } from './OrderedList';
export { PageContent, type PageContentProps } from './PageContent';
export { PageHeader, type PageHeaderProps } from './PageHeader';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!-- @license CC0-1.0 -->

# Rijkshuisstijl Community Counter Badge component
# Rijkshuisstijl Community Number Badge component

Een counter badge is een badge die een getal toont.
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { BadgeCounter } from '@rijkshuisstijl-community/components-react';
import { NumberBadge } from '@rijkshuisstijl-community/components-react';
import { Meta, StoryObj } from '@storybook/react';
import readme from './counter-badge.md?raw';
import readme from './number-badge.md?raw';
const meta = {
title: 'Rijkshuisstijl/Counter Badge',
title: 'Rijkshuisstijl/Number Badge',
id: 'rhc-counter-badge',
component: BadgeCounter,
component: NumberBadge,
tags: ['autodocs'],
argTypes: {
children: {
Expand All @@ -26,7 +26,7 @@ const meta = {
},
},
},
} satisfies Meta<typeof BadgeCounter>;
} satisfies Meta<typeof NumberBadge>;
export default meta;
type Story = StoryObj<typeof meta>;

Expand Down
4 changes: 2 additions & 2 deletions packages/storybook/src/community/side-nav.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {
BadgeCounter,
NumberBadge,
Separator,
SideNav,
SideNavItem,
Expand Down Expand Up @@ -49,7 +49,7 @@ export const Default: Story = {
<SideNavItem>
<SideNavLink href="/#" icon="mail">
Mijn berichten
<BadgeCounter>2</BadgeCounter>
<NumberBadge>2</NumberBadge>
</SideNavLink>
</SideNavItem>
<SideNavItem>
Expand Down
4 changes: 2 additions & 2 deletions packages/storybook/src/templates/mijn-omgeving/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import {
AccordionProvider,
BadgeCounter,
Footer,
Heading,
Icon,
Expand All @@ -13,6 +12,7 @@ import {
NavBar,
NavigationList,
NavigationListItem,
NumberBadge,
PageContent,
PageHeader,
Separator,
Expand Down Expand Up @@ -55,7 +55,7 @@ export default function MijnOmgeving() {
<SideNavItem>
<SideNavLink href="/#" icon="inbox">
MijnZaken
<BadgeCounter>2</BadgeCounter>
<NumberBadge>2</NumberBadge>
</SideNavLink>
</SideNavItem>
</SideNavList>
Expand Down

0 comments on commit 5646634

Please sign in to comment.