Skip to content

Commit

Permalink
[Avatar] Use structured / semantic markup for avatars and avatar grou…
Browse files Browse the repository at this point in the history
…ps (#33994)
  • Loading branch information
paulschreiber committed Aug 31, 2022
1 parent 5a3036a commit 660b9da
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 1 deletion.
1 change: 1 addition & 0 deletions docs/pages/material-ui/api/avatar-group.json
Expand Up @@ -2,6 +2,7 @@
"props": {
"children": { "type": { "name": "node" } },
"classes": { "type": { "name": "object" } },
"component": { "type": { "name": "elementType" } },
"componentsProps": {
"type": { "name": "shape", "description": "{ additionalAvatar?: object }" },
"default": "{}"
Expand Down
1 change: 1 addition & 0 deletions docs/translations/api-docs/avatar-group/avatar-group.json
Expand Up @@ -3,6 +3,7 @@
"propDescriptions": {
"children": "The avatars to stack.",
"classes": "Override or extend the styles applied to the component. See <a href=\"#css\">CSS API</a> below for more details.",
"component": "The component used for the root node. Either a string to use a HTML element or a component.",
"componentsProps": "The props used for each slot inside the AvatarGroup.",
"max": "Max avatars to show before +x.",
"spacing": "Spacing between avatars.",
Expand Down
5 changes: 5 additions & 0 deletions packages/mui-material/src/AvatarGroup/AvatarGroup.d.ts
Expand Up @@ -17,6 +17,11 @@ export interface AvatarGroupProps extends StandardProps<React.HTMLAttributes<HTM
* Override or extend the styles applied to the component.
*/
classes?: Partial<AvatarGroupClasses>;
/**
* The component used for the root node.
* Either a string to use a HTML element or a component.
*/
component?: React.ElementType;
/**
* The props used for each slot inside the AvatarGroup.
* @default {}
Expand Down
8 changes: 8 additions & 0 deletions packages/mui-material/src/AvatarGroup/AvatarGroup.js
Expand Up @@ -67,6 +67,7 @@ const AvatarGroup = React.forwardRef(function AvatarGroup(inProps, ref) {
const {
children: childrenProp,
className,
component = 'div',
componentsProps = {},
max = 5,
spacing = 'medium',
Expand All @@ -80,6 +81,7 @@ const AvatarGroup = React.forwardRef(function AvatarGroup(inProps, ref) {
...props,
max,
spacing,
component,
variant,
};

Expand Down Expand Up @@ -115,6 +117,7 @@ const AvatarGroup = React.forwardRef(function AvatarGroup(inProps, ref) {

return (
<AvatarGroupRoot
as={component}
ownerState={ownerState}
className={clsx(classes.root, className)}
ref={ref}
Expand Down Expand Up @@ -167,6 +170,11 @@ AvatarGroup.propTypes /* remove-proptypes */ = {
* @ignore
*/
className: PropTypes.string,
/**
* The component used for the root node.
* Either a string to use a HTML element or a component.
*/
component: PropTypes.elementType,
/**
* The props used for each slot inside the AvatarGroup.
* @default {}
Expand Down
10 changes: 10 additions & 0 deletions packages/mui-material/src/AvatarGroup/AvatarGroup.spec.tsx
@@ -0,0 +1,10 @@
import * as React from 'react';
import AvatarGroup from '@mui/material/AvatarGroup';

<AvatarGroup component="ul" />;
<AvatarGroup variant="circular" />;
<AvatarGroup variant="rounded" />;
<AvatarGroup variant="square" />;

// @ts-expect-error
<AvatarGroup variant="unknown" />;
2 changes: 1 addition & 1 deletion packages/mui-material/src/AvatarGroup/AvatarGroup.test.js
Expand Up @@ -18,7 +18,7 @@ describe('<AvatarGroup />', () => {
muiName: 'MuiAvatarGroup',
refInstanceof: window.HTMLDivElement,
testVariantProps: { max: 10, spacing: 'small', variant: 'square' },
skip: ['componentProp', 'componentsProp'],
skip: ['componentsProp'],
}),
);

Expand Down

0 comments on commit 660b9da

Please sign in to comment.