Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(badge): ensure badge does not appear under child components #7012

Merged
merged 2 commits into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
1 change: 1 addition & 0 deletions src/components/badge/badge.style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ const StyledBadge = styled.span.attrs(({ onClick }) => ({
width: 22px;
min-height: 22px;
border: solid 2px transparent;
z-index: 2;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added this to fix issue found during QA:
image


${({ color, theme }) => css`
border-color: ${toColor(theme, color)};
Expand Down
Loading