Skip to content

Commit

Permalink
fix yarn proptypes generation
Browse files Browse the repository at this point in the history
  • Loading branch information
oliviertassinari committed Feb 18, 2020
1 parent e15f32e commit 0ce81e0
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
3 changes: 1 addition & 2 deletions docs/pages/api/avatar-group.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ You can learn more about the difference by [reading this guide](/guides/minimizi
|:-----|:-----|:--------|:------------|
| <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. |
| <span class="prop-name">spacing</span> | <span class="prop-type">'small'<br>&#124;&nbsp;'medium'<br>&#124;&nbsp;'large'<br>&#124;&nbsp;number</span> | | Defines the spacing between `avatar` as `'large': -4px`, `'medium': -8px`, and `'small': -16px` or define a `number` as the spacing. |

| <span class="prop-name">spacing</span> | <span class="prop-type">'large'<br>&#124;&nbsp;'medium'<br>&#124;&nbsp;'small'<br>&#124;&nbsp;number</span> | <span class="prop-default">'medium'</span> | Spacing between avatars. |

The `ref` is forwarded to the root element.

Expand Down
2 changes: 1 addition & 1 deletion packages/material-ui-lab/src/AvatarGroup/AvatarGroup.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ export interface AvatarGroupProps

export type AvatarGroupClassKey = 'root' | 'avatar';

export default function AvatarGroup(props: AvatarGroupProps): JSX.Element | null;
export default function AvatarGroup(props: AvatarGroupProps): JSX.Element;
19 changes: 10 additions & 9 deletions packages/material-ui-lab/src/AvatarGroup/AvatarGroup.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@ import clsx from 'clsx';
import { withStyles } from '@material-ui/core/styles';

const SPACINGS = {
large: -4,
medium: -8,
small: -16
large: -4,
small: -16,
};

export const styles = theme => ({
Expand All @@ -18,11 +17,13 @@ export const styles = theme => ({
/* Styles applied to the avatar elements. */
avatar: {
border: `2px solid ${theme.palette.background.default}`,
marginLeft: -8,
},
});

const AvatarGroup = React.forwardRef(function AvatarGroup(props, ref) {
const { children: childrenProp, classes, className, spacing, ...other } = props;
const { children: childrenProp, classes, className, spacing = 'medium', ...other } = props;

This comment has been minimized.

Copy link
@GFynbo

GFynbo Feb 18, 2020

Contributor

Also if the “medium” value has been removed from the SPACINGS what will the default value refer to?

This comment has been minimized.

Copy link
@oliviertassinari

oliviertassinari Feb 18, 2020

Author Member

It will use the value provided with CSS (not inline style)


const children = React.Children.toArray(childrenProp).filter(child => {
if (process.env.NODE_ENV !== 'production') {
if (isFragment(child)) {
Expand All @@ -45,7 +46,7 @@ const AvatarGroup = React.forwardRef(function AvatarGroup(props, ref) {
className: clsx(child.props.className, classes.avatar),
style: {
zIndex: children.length - index,
marginLeft: spacing ? (SPACINGS[spacing] ? SPACINGS[spacing] : spacing) : -8,
marginLeft: spacing && SPACINGS[spacing] ? SPACINGS[spacing] : -spacing,

This comment has been minimized.

Copy link
@GFynbo

GFynbo Feb 18, 2020

Contributor

Won’t this cause issues if the user puts in something like “lrge” where it’ll attempt to use -“lrge”?

This comment has been minimized.

Copy link
@oliviertassinari

oliviertassinari Feb 18, 2020

Author Member

It will generate a prop type warning and fall back to the CSS value.

...child.props.style,
},
});
Expand All @@ -68,14 +69,14 @@ AvatarGroup.propTypes = {
* See [CSS API](#css) below for more details.
*/
classes: PropTypes.object,
/**
* Spacing between avatars.
*/
spacing: PropTypes.oneOfType([PropTypes.oneOf(['large', 'medium', 'small']), PropTypes.number]),
/**
* @ignore
*/
className: PropTypes.string,
/**
* Spacing between avatars.
*/
spacing: PropTypes.oneOfType([PropTypes.oneOf(['large', 'medium', 'small']), PropTypes.number]),
};

export default withStyles(styles, { name: 'MuiAvatarGroup' })(AvatarGroup);

0 comments on commit 0ce81e0

Please sign in to comment.