Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Skeleton] Add rounded variant #33687

Merged
merged 2 commits into from Aug 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 5 additions & 2 deletions docs/data/material/components/skeleton/Variants.js
Expand Up @@ -5,9 +5,12 @@ import Stack from '@mui/material/Stack';
export default function Variants() {
return (
<Stack spacing={1}>
<Skeleton variant="text" />
{/* For variant="text", adjust the height via font-size */}
<Skeleton variant="text" sx={{ fontSize: '1rem' }} />
{/* For other variants, adjust the size with `width` and `height` */}
<Skeleton variant="circular" width={40} height={40} />
<Skeleton variant="rectangular" width={210} height={118} />
<Skeleton variant="rectangular" width={210} height={60} />
<Skeleton variant="rounded" width={210} height={60} />
</Stack>
);
}
8 changes: 6 additions & 2 deletions docs/data/material/components/skeleton/Variants.tsx
Expand Up @@ -5,9 +5,13 @@ import Stack from '@mui/material/Stack';
export default function Variants() {
return (
<Stack spacing={1}>
<Skeleton variant="text" />
{/* For variant="text", adjust the height via font-size */}
<Skeleton variant="text" sx={{ fontSize: '1rem' }} />

{/* For other variants, adjust the size with `width` and `height` */}
<Skeleton variant="circular" width={40} height={40} />
<Skeleton variant="rectangular" width={210} height={118} />
<Skeleton variant="rectangular" width={210} height={60} />
<Skeleton variant="rounded" width={210} height={60} />
</Stack>
);
}
8 changes: 6 additions & 2 deletions docs/data/material/components/skeleton/Variants.tsx.preview
@@ -1,3 +1,7 @@
<Skeleton variant="text" />
{/* For variant="text", adjust the height via font-size */}
<Skeleton variant="text" sx={{ fontSize: '1rem' }} />

{/* For other variants, adjust the size with `width` and `height` */}
<Skeleton variant="circular" width={40} height={40} />
<Skeleton variant="rectangular" width={210} height={118} />
<Skeleton variant="rectangular" width={210} height={60} />
<Skeleton variant="rounded" width={210} height={60} />
5 changes: 4 additions & 1 deletion docs/data/material/components/skeleton/skeleton.md
Expand Up @@ -37,7 +37,10 @@ For instance:

## Variants

The component supports 3 shape variants.
The component supports 4 shape variants:

- `text` (default): represents a single line of text (you can adjust the height via font size).
- `circular`, `rectangular`, and `rounded`: come with different border radius to let you take control of the size.

{{"demo": "Variants.js"}}

Expand Down
3 changes: 2 additions & 1 deletion docs/pages/material-ui/api/skeleton.json
Expand Up @@ -20,7 +20,7 @@
"variant": {
"type": {
"name": "union",
"description": "'circular'<br>&#124;&nbsp;'rectangular'<br>&#124;&nbsp;'text'<br>&#124;&nbsp;string"
"description": "'circular'<br>&#124;&nbsp;'rectangular'<br>&#124;&nbsp;'rounded'<br>&#124;&nbsp;'text'<br>&#124;&nbsp;string"
},
"default": "'text'"
},
Expand All @@ -32,6 +32,7 @@
"root",
"text",
"rectangular",
"rounded",
"circular",
"pulse",
"wave",
Expand Down
5 changes: 5 additions & 0 deletions docs/translations/api-docs/skeleton/skeleton.json
Expand Up @@ -22,6 +22,11 @@
"nodeName": "the root element",
"conditions": "<code>variant=\"rectangular\"</code>"
},
"rounded": {
"description": "Styles applied to {{nodeName}} if {{conditions}}.",
"nodeName": "the root element",
"conditions": "<code>variant=\"rounded\"</code>"
},
"circular": {
"description": "Styles applied to {{nodeName}} if {{conditions}}.",
"nodeName": "the root element",
Expand Down
2 changes: 1 addition & 1 deletion packages/mui-material/src/Skeleton/Skeleton.d.ts
Expand Up @@ -37,7 +37,7 @@ export interface SkeletonTypeMap<P = {}, D extends React.ElementType = 'span'> {
* @default 'text'
*/
variant?: OverridableStringUnion<
'text' | 'rectangular' | 'circular',
'text' | 'rectangular' | 'rounded' | 'circular',
SkeletonPropsVariantOverrides
>;
/**
Expand Down
5 changes: 4 additions & 1 deletion packages/mui-material/src/Skeleton/Skeleton.js
Expand Up @@ -97,6 +97,9 @@ const SkeletonRoot = styled('span', {
...(ownerState.variant === 'circular' && {
borderRadius: '50%',
}),
...(ownerState.variant === 'rounded' && {
borderRadius: (theme.vars || theme).shape.borderRadius,
}),
...(ownerState.hasChildren && {
'& > *': {
visibility: 'hidden',
Expand Down Expand Up @@ -234,7 +237,7 @@ Skeleton.propTypes /* remove-proptypes */ = {
* @default 'text'
*/
variant: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([
PropTypes.oneOf(['circular', 'rectangular', 'text']),
PropTypes.oneOf(['circular', 'rectangular', 'rounded', 'text']),
PropTypes.string,
]),
/**
Expand Down
3 changes: 3 additions & 0 deletions packages/mui-material/src/Skeleton/skeletonClasses.ts
Expand Up @@ -7,6 +7,8 @@ export interface SkeletonClasses {
text: string;
/** Styles applied to the root element if `variant="rectangular"`. */
rectangular: string;
/** Styles applied to the root element if `variant="rounded"`. */
rounded: string;
/** Styles applied to the root element if `variant="circular"`. */
circular: string;
/** Styles applied to the root element if `animation="pulse"`. */
Expand All @@ -31,6 +33,7 @@ const skeletonClasses: SkeletonClasses = generateUtilityClasses('MuiSkeleton', [
'root',
'text',
'rectangular',
'rounded',
'circular',
'pulse',
'wave',
Expand Down