-
Notifications
You must be signed in to change notification settings - Fork 568
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
### Add Skeleton component. Related PR in extension: MetaMask/metamask-extension#29764 #### Code example JSX code used for testing: ```typescript <Container> <Box> <Text>Skeleton inside text component:</Text> <Text> <Skeleton /> </Text> <Text>Classic Skeleton inside a box:</Text> <Skeleton /> <Text>Top level Skeleton: </Text> <Skeleton height={32} width="100%" /> <Skeleton height={16} width="50%" borderRadius="none" /> <Skeleton height={16} width="25%" borderRadius="medium" /> <Skeleton height={32} width={32} borderRadius="full" /> <Text>Skeleton inside Section: </Text> <Section> <Skeleton height={32} width="100%" /> <Skeleton height={16} width="50%" borderRadius="none" /> <Skeleton height={16} width="25%" borderRadius="medium" /> <Skeleton height={32} width={32} borderRadius="full" /> </Section> <Text>Skeleton inside Row: </Text> <Row label="Row"> <Skeleton height={22} width="30%" /> </Row> <Row label="Row"> <Text> <Skeleton height={22} width={40} /> </Text> </Row> </Box> </Container> ``` #### Screenshots ![Screenshot 2025-01-17 at 13 09 22](https://github.com/user-attachments/assets/7ebd5646-6664-4b72-8578-33e7db6557a5)
- Loading branch information
Showing
14 changed files
with
144 additions
and
14 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
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
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
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,36 @@ | ||
import { createSnapComponent } from '../component'; | ||
import type { BorderRadius } from './utils'; | ||
|
||
/** | ||
* 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 | undefined; | ||
height?: number | string | undefined; | ||
borderRadius?: BorderRadius | 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
/** | ||
* Definition of border radius. | ||
*/ | ||
export type BorderRadius = 'none' | 'medium' | 'full' | undefined; |
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