Skip to content

Commit

Permalink
fix: adjusted brakelines and chip component and storybook
Browse files Browse the repository at this point in the history
  • Loading branch information
wendellguimaraes-tlf committed Feb 21, 2025
1 parent 898b172 commit 740cf7c
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 15 deletions.
28 changes: 15 additions & 13 deletions src/__stories__/chip-story.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -157,22 +157,20 @@ export const MultipleSelection: StoryComponent<Omit<Args, 'closable'>> = ({inver
</ChipBackgroundContainer>
);
};
export const NavigableChip: StoryComponent<Omit<Args, 'closable'>> = ({
inverse,
icon,
badge,
active: chipActive,
href: hrefProp,
}) => {
export const NavigableChip: StoryComponent<{
inverse: boolean;
icon: boolean;
badge: string;
}> = ({inverse, icon, badge}) => {
const props = {
Icon: icon ? IconLightningFilled : undefined,
badge: badge !== 'undefined' ? +badge : undefined,
href: hrefProp !== 'undefined' ? hrefProp : '',
active: chipActive,
href: 'https://example.com',
active: true,
};

return (
<ChipBackgroundContainer dataAttributes={{testid: 'chip'}} inverse={inverse}>
<ChipBackgroundContainer dataAttributes={{testid: 'navigable-chip'}} inverse={inverse}>
<Chip {...props}>Chip</Chip>
</ChipBackgroundContainer>
);
Expand All @@ -189,10 +187,8 @@ const defaultArgs = {

const navigableArgs = {
inverse: false,
active: true,
badge: '0',
icon: false,
href: 'https://example.com',
};

const defaultArgTypes = {
Expand All @@ -205,6 +201,12 @@ const defaultArgTypes = {
control: {type: 'select'},
},
};
const NavigableChipArgTypes = {
badge: {
options: badgeOptions,
control: {type: 'select'},
},
};

Default.storyName = 'Chip';
Default.argTypes = defaultArgTypes;
Expand All @@ -216,5 +218,5 @@ SingleSelection.args = {...(({closable, ...o}) => o)(defaultArgs)};
MultipleSelection.argTypes = defaultArgTypes;
MultipleSelection.args = {...(({closable, ...o}) => o)(defaultArgs)};

NavigableChip.argTypes = defaultArgTypes;
NavigableChip.argTypes = NavigableChipArgTypes;
NavigableChip.args = navigableArgs;
8 changes: 8 additions & 0 deletions src/__tests__/chip-test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ test('Chip can be closed', async () => {
);

const closeButton = screen.getByRole('button', {name: 'Cerrar'});

await userEvent.click(closeButton);

expect(closeSpy).toHaveBeenCalledTimes(1);
});

Expand All @@ -27,8 +29,11 @@ test('Chip can be closed when using custom close label', async () => {
</Chip>
</ThemeContextProvider>
);

const closeButton = screen.getByRole('button', {name: 'custom close label'});

await userEvent.click(closeButton);

expect(closeSpy).toHaveBeenCalledTimes(1);
});

Expand All @@ -39,7 +44,10 @@ test('Chip can be clicked', async () => {
<Chip onPress={clickSpy}>some text</Chip>
</ThemeContextProvider>
);

const chip = screen.getByText('some text');

await userEvent.click(chip);

expect(clickSpy).toHaveBeenCalledTimes(1);
});
4 changes: 2 additions & 2 deletions src/chip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ const Chip = (props: ChipProps): JSX.Element => {
{Icon && (
<div
className={
props.active
active
? isTouchable
? overInverse
? styles.iconNavigationInverse
Expand Down Expand Up @@ -120,7 +120,7 @@ const Chip = (props: ChipProps): JSX.Element => {
<div
className={classnames(
styles.chipVariants[
props.active
active
? isTouchable
? overInverse
? 'navigationActiveInverse'
Expand Down

0 comments on commit 740cf7c

Please sign in to comment.