Skip to content

Commit bd0b438

Browse files
committed
feat: add component skeleton
1 parent d7de8a3 commit bd0b438

File tree

8 files changed

+88
-0
lines changed

8 files changed

+88
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { cn } from '@/lib/utils';
2+
3+
import { skeletonVariants } from './skeleton-variants';
4+
import type { SkeletonProps } from './types';
5+
6+
function Skeleton(props: SkeletonProps) {
7+
const { className, ...rest } = props;
8+
9+
const mergedCls = cn(skeletonVariants(), className);
10+
11+
return (
12+
<div
13+
className={mergedCls}
14+
data-slot="skeleton"
15+
{...rest}
16+
/>
17+
);
18+
}
19+
20+
export default Skeleton;
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export { default as Skeleton } from './Skeleton';
2+
3+
export * from './types';
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { tv } from 'tailwind-variants';
2+
3+
export const skeletonVariants = tv({
4+
base: `animate-pulse rounded-md bg-accent-foreground/10`
5+
});
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import type { BaseComponentProps } from '@/types/other';
2+
3+
export type SkeletonProps = BaseComponentProps<'div'>;

packages/ui/src/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ export * from './components/collapsible';
2626

2727
export * from './components/config-provider';
2828

29+
export * from './components/context-menu';
30+
2931
export * from './components/divider';
3032

3133
export * from './components/dropdown-menu';
@@ -40,6 +42,8 @@ export * from './components/popover';
4042

4143
export * from './components/scroll-area';
4244

45+
export * from './components/skeleton';
46+
4347
export * from './components/sonner';
4448

4549
export * from './components/switch';
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { Card, Skeleton } from 'soybean-react-ui';
2+
3+
const CustomSize = () => {
4+
return (
5+
<Card
6+
split
7+
title="Custom Size"
8+
>
9+
<div className="flex flex-col space-y-3">
10+
<Skeleton className="h-[125px] w-[250px] rounded-xl" />
11+
<div className="space-y-2">
12+
<Skeleton className="h-4 w-[250px]" />
13+
<Skeleton className="h-4 w-[200px]" />
14+
</div>
15+
</div>
16+
</Card>
17+
);
18+
};
19+
20+
export default CustomSize;
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { Card, Skeleton } from 'soybean-react-ui';
2+
3+
const DefaultDemo = () => {
4+
return (
5+
<Card
6+
split
7+
title="Skeleton"
8+
>
9+
<div className="flex items-center space-x-4">
10+
<Skeleton className="size-12 rounded-full" />
11+
<div className="space-y-2">
12+
<Skeleton className="h-4 w-[250px]" />
13+
<Skeleton className="h-4 w-[200px]" />
14+
</div>
15+
</div>
16+
</Card>
17+
);
18+
};
19+
20+
export default DefaultDemo;
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import CustomSize from './modules/CustomSize';
2+
import DefaultDemo from './modules/DefaultDemo';
3+
4+
const SkeletonPage = () => {
5+
return (
6+
<div className="flex-c gap-4">
7+
<DefaultDemo />
8+
<CustomSize />
9+
</div>
10+
);
11+
};
12+
13+
export default SkeletonPage;

0 commit comments

Comments
 (0)