Skip to content

Commit a7b81dc

Browse files
feat: add progress items (#71)
1 parent b0eed25 commit a7b81dc

File tree

5 files changed

+163
-0
lines changed

5 files changed

+163
-0
lines changed

.changeset/fair-dolls-cheat.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@zenml-io/react-component-library": minor
3+
---
4+
5+
add progressTick and progressOutstanding
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
import { Meta } from "@storybook/react";
2+
import { StoryObj } from "@storybook/react";
3+
import { ProgressOutstanding, ProgressTick, progressTickVariants } from "./index";
4+
import React from "react";
5+
6+
const meta = {
7+
title: "Elements/Progress",
8+
component: ProgressOutstanding,
9+
parameters: {
10+
layout: "centered"
11+
},
12+
argTypes: {
13+
size: {
14+
description: "defining the size of the Item",
15+
control: "select",
16+
defaultValue: "sm",
17+
options: ["sm", "md"]
18+
}
19+
},
20+
decorators: [
21+
(Story) => (
22+
<div className="flex items-center gap-7">
23+
<Story />
24+
</div>
25+
)
26+
],
27+
28+
tags: ["autodocs"]
29+
} satisfies Meta<typeof ProgressOutstanding>;
30+
31+
export default meta;
32+
33+
type Story = StoryObj<typeof meta>;
34+
35+
export const DefaultVariant: Story = {
36+
name: "Default",
37+
args: {
38+
size: "sm"
39+
},
40+
render: ({ size }) => (
41+
<>
42+
<ProgressOutstanding size={size} />
43+
<ProgressTick size={size}>
44+
<svg
45+
className={progressTickVariants({ size })}
46+
viewBox="0 0 24 24"
47+
fill="black"
48+
xmlns="http://www.w3.org/2000/svg"
49+
>
50+
<path
51+
fillRule="evenodd"
52+
clipRule="evenodd"
53+
d="M20.7071 5.29289C21.0976 5.68342 21.0976 6.31658 20.7071 6.70711L9.70711 17.7071C9.31658 18.0976 8.68342 18.0976 8.29289 17.7071L3.29289 12.7071C2.90237 12.3166 2.90237 11.6834 3.29289 11.2929C3.68342 10.9024 4.31658 10.9024 4.70711 11.2929L9 15.5858L19.2929 5.29289C19.6834 4.90237 20.3166 4.90237 20.7071 5.29289Z"
54+
/>
55+
</svg>
56+
</ProgressTick>
57+
</>
58+
)
59+
};
60+
61+
export const TickStory: Story = {
62+
name: "Progress Tick",
63+
args: {
64+
size: "md"
65+
},
66+
render: ({ size }) => (
67+
<ProgressTick size={size}>
68+
<svg
69+
className={progressTickVariants({ size: size })}
70+
viewBox="0 0 24 24"
71+
fill="black"
72+
xmlns="http://www.w3.org/2000/svg"
73+
>
74+
<path
75+
fillRule="evenodd"
76+
clipRule="evenodd"
77+
d="M20.7071 5.29289C21.0976 5.68342 21.0976 6.31658 20.7071 6.70711L9.70711 17.7071C9.31658 18.0976 8.68342 18.0976 8.29289 17.7071L3.29289 12.7071C2.90237 12.3166 2.90237 11.6834 3.29289 11.2929C3.68342 10.9024 4.31658 10.9024 4.70711 11.2929L9 15.5858L19.2929 5.29289C19.6834 4.90237 20.3166 4.90237 20.7071 5.29289Z"
78+
/>
79+
</svg>
80+
</ProgressTick>
81+
)
82+
};
83+
84+
export const OutstandingStory: Story = {
85+
name: "Progress Outstanding",
86+
args: {
87+
size: "md"
88+
},
89+
render: ({ size }) => <ProgressOutstanding size={size} />
90+
};
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
import React, { HTMLAttributes } from "react";
2+
import { cn } from "../../utilities";
3+
import { cva, VariantProps } from "class-variance-authority";
4+
5+
export const progressTickCircleVariants = cva(
6+
"shrink-0 flex items-center justify-center rounded-rounded border-success-300 bg-success-50",
7+
{
8+
variants: {
9+
size: {
10+
sm: "h-[28px] w-[28px] border-2",
11+
md: "h-7 w-7 border-4"
12+
}
13+
},
14+
defaultVariants: {
15+
size: "sm"
16+
}
17+
}
18+
);
19+
20+
export const progressTickVariants = cva("fill-success-300", {
21+
variants: {
22+
size: {
23+
sm: "h-3 w-3",
24+
md: "h-[28px] w-[28px]"
25+
}
26+
},
27+
defaultVariants: {
28+
size: "sm"
29+
}
30+
});
31+
32+
export function ProgressTick({
33+
className,
34+
children,
35+
size,
36+
...rest
37+
}: HTMLAttributes<HTMLDivElement> & VariantProps<typeof progressTickCircleVariants>) {
38+
return (
39+
<div {...rest} className={cn(progressTickCircleVariants({ size }), className)}>
40+
{children}
41+
</div>
42+
);
43+
}
44+
45+
export const progressOutstandingVariants = cva(
46+
"rounded-rounded border-dashed border-neutral-300 bg-theme-surface-tertiary",
47+
{
48+
variants: {
49+
size: {
50+
sm: "h-[28px] w-[28px] border-2",
51+
md: "h-7 w-7 border-4"
52+
}
53+
},
54+
defaultVariants: {
55+
size: "sm"
56+
}
57+
}
58+
);
59+
60+
export function ProgressOutstanding({
61+
className,
62+
size,
63+
...rest
64+
}: HTMLAttributes<HTMLDivElement> & VariantProps<typeof progressOutstandingVariants>) {
65+
return <div {...rest} className={cn(progressOutstandingVariants({ size }), className)}></div>;
66+
}

src/components/Progress/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from "./ProgressItems";

src/components/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,4 @@ export * from "./Tooltip";
1616
export * from "./Checkbox";
1717
export * from "./Toast";
1818
export * from "./Dialog";
19+
export * from "./Progress";

0 commit comments

Comments
 (0)