Skip to content

Commit caf5c23

Browse files
feat: Loading Skeleton (#48)
1 parent 656180c commit caf5c23

File tree

6 files changed

+51
-0
lines changed

6 files changed

+51
-0
lines changed

.changeset/eight-mirrors-bake.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 loading skeleton
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import { Meta } from "@storybook/react";
2+
import { Skeleton } from "./index";
3+
import { StoryObj } from "@storybook/react";
4+
import React from "react";
5+
6+
const meta = {
7+
title: "Elements/Skeleton",
8+
component: Skeleton,
9+
10+
parameters: {
11+
layout: "centered"
12+
},
13+
decorators: [
14+
(Story) => (
15+
<div className="w-[400px] h-[200px]">
16+
<Story />
17+
</div>
18+
)
19+
],
20+
tags: ["autodocs"]
21+
} satisfies Meta<typeof Skeleton>;
22+
23+
export default meta;
24+
25+
type Story = StoryObj<typeof meta>;
26+
27+
export const DefaultVariant: Story = {
28+
name: "Default",
29+
args: {
30+
className: "h-full"
31+
}
32+
};
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { cn } from "../../utilities";
2+
import React from "react";
3+
4+
function Skeleton({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) {
5+
return <div className={cn("animate-pulse rounded-md bg-neutral-200", className)} {...props} />;
6+
}
7+
8+
export { Skeleton };

src/components/Skeleton/index.tsx

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

src/components/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ export * from "./Input";
33
export * from "./Sidebar";
44
export * from "./Box";
55
export * from "./Avatar";
6+
export * from "./Skeleton";

test/utilities/index.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,8 @@ describe("cn", () => {
1717
test("should replace undefined classes", () => {
1818
expect(cn("text-white", undefined)).toBe("text-white");
1919
});
20+
21+
test("custom font sizes", () => {
22+
expect(cn("text-text-md", "text-display-xs")).toBe("text-display-xs");
23+
});
2024
});

0 commit comments

Comments
 (0)