Skip to content

Commit

Permalink
[Skeleton] Make demo Facebook closer to the original
Browse files Browse the repository at this point in the history
  • Loading branch information
oliviertassinari committed Jan 27, 2020
1 parent 2ab33ab commit 19c2ba9
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 14 deletions.
18 changes: 12 additions & 6 deletions docs/src/pages/components/skeleton/Facebook.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ function Media(props) {
<CardHeader
avatar={
loading ? (
<Skeleton variant="circle" width={40} height={40} />
<Skeleton animation="wave" variant="circle" width={40} height={40} />
) : (
<Avatar
alt="Ted talk"
Expand All @@ -45,11 +45,17 @@ function Media(props) {
</IconButton>
)
}
title={loading ? <Skeleton height={10} width="80%" style={{ marginBottom: 6 }} /> : 'Ted'}
subheader={loading ? <Skeleton height={10} width="40%" /> : '5 hours ago'}
title={
loading ? (
<Skeleton animation="wave" height={10} width="80%" style={{ marginBottom: 6 }} />
) : (
'Ted'
)
}
subheader={loading ? <Skeleton animation="wave" height={10} width="40%" /> : '5 hours ago'}
/>
{loading ? (
<Skeleton variant="rect" className={classes.media} />
<Skeleton animation="wave" variant="rect" className={classes.media} />
) : (
<CardMedia
className={classes.media}
Expand All @@ -61,8 +67,8 @@ function Media(props) {
<CardContent>
{loading ? (
<React.Fragment>
<Skeleton height={10} style={{ marginBottom: 6 }} />
<Skeleton height={10} width="80%" />
<Skeleton animation="wave" height={10} style={{ marginBottom: 6 }} />
<Skeleton animation="wave" height={10} width="80%" />
</React.Fragment>
) : (
<Typography variant="body2" color="textSecondary" component="p">
Expand Down
18 changes: 12 additions & 6 deletions docs/src/pages/components/skeleton/Facebook.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ function Media(props: MediaProps) {
<CardHeader
avatar={
loading ? (
<Skeleton variant="circle" width={40} height={40} />
<Skeleton animation="wave" variant="circle" width={40} height={40} />
) : (
<Avatar
alt="Ted talk"
Expand All @@ -50,11 +50,17 @@ function Media(props: MediaProps) {
</IconButton>
)
}
title={loading ? <Skeleton height={10} width="80%" style={{ marginBottom: 6 }} /> : 'Ted'}
subheader={loading ? <Skeleton height={10} width="40%" /> : '5 hours ago'}
title={
loading ? (
<Skeleton animation="wave" height={10} width="80%" style={{ marginBottom: 6 }} />
) : (
'Ted'
)
}
subheader={loading ? <Skeleton animation="wave" height={10} width="40%" /> : '5 hours ago'}
/>
{loading ? (
<Skeleton variant="rect" className={classes.media} />
<Skeleton animation="wave" variant="rect" className={classes.media} />
) : (
<CardMedia
className={classes.media}
Expand All @@ -65,8 +71,8 @@ function Media(props: MediaProps) {
<CardContent>
{loading ? (
<React.Fragment>
<Skeleton height={10} style={{ marginBottom: 6 }} />
<Skeleton height={10} width="80%" />
<Skeleton animation="wave" height={10} style={{ marginBottom: 6 }} />
<Skeleton animation="wave" height={10} width="80%" />
</React.Fragment>
) : (
<Typography variant="body2" color="textSecondary" component="p">
Expand Down
8 changes: 6 additions & 2 deletions packages/material-ui-lab/src/Skeleton/Skeleton.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,11 @@ export const styles = theme => ({
position: 'relative',
overflow: 'hidden',
'&::after': {
animation: '$wave 1.5s linear 0.5s infinite',
background: 'linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent)',
animation: '$wave 1.6s linear 0.5s infinite',
background: 'linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.6), transparent)',
content: '""',
position: 'absolute',
transform: 'translateX(-100%)', // Avoid flash during server-side hydration
bottom: 0,
left: 0,
right: 0,
Expand All @@ -63,6 +64,9 @@ export const styles = theme => ({
'0%': {
transform: 'translateX(-100%)',
},
'60%': { // +0.5s of delay between each loop
transform: 'translateX(100%)',
},
'100%': {
transform: 'translateX(100%)',
},
Expand Down

0 comments on commit 19c2ba9

Please sign in to comment.