-
Notifications
You must be signed in to change notification settings - Fork 104
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Skeleton): Add skeleton component (#429)
- Loading branch information
Showing
3 changed files
with
99 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import React from 'react' | ||
import { StoryFn as Story, Meta } from '@storybook/react' | ||
|
||
import Skeleton, { SkeletonProps } from '.' | ||
|
||
const meta: Meta = { | ||
title: 'Feedback/Skeleton', | ||
component: Skeleton, | ||
parameters: { | ||
controls: { expanded: true }, | ||
}, | ||
} | ||
|
||
export default meta | ||
|
||
export const Default: Story<SkeletonProps> = (args) => { | ||
return <Skeleton {...args} /> | ||
} | ||
Default.args = { | ||
className: 'w-32 h-32', | ||
} | ||
|
||
export const CircleWithContent: Story<SkeletonProps> = ({ dataTheme }) => { | ||
return ( | ||
<div className="flex flex-col gap-4 w-52" data-theme={dataTheme}> | ||
<div className="flex gap-4 items-center"> | ||
<Skeleton className="w-16 h-16 rounded-full shrink-0"></Skeleton> | ||
<div className="flex flex-col gap-4"> | ||
<Skeleton className="h-4 w-20"></Skeleton> | ||
<Skeleton className="h-4 w-28"></Skeleton> | ||
</div> | ||
</div> | ||
<Skeleton className="h-32 w-full"></Skeleton> | ||
</div> | ||
) | ||
} | ||
|
||
export const RectangleWithContent: Story<SkeletonProps> = ({ dataTheme }) => { | ||
return ( | ||
<div className="flex flex-col gap-4 w-52" data-theme={dataTheme}> | ||
<Skeleton className="h-32 w-full"></Skeleton> | ||
<Skeleton className="h-4 w-28"></Skeleton> | ||
<Skeleton className="h-4 w-full"></Skeleton> | ||
<Skeleton className="h-4 w-full"></Skeleton> | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import React, { forwardRef, ReactNode } from 'react' | ||
import clsx from 'clsx' | ||
import { twMerge } from 'tailwind-merge' | ||
|
||
import { | ||
IComponentBaseProps, | ||
} from '../types' | ||
|
||
export type SkeletonProps = | ||
& React.HTMLAttributes<HTMLDivElement> | ||
& IComponentBaseProps | ||
& { | ||
} | ||
|
||
const Skeleton = forwardRef<HTMLDivElement, SkeletonProps>( | ||
( | ||
{ | ||
dataTheme, | ||
className, | ||
children, | ||
...props | ||
}, | ||
ref | ||
): JSX.Element => { | ||
const classes = twMerge( | ||
'skeleton', | ||
clsx({ | ||
}), | ||
className, | ||
) | ||
|
||
return ( | ||
<div | ||
{...props} | ||
data-theme={dataTheme} | ||
className={classes} | ||
ref={ref} | ||
> | ||
{children} | ||
</div> | ||
) | ||
} | ||
) | ||
|
||
Skeleton.displayName = "Skeleton" | ||
|
||
export default Skeleton |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export * from './Skeleton'; | ||
|
||
import Skeleton, { SkeletonProps as TSkeletonProps } from './Skeleton' | ||
export type SkeletonProps = TSkeletonProps | ||
export default Skeleton |