-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[AvatarGroup] Introduce new component (#18707)
- Loading branch information
1 parent
b0e02c9
commit 53ef743
Showing
40 changed files
with
672 additions
and
534 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import React from 'react'; | ||
import MarkdownDocs from 'docs/src/modules/components/MarkdownDocs'; | ||
import markdown from './avatar-group.md'; | ||
|
||
export default function Page() { | ||
return <MarkdownDocs markdown={markdown} />; | ||
} |
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,55 @@ | ||
--- | ||
filename: /packages/material-ui-lab/src/AvatarGroup/AvatarGroup.js | ||
--- | ||
|
||
<!--- This documentation is automatically generated, do not try to edit it. --> | ||
|
||
# AvatarGroup API | ||
|
||
<p class="description">The API documentation of the AvatarGroup React component. Learn more about the props and the CSS customization points.</p> | ||
|
||
## Import | ||
|
||
```js | ||
import AvatarGroup from '@material-ui/lab/AvatarGroup'; | ||
// or | ||
import { AvatarGroup } from '@material-ui/lab'; | ||
``` | ||
|
||
You can learn more about the difference by [reading this guide](/guides/minimizing-bundle-size/). | ||
|
||
|
||
|
||
## Props | ||
|
||
| Name | Type | Default | Description | | ||
|:-----|:-----|:--------|:------------| | ||
| <span class="prop-name">children</span> | <span class="prop-type">node</span> | | The avatars to stack. | | ||
| <span class="prop-name">classes</span> | <span class="prop-type">object</span> | | Override or extend the styles applied to the component. See [CSS API](#css) below for more details. | | ||
|
||
The `ref` is forwarded to the root element. | ||
|
||
Any other props supplied will be provided to the root element (native element). | ||
|
||
## CSS | ||
|
||
- Style sheet name: `MuiAvatarGroup`. | ||
- Style sheet details: | ||
|
||
| Rule name | Global class | Description | | ||
|:-----|:-------------|:------------| | ||
| <span class="prop-name">root</span> | <span class="prop-name">.MuiAvatarGroup-root</span> | Styles applied to the root element. | ||
| <span class="prop-name">avatar</span> | <span class="prop-name">.MuiAvatarGroup-avatar</span> | Styles applied to the avatar elements. | ||
|
||
You can override the style of the component thanks to one of these customization points: | ||
|
||
- With a rule name of the [`classes` object prop](/customization/components/#overriding-styles-with-classes). | ||
- With a [global class name](/customization/components/#overriding-styles-with-global-class-names). | ||
- With a theme and an [`overrides` property](/customization/globals/#css). | ||
|
||
If that's not sufficient, you can check the [implementation of the component](https://github.com/mui-org/material-ui/blob/master/packages/material-ui-lab/src/AvatarGroup/AvatarGroup.js) for more detail. | ||
|
||
## Demos | ||
|
||
- [Avatars](/components/avatars/) | ||
|
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,79 @@ | ||
import React from 'react'; | ||
import Badge from '@material-ui/core/Badge'; | ||
import Avatar from '@material-ui/core/Avatar'; | ||
import { makeStyles, withStyles } from '@material-ui/core/styles'; | ||
|
||
const StyledBadge = withStyles(theme => ({ | ||
badge: { | ||
backgroundColor: '#44b700', | ||
color: '#44b700', | ||
boxShadow: `0 0 0 2px ${theme.palette.background.paper}`, | ||
'&::after': { | ||
position: 'absolute', | ||
top: 0, | ||
left: 0, | ||
width: '100%', | ||
height: '100%', | ||
borderRadius: '50%', | ||
animation: '$ripple 1.2s infinite ease-in-out', | ||
border: '1px solid currentColor', | ||
content: '""', | ||
}, | ||
}, | ||
'@keyframes ripple': { | ||
'0%': { | ||
transform: 'scale(.8)', | ||
opacity: 1, | ||
}, | ||
'100%': { | ||
transform: 'scale(2.4)', | ||
opacity: 0, | ||
}, | ||
}, | ||
}))(Badge); | ||
|
||
const SmallAvatar = withStyles(theme => ({ | ||
root: { | ||
width: 22, | ||
height: 22, | ||
border: `2px solid ${theme.palette.background.paper}`, | ||
}, | ||
}))(Avatar); | ||
|
||
const useStyles = makeStyles(theme => ({ | ||
root: { | ||
display: 'flex', | ||
'& > *': { | ||
margin: theme.spacing(1), | ||
}, | ||
}, | ||
})); | ||
|
||
export default function BadgeAvatars() { | ||
const classes = useStyles(); | ||
|
||
return ( | ||
<div className={classes.root}> | ||
<StyledBadge | ||
overlap="circle" | ||
anchorOrigin={{ | ||
vertical: 'bottom', | ||
horizontal: 'right', | ||
}} | ||
variant="dot" | ||
> | ||
<Avatar alt="Remy Sharp" src="/static/images/avatar/1.jpg" /> | ||
</StyledBadge> | ||
<Badge | ||
overlap="circle" | ||
anchorOrigin={{ | ||
vertical: 'bottom', | ||
horizontal: 'right', | ||
}} | ||
badgeContent={<SmallAvatar alt="Remy Sharp" src="/static/images/avatar/1.jpg" />} | ||
> | ||
<Avatar alt="Travis Howard" src="/static/images/avatar/2.jpg" /> | ||
</Badge> | ||
</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,85 @@ | ||
import React from 'react'; | ||
import Badge from '@material-ui/core/Badge'; | ||
import Avatar from '@material-ui/core/Avatar'; | ||
import { Theme, makeStyles, withStyles, createStyles } from '@material-ui/core/styles'; | ||
|
||
const StyledBadge = withStyles((theme: Theme) => | ||
createStyles({ | ||
badge: { | ||
backgroundColor: '#44b700', | ||
color: '#44b700', | ||
boxShadow: `0 0 0 2px ${theme.palette.background.paper}`, | ||
'&::after': { | ||
position: 'absolute', | ||
top: 0, | ||
left: 0, | ||
width: '100%', | ||
height: '100%', | ||
borderRadius: '50%', | ||
animation: '$ripple 1.2s infinite ease-in-out', | ||
border: '1px solid currentColor', | ||
content: '""', | ||
}, | ||
}, | ||
'@keyframes ripple': { | ||
'0%': { | ||
transform: 'scale(.8)', | ||
opacity: 1, | ||
}, | ||
'100%': { | ||
transform: 'scale(2.4)', | ||
opacity: 0, | ||
}, | ||
}, | ||
}), | ||
)(Badge); | ||
|
||
const SmallAvatar = withStyles((theme: Theme) => | ||
createStyles({ | ||
root: { | ||
width: 22, | ||
height: 22, | ||
border: `2px solid ${theme.palette.background.paper}`, | ||
}, | ||
}), | ||
)(Avatar); | ||
|
||
const useStyles = makeStyles((theme: Theme) => | ||
createStyles({ | ||
root: { | ||
display: 'flex', | ||
'& > *': { | ||
margin: theme.spacing(1), | ||
}, | ||
}, | ||
}), | ||
); | ||
|
||
export default function BadgeAvatars() { | ||
const classes = useStyles(); | ||
|
||
return ( | ||
<div className={classes.root}> | ||
<StyledBadge | ||
overlap="circle" | ||
anchorOrigin={{ | ||
vertical: 'bottom', | ||
horizontal: 'right', | ||
}} | ||
variant="dot" | ||
> | ||
<Avatar alt="Remy Sharp" src="/static/images/avatar/1.jpg" /> | ||
</StyledBadge> | ||
<Badge | ||
overlap="circle" | ||
anchorOrigin={{ | ||
vertical: 'bottom', | ||
horizontal: 'right', | ||
}} | ||
badgeContent={<SmallAvatar alt="Remy Sharp" src="/static/images/avatar/1.jpg" />} | ||
> | ||
<Avatar alt="Travis Howard" src="/static/images/avatar/2.jpg" /> | ||
</Badge> | ||
</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,17 @@ | ||
import React from 'react'; | ||
import Avatar from '@material-ui/core/Avatar'; | ||
import AvatarGroup from '@material-ui/lab/AvatarGroup'; | ||
import Tooltip from '@material-ui/core/Tooltip'; | ||
|
||
export default function GroupAvatars() { | ||
return ( | ||
<AvatarGroup> | ||
<Avatar alt="Remy Sharp" src="/static/images/avatar/1.jpg" /> | ||
<Avatar alt="Travis Howard" src="/static/images/avatar/2.jpg" /> | ||
<Avatar alt="Cindy Baker" src="/static/images/avatar/3.jpg" /> | ||
<Tooltip title="Foo • Bar • Baz"> | ||
<Avatar>+3</Avatar> | ||
</Tooltip> | ||
</AvatarGroup> | ||
); | ||
} |
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 React from 'react'; | ||
import Avatar from '@material-ui/core/Avatar'; | ||
import AvatarGroup from '@material-ui/lab/AvatarGroup'; | ||
import Tooltip from '@material-ui/core/Tooltip'; | ||
|
||
export default function GroupAvatars() { | ||
return ( | ||
<AvatarGroup> | ||
<Avatar alt="Remy Sharp" src="/static/images/avatar/1.jpg" /> | ||
<Avatar alt="Travis Howard" src="/static/images/avatar/2.jpg" /> | ||
<Avatar alt="Cindy Baker" src="/static/images/avatar/3.jpg" /> | ||
<Tooltip title="Foo • Bar • Baz"> | ||
<Avatar>+3</Avatar> | ||
</Tooltip> | ||
</AvatarGroup> | ||
); | ||
} |
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,32 @@ | ||
import React from 'react'; | ||
import { makeStyles } from '@material-ui/core/styles'; | ||
import Avatar from '@material-ui/core/Avatar'; | ||
|
||
const useStyles = makeStyles(theme => ({ | ||
root: { | ||
display: 'flex', | ||
'& > *': { | ||
margin: theme.spacing(1), | ||
}, | ||
}, | ||
small: { | ||
width: theme.spacing(3), | ||
height: theme.spacing(3), | ||
}, | ||
large: { | ||
width: theme.spacing(7), | ||
height: theme.spacing(7), | ||
}, | ||
})); | ||
|
||
export default function ImageAvatars() { | ||
const classes = useStyles(); | ||
|
||
return ( | ||
<div className={classes.root}> | ||
<Avatar alt="Remy Sharp" src="/static/images/avatar/1.jpg" className={classes.small} /> | ||
<Avatar alt="Remy Sharp" src="/static/images/avatar/1.jpg" /> | ||
<Avatar alt="Remy Sharp" src="/static/images/avatar/1.jpg" className={classes.large} /> | ||
</div> | ||
); | ||
} |
Oops, something went wrong.