Skip to content

Commit 0fa45fa

Browse files
authored
Extending the horizontal card to include a button (#570)
* Extending the horizontal card to include a button * Removing changes to App.tsx * Updating tokens * Fixing prettier issue
1 parent e531351 commit 0fa45fa

8 files changed

+249
-76
lines changed

Diff for: src/components/CardHorizontal/CardHorizontal.stories.ts

-19
This file was deleted.
+84
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
import { CardHorizontal } from "./CardHorizontal";
2+
import { ICON_NAMES } from "@/components/Icon/types.ts";
3+
import { styled } from "styled-components";
4+
const GridCenter = styled.div`
5+
display: grid;
6+
width: 60%;
7+
`;
8+
9+
const CardHorizontalExample = ({ ...props }) => {
10+
return (
11+
<GridCenter>
12+
<CardHorizontal
13+
title={props.title}
14+
icon={props.icon}
15+
description={props.description}
16+
disabled={props.disabled}
17+
isSelected={props.isSelected}
18+
badgeText={props.badgeText}
19+
badgeIcon={props.badgeIcon}
20+
badgeState={props.badgeState}
21+
badgeIconDir={props.badgeIconDir}
22+
infoText={props.infoText}
23+
infoUrl={props.infoUrl}
24+
/>
25+
</GridCenter>
26+
);
27+
};
28+
29+
export default {
30+
component: CardHorizontalExample,
31+
title: "Cards/Horizontal Card",
32+
tags: ["cardHorizontal", "autodocs"],
33+
argTypes: {
34+
icon: { control: "select", options: ICON_NAMES, description: "`IconName`" },
35+
badgeIcon: { control: "select", options: ICON_NAMES, description: "`IconName`" },
36+
badgeText: {
37+
control: "text",
38+
description: "Shows and hides the badge <br />`string`",
39+
},
40+
badgeState: {
41+
control: "select",
42+
options: ["default", "info", "success", "warning", "danger"],
43+
description: "`BadgeState`",
44+
},
45+
badgeIconDir: {
46+
control: "radio",
47+
options: ["start", "end"],
48+
description: "`start` `end`",
49+
},
50+
title: { control: "text", description: "`ReactNode`" },
51+
description: { control: "text", description: "`ReactNode`" },
52+
infoText: {
53+
control: "text",
54+
description: "Shows and hides the button <br />`string`",
55+
},
56+
infoUrl: { control: "text", description: "`string`" },
57+
disabled: {
58+
control: "boolean",
59+
description: "`boolean`",
60+
defaultValue: { summary: "false" },
61+
},
62+
isSelected: {
63+
control: "boolean",
64+
description: "`boolean`",
65+
defaultValue: { summary: "false" },
66+
},
67+
},
68+
};
69+
70+
export const Playground = {
71+
args: {
72+
icon: "building",
73+
title: "Card title",
74+
description: "A description very interesting that presumably relates to the card.",
75+
disabled: false,
76+
isSelected: false,
77+
badgeText: "",
78+
badgeIcon: null,
79+
badgeState: "default",
80+
badgeIconDir: "",
81+
infoText: "",
82+
infoUrl: "",
83+
},
84+
};

Diff for: src/components/CardHorizontal/CardHorizontal.test.tsx

+10
Original file line numberDiff line numberDiff line change
@@ -54,5 +54,15 @@ describe("CardHorizontal Component", () => {
5454

5555
expect(screen.queryByTestId("horizontal-card-badge")).toBeNull();
5656
});
57+
58+
it("should render the button when provided", () => {
59+
renderCard({
60+
title: "title",
61+
infoText: "I'm a button",
62+
});
63+
64+
expect(screen.getByText("title")).toBeDefined();
65+
expect(screen.getByTestId("horizontal-card-button")).toBeDefined();
66+
});
5767
});
5868
});

0 commit comments

Comments
 (0)