-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add base skeleton component (#11339)
- Loading branch information
Showing
1 changed file
with
47 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 type { ComponentProps, FC } from 'react' | ||
import classNames from '@/utils/classnames' | ||
|
||
type SkeletonProps = ComponentProps<'div'> | ||
|
||
export const SkeletonContanier: FC<SkeletonProps> = (props) => { | ||
const { className, children, ...rest } = props | ||
return ( | ||
<div className={classNames('flex flex-col gap-1', className)} {...rest}> | ||
{children} | ||
</div> | ||
) | ||
} | ||
|
||
export const SkeletonRow: FC<SkeletonProps> = (props) => { | ||
const { className, children, ...rest } = props | ||
return ( | ||
<div className={classNames('flex items-center gap-2', className)} {...rest}> | ||
{children} | ||
</div> | ||
) | ||
} | ||
|
||
export const SkeletonRectangle: FC<SkeletonProps> = (props) => { | ||
const { className, children, ...rest } = props | ||
return ( | ||
<div className={classNames('h-2 rounded-sm opacity-20 bg-text-tertiary my-1', className)} {...rest}> | ||
{children} | ||
</div> | ||
) | ||
} | ||
|
||
export const SkeletonPoint: FC = () => | ||
<div className='text-text-quaternary text-xs font-medium'>·</div> | ||
|
||
/** Usage | ||
* <SkeletonContanier> | ||
* <SkeletonRow> | ||
* <SkeletonRectangle className="w-96" /> | ||
* <SkeletonPoint /> | ||
* <SkeletonRectangle className="w-96" /> | ||
* </SkeletonRow> | ||
* <SkeletonRow> | ||
* <SkeletonRectangle className="w-96" /> | ||
* </SkeletonRow> | ||
* <SkeletonRow> | ||
*/ |