Skip to content

Commit

Permalink
fix(badge): ensure badge does not appear under child components
Browse files Browse the repository at this point in the history
This fix ensures badge does not appear under child components.

fix #6765
  • Loading branch information
nuria1110 committed Oct 10, 2024
1 parent dfba661 commit 1c3601c
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 13 deletions.
36 changes: 24 additions & 12 deletions src/components/badge/badge-test.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import React from "react";
import { action } from "@storybook/addon-actions";
import Badge, { BadgeProps } from "./badge.component";
import Badge from ".";
import Box from "../box";
import Button from "../button";
import MultiActionButton from "../multi-action-button";
import SplitButton from "../split-button";

export default {
title: "Badge/Test",
Expand Down Expand Up @@ -31,6 +33,8 @@ export const DefaultStory = ({ counter, ...args }: BadgeStoryProps) => {
</div>
);
};
DefaultStory.storyName = "default";
DefaultStory.args = { counter: 1, color: "--colorsActionMajor500" };

export const DisplayOnlyStory = ({ counter, ...args }: BadgeStoryProps) => {
return (
Expand All @@ -43,21 +47,29 @@ export const DisplayOnlyStory = ({ counter, ...args }: BadgeStoryProps) => {
</Box>
);
};

DefaultStory.storyName = "default";
DefaultStory.args = { counter: 1, color: "--colorsActionMajor500" };

DisplayOnlyStory.storyName = "display only";
DisplayOnlyStory.args = { counter: 1, color: "--colorsActionMajor500" };

export const BadgeComponent = (props: Partial<BadgeProps>) => {
export const WithOtherButtons = () => {
return (
<Box margin="40px">
<Badge {...props}>
<Button mr={0} buttonType="tertiary">
Filter
</Button>
<>
<Badge counter={2} onClick={() => {}}>
<MultiActionButton text="Multi action">
<Button onClick={() => {}}>Action</Button>
<Button onClick={() => {}}>Action</Button>
</MultiActionButton>
</Badge>
</Box>

<Badge counter={2} onClick={() => {}}>
<SplitButton text="Split button">
<Button href="#">Button 1</Button>
<Button>Button 2</Button>
<Button>Button 3</Button>
</SplitButton>
</Badge>
</>
);
};
WithOtherButtons.parameters = {
chromatic: { disableSnapshot: false },
};
2 changes: 1 addition & 1 deletion src/components/badge/badge.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ export const Badge = ({

return (
<StyledBadgeWrapper>
{renderCorrectBadge()}
{children}
{renderCorrectBadge()}
</StyledBadgeWrapper>
);
};
Expand Down

0 comments on commit 1c3601c

Please sign in to comment.