File tree Expand file tree Collapse file tree 4 files changed +76
-0
lines changed Expand file tree Collapse file tree 4 files changed +76
-0
lines changed Original file line number Diff line number Diff line change
1
+ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
2
+
3
+ exports [` Skeleton component > renders correctly 1` ] = `
4
+ <div >
5
+ <div
6
+ class = " animate-pulse rounded-md bg-gray-300"
7
+ />
8
+ </div >
9
+ ` ;
Original file line number Diff line number Diff line change
1
+ import { render } from "@testing-library/react" ;
2
+ import { describe , expect , it } from "vitest" ;
3
+ import { Skeleton } from "./skeleton" ;
4
+
5
+ describe ( "Skeleton component" , ( ) => {
6
+ it ( "renders correctly" , ( ) => {
7
+ const { container } = render ( < Skeleton /> ) ;
8
+ expect ( container ) . toMatchSnapshot ( ) ;
9
+ } ) ;
10
+ } ) ;
Original file line number Diff line number Diff line change
1
+ import type { Meta , StoryObj } from "@storybook/react" ;
2
+
3
+ import { Skeleton } from "./skeleton" ;
4
+
5
+ const meta = {
6
+ title : "Skeleton" ,
7
+ component : Skeleton ,
8
+ parameters : {
9
+ layout : "centered" ,
10
+ } ,
11
+ } satisfies Meta < typeof Skeleton > ;
12
+
13
+ export default meta ;
14
+ type Story = StoryObj < typeof meta > ;
15
+
16
+ export const Example : Story = {
17
+ render ( ) {
18
+ return (
19
+ < div className = "flex items-center space-x-4" >
20
+ < Skeleton className = "h-12 w-12 rounded-full" />
21
+ < div className = "space-y-2" >
22
+ < Skeleton className = "h-4 w-[250px]" />
23
+ < Skeleton className = "h-4 w-[200px]" />
24
+ </ div >
25
+ </ div >
26
+ ) ;
27
+ } ,
28
+ } ;
29
+
30
+ export const Card : Story = {
31
+ render ( ) {
32
+ return (
33
+ < div className = "flex flex-col space-y-3" >
34
+ < Skeleton className = "h-[125px] w-[250px] rounded-xl" />
35
+ < div className = "space-y-2" >
36
+ < Skeleton className = "h-4 w-[250px]" />
37
+ < Skeleton className = "h-4 w-[200px]" />
38
+ </ div >
39
+ </ div >
40
+ ) ;
41
+ } ,
42
+ } ;
Original file line number Diff line number Diff line change
1
+ import { cn } from "@/lib/utils" ;
2
+
3
+ function Skeleton ( {
4
+ className,
5
+ ...props
6
+ } : React . HTMLAttributes < HTMLDivElement > ) {
7
+ return (
8
+ < div
9
+ className = { cn ( "animate-pulse rounded-md bg-gray-300" , className ) }
10
+ { ...props }
11
+ />
12
+ ) ;
13
+ }
14
+
15
+ export { Skeleton } ;
You can’t perform that action at this time.
0 commit comments