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

[Avatar] Use structured / semantic markup for avatars and avatar groups #33994

Merged
merged 10 commits into from Aug 31, 2022
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