-
Notifications
You must be signed in to change notification settings - Fork 570
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
113 additions
and
3 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
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,17 @@ | ||
import { Skeleton } from './Skeleton'; | ||
|
||
describe('Skeleton', () => { | ||
it('renders a skeleton component', () => { | ||
const result = <Skeleton width={320} height={32} borderRadius="medium" />; | ||
|
||
expect(result).toStrictEqual({ | ||
type: 'Skeleton', | ||
key: null, | ||
props: { | ||
width: 320, | ||
height: 32, | ||
borderRadius: 'medium', | ||
}, | ||
}); | ||
}); | ||
}); |
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,40 @@ | ||
import { createSnapComponent } from '../component'; | ||
|
||
/** | ||
* Definition of Skeleton border radius. | ||
*/ | ||
export type SkeletonBorderRadius = 'none' | 'medium' | 'full' | undefined; | ||
|
||
/** | ||
* The props of the {@link Skeleton} component. | ||
* | ||
* @param width - Width of the Skeleton. | ||
* @param width - Height of the Skeleton. | ||
* @param borderRadius - Border radius of the Skeleton. | ||
*/ | ||
export type SkeletonProps = { | ||
width: number | string; | ||
height: number | string; | ||
borderRadius?: SkeletonBorderRadius | undefined; | ||
}; | ||
|
||
const TYPE = 'Skeleton'; | ||
|
||
/** | ||
* A Skeleton component, which is used to display skeleton of loading content. | ||
* | ||
* @param props - The props of the component. | ||
* @param props.width - Width of the Skeleton. | ||
* @param props.width - Height of the Skeleton. | ||
* @param props.borderRadius - Border radius of the Skeleton. | ||
* @example | ||
* <Skeleton height={32} width={50%} /> | ||
*/ | ||
export const Skeleton = createSnapComponent<SkeletonProps, typeof TYPE>(TYPE); | ||
|
||
/** | ||
* A Skeleton element. | ||
* | ||
* @see Skeleton | ||
*/ | ||
export type SkeletonElement = ReturnType<typeof 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
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
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