-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Avatar] Fallback images when fails to load (#18711)
- Loading branch information
1 parent
e8703bf
commit f8464a1
Showing
7 changed files
with
150 additions
and
9 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,31 @@ | ||
import React from 'react'; | ||
import { makeStyles } from '@material-ui/core/styles'; | ||
import Avatar from '@material-ui/core/Avatar'; | ||
import { deepOrange } from '@material-ui/core/colors'; | ||
|
||
const useStyles = makeStyles(theme => ({ | ||
root: { | ||
display: 'flex', | ||
'& > *': { | ||
margin: theme.spacing(1), | ||
}, | ||
}, | ||
orange: { | ||
color: theme.palette.getContrastText(deepOrange[500]), | ||
backgroundColor: deepOrange[500], | ||
}, | ||
})); | ||
|
||
export default function FallbackAvatars() { | ||
const classes = useStyles(); | ||
|
||
return ( | ||
<div className={classes.root}> | ||
<Avatar alt="Remy Sharp" src="/broken-image.jpg" className={classes.orange}> | ||
B | ||
</Avatar> | ||
<Avatar alt="Remy Sharp" src="/broken-image.jpg" className={classes.orange} /> | ||
<Avatar src="/broken-image.jpg" /> | ||
</div> | ||
); | ||
} |
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,33 @@ | ||
import React from 'react'; | ||
import { makeStyles, createStyles, Theme } from '@material-ui/core/styles'; | ||
import Avatar from '@material-ui/core/Avatar'; | ||
import { deepOrange } from '@material-ui/core/colors'; | ||
|
||
const useStyles = makeStyles((theme: Theme) => | ||
createStyles({ | ||
root: { | ||
display: 'flex', | ||
'& > *': { | ||
margin: theme.spacing(1), | ||
}, | ||
}, | ||
orange: { | ||
color: theme.palette.getContrastText(deepOrange[500]), | ||
backgroundColor: deepOrange[500], | ||
}, | ||
}), | ||
); | ||
|
||
export default function FallbackAvatars() { | ||
const classes = useStyles(); | ||
|
||
return ( | ||
<div className={classes.root}> | ||
<Avatar alt="Remy Sharp" src="/broken-image.jpg" className={classes.orange}> | ||
B | ||
</Avatar> | ||
<Avatar alt="Remy Sharp" src="/broken-image.jpg" className={classes.orange} /> | ||
<Avatar src="/broken-image.jpg" /> | ||
</div> | ||
); | ||
} |
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,10 @@ | ||
import React from 'react'; | ||
import createSvgIcon from './createSvgIcon'; | ||
|
||
/** | ||
* @ignore - internal component. | ||
*/ | ||
export default createSvgIcon( | ||
<path d="M12 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm0 2c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4z" />, | ||
'Person', | ||
); |
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