Skip to content

Commit

Permalink
[Badge] Rename overlap circle -> circular and rectangle -> rectangula…
Browse files Browse the repository at this point in the history
…r for consistency (#22050)
  • Loading branch information
kodai3 authored Aug 3, 2020
1 parent d7b6051 commit 89a3cfa
Show file tree
Hide file tree
Showing 9 changed files with 66 additions and 45 deletions.
18 changes: 9 additions & 9 deletions docs/pages/api-docs/badge.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ The `MuiBadge` name can be used for providing [default props](/customization/glo
| <span class="prop-name">component</span> | <span class="prop-type">elementType</span> | <span class="prop-default">'span'</span> | The component used for the root node. Either a string to use a HTML element or a component. |
| <span class="prop-name">invisible</span> | <span class="prop-type">bool</span> | | If `true`, the badge will be invisible. |
| <span class="prop-name">max</span> | <span class="prop-type">number</span> | <span class="prop-default">99</span> | Max count to show. |
| <span class="prop-name">overlap</span> | <span class="prop-type">'circle'<br>&#124;&nbsp;'rectangle'</span> | <span class="prop-default">'rectangle'</span> | Wrapped shape the badge should overlap. |
| <span class="prop-name">overlap</span> | <span class="prop-type">'circular'<br>&#124;&nbsp;'rectangular'</span> | <span class="prop-default">'rectangular'</span> | Wrapped shape the badge should overlap. |
| <span class="prop-name">showZero</span> | <span class="prop-type">bool</span> | <span class="prop-default">false</span> | Controls whether the badge is hidden when `badgeContent` is zero. |
| <span class="prop-name">variant</span> | <span class="prop-type">'dot'<br>&#124;&nbsp;'standard'</span> | <span class="prop-default">'standard'</span> | The variant to use. |

Expand All @@ -54,14 +54,14 @@ Any other props supplied will be provided to the root element (native element).
| <span class="prop-name">colorSecondary</span> | <span class="prop-name">.MuiBadge-colorSecondary</span> | Styles applied to the root element if `color="secondary"`.
| <span class="prop-name">colorError</span> | <span class="prop-name">.MuiBadge-colorError</span> | Styles applied to the root element if `color="error"`.
| <span class="prop-name">dot</span> | <span class="prop-name">.MuiBadge-dot</span> | Styles applied to the root element if `variant="dot"`.
| <span class="prop-name">anchorOriginTopRightRectangle</span> | <span class="prop-name">.MuiBadge-anchorOriginTopRightRectangle</span> | Styles applied to the root element if `anchorOrigin={{ 'top', 'right' }} overlap="rectangle"`.
| <span class="prop-name">anchorOriginBottomRightRectangle</span> | <span class="prop-name">.MuiBadge-anchorOriginBottomRightRectangle</span> | Styles applied to the root element if `anchorOrigin={{ 'bottom', 'right' }} overlap="rectangle"`.
| <span class="prop-name">anchorOriginTopLeftRectangle</span> | <span class="prop-name">.MuiBadge-anchorOriginTopLeftRectangle</span> | Styles applied to the root element if `anchorOrigin={{ 'top', 'left' }} overlap="rectangle"`.
| <span class="prop-name">anchorOriginBottomLeftRectangle</span> | <span class="prop-name">.MuiBadge-anchorOriginBottomLeftRectangle</span> | Styles applied to the root element if `anchorOrigin={{ 'bottom', 'left' }} overlap="rectangle"`.
| <span class="prop-name">anchorOriginTopRightCircle</span> | <span class="prop-name">.MuiBadge-anchorOriginTopRightCircle</span> | Styles applied to the root element if `anchorOrigin={{ 'top', 'right' }} overlap="circle"`.
| <span class="prop-name">anchorOriginBottomRightCircle</span> | <span class="prop-name">.MuiBadge-anchorOriginBottomRightCircle</span> | Styles applied to the root element if `anchorOrigin={{ 'bottom', 'right' }} overlap="circle"`.
| <span class="prop-name">anchorOriginTopLeftCircle</span> | <span class="prop-name">.MuiBadge-anchorOriginTopLeftCircle</span> | Styles applied to the root element if `anchorOrigin={{ 'top', 'left' }} overlap="circle"`.
| <span class="prop-name">anchorOriginBottomLeftCircle</span> | <span class="prop-name">.MuiBadge-anchorOriginBottomLeftCircle</span> | Styles applied to the root element if `anchorOrigin={{ 'bottom', 'left' }} overlap="circle"`.
| <span class="prop-name">anchorOriginTopRightRectangular</span> | <span class="prop-name">.MuiBadge-anchorOriginTopRightRectangular</span> | Styles applied to the root element if `anchorOrigin={{ 'top', 'right' }} overlap="rectangular"`.
| <span class="prop-name">anchorOriginBottomRightRectangular</span> | <span class="prop-name">.MuiBadge-anchorOriginBottomRightRectangular</span> | Styles applied to the root element if `anchorOrigin={{ 'bottom', 'right' }} overlap="rectangular"`.
| <span class="prop-name">anchorOriginTopLeftRectangular</span> | <span class="prop-name">.MuiBadge-anchorOriginTopLeftRectangular</span> | Styles applied to the root element if `anchorOrigin={{ 'top', 'left' }} overlap="rectangular"`.
| <span class="prop-name">anchorOriginBottomLeftRectangular</span> | <span class="prop-name">.MuiBadge-anchorOriginBottomLeftRectangular</span> | Styles applied to the root element if `anchorOrigin={{ 'bottom', 'left' }} overlap="rectangular"`.
| <span class="prop-name">anchorOriginTopRightCircular</span> | <span class="prop-name">.MuiBadge-anchorOriginTopRightCircular</span> | Styles applied to the root element if `anchorOrigin={{ 'top', 'right' }} overlap="circular"`.
| <span class="prop-name">anchorOriginBottomRightCircular</span> | <span class="prop-name">.MuiBadge-anchorOriginBottomRightCircular</span> | Styles applied to the root element if `anchorOrigin={{ 'bottom', 'right' }} overlap="circular"`.
| <span class="prop-name">anchorOriginTopLeftCircular</span> | <span class="prop-name">.MuiBadge-anchorOriginTopLeftCircular</span> | Styles applied to the root element if `anchorOrigin={{ 'top', 'left' }} overlap="circular"`.
| <span class="prop-name">anchorOriginBottomLeftCircular</span> | <span class="prop-name">.MuiBadge-anchorOriginBottomLeftCircular</span> | Styles applied to the root element if `anchorOrigin={{ 'bottom', 'left' }} overlap="circular"`.
| <span class="prop-name">invisible</span> | <span class="prop-name">.MuiBadge-invisible</span> | Pseudo-class to the badge `span` element if `invisible={true}`.

You can override the style of the component thanks to one of these customization points:
Expand Down
4 changes: 2 additions & 2 deletions docs/src/pages/components/avatars/BadgeAvatars.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export default function BadgeAvatars() {
return (
<div className={classes.root}>
<StyledBadge
overlap="circle"
overlap="circular"
anchorOrigin={{
vertical: 'bottom',
horizontal: 'right',
Expand All @@ -65,7 +65,7 @@ export default function BadgeAvatars() {
<Avatar alt="Remy Sharp" src="/static/images/avatar/1.jpg" />
</StyledBadge>
<Badge
overlap="circle"
overlap="circular"
anchorOrigin={{
vertical: 'bottom',
horizontal: 'right',
Expand Down
4 changes: 2 additions & 2 deletions docs/src/pages/components/avatars/BadgeAvatars.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export default function BadgeAvatars() {
return (
<div className={classes.root}>
<StyledBadge
overlap="circle"
overlap="circular"
anchorOrigin={{
vertical: 'bottom',
horizontal: 'right',
Expand All @@ -76,7 +76,7 @@ export default function BadgeAvatars() {
<Avatar alt="Remy Sharp" src="/static/images/avatar/1.jpg" />
</StyledBadge>
<Badge
overlap="circle"
overlap="circular"
anchorOrigin={{
vertical: 'bottom',
horizontal: 'right',
Expand Down
9 changes: 7 additions & 2 deletions docs/src/pages/components/badges/BadgeOverlap.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,15 @@ export default function BadgeOverlap() {
<Badge color="secondary" badgeContent=" " variant="dot">
{rectangle}
</Badge>
<Badge color="secondary" overlap="circle" badgeContent=" ">
<Badge color="secondary" overlap="circular" badgeContent=" ">
{circle}
</Badge>
<Badge color="secondary" overlap="circle" badgeContent=" " variant="dot">
<Badge
color="secondary"
overlap="circular"
badgeContent=" "
variant="dot"
>
{circle}
</Badge>
</div>
Expand Down
9 changes: 7 additions & 2 deletions docs/src/pages/components/badges/BadgeOverlap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,15 @@ export default function BadgeOverlap() {
<Badge color="secondary" badgeContent=" " variant="dot">
{rectangle}
</Badge>
<Badge color="secondary" overlap="circle" badgeContent=" ">
<Badge color="secondary" overlap="circular" badgeContent=" ">
{circle}
</Badge>
<Badge color="secondary" overlap="circle" badgeContent=" " variant="dot">
<Badge
color="secondary"
overlap="circular"
badgeContent=" "
variant="dot"
>
{circle}
</Badge>
</div>
Expand Down
11 changes: 11 additions & 0 deletions docs/src/pages/guides/migration-v4/migration-v4.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,17 @@ Support for non-ref-forwarding class components in the `component` prop or as an
Otherwise check out the ["Caveat with refs" section in our composition guide](/guides/composition/#caveat-with-refs) to find out how to migrate.
This change affects almost all components where you're using the `component` prop or passing `children` to components that require `children` to be elements (e.g. `<MenuList><CustomMenuItem /></MenuList>`)

### Badge

- Rename `circle` to `circular` and `rectangle` to `rectangular` for consistency. The possible values should be adjectives, not nouns:

```diff
-<Badge overlap="circle">
-<Badge overlap="rectangle">
+<Badge overlap="circular">
+<Badge overlap="rectangular">
```

### BottomNavigation

- typescript: The `event` in `onChange` is no longer typed as a `React.ChangeEvent` but `React.SyntheticEvent`.
Expand Down
16 changes: 8 additions & 8 deletions packages/material-ui/src/Badge/Badge.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export interface BadgeTypeMap<P = {}, D extends React.ElementType = 'div'> {
/**
* Wrapped shape the badge should overlap.
*/
overlap?: 'rectangle' | 'circle';
overlap?: 'rectangular' | 'circular';
/**
* The content rendered within the badge.
*/
Expand Down Expand Up @@ -56,13 +56,13 @@ export type BadgeClassKey =
| 'colorSecondary'
| 'colorError'
| 'dot'
| 'anchorOriginTopRightRectangle'
| 'anchorOriginBottomRightRectangle'
| 'anchorOriginTopLeftRectangle'
| 'anchorOriginBottomLeftRectangle'
| 'anchorOriginTopRightCircle'
| 'anchorOriginBottomRightCircle'
| 'anchorOriginTopLeftCircle'
| 'anchorOriginTopRightRectangular'
| 'anchorOriginBottomRightRectangular'
| 'anchorOriginTopLeftRectangular'
| 'anchorOriginBottomLeftRectangular'
| 'anchorOriginTopRightCircular'
| 'anchorOriginBottomRightCircular'
| 'anchorOriginTopLeftCircular'
| 'invisible';
/**
*
Expand Down
36 changes: 18 additions & 18 deletions packages/material-ui/src/Badge/Badge.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ export const styles = (theme) => ({
minWidth: RADIUS_DOT * 2,
padding: 0,
},
/* Styles applied to the root element if `anchorOrigin={{ 'top', 'right' }} overlap="rectangle"`. */
anchorOriginTopRightRectangle: {
/* Styles applied to the root element if `anchorOrigin={{ 'top', 'right' }} overlap="rectangular"`. */
anchorOriginTopRightRectangular: {
top: 0,
right: 0,
transform: 'scale(1) translate(50%, -50%)',
Expand All @@ -72,8 +72,8 @@ export const styles = (theme) => ({
transform: 'scale(0) translate(50%, -50%)',
},
},
/* Styles applied to the root element if `anchorOrigin={{ 'bottom', 'right' }} overlap="rectangle"`. */
anchorOriginBottomRightRectangle: {
/* Styles applied to the root element if `anchorOrigin={{ 'bottom', 'right' }} overlap="rectangular"`. */
anchorOriginBottomRightRectangular: {
bottom: 0,
right: 0,
transform: 'scale(1) translate(50%, 50%)',
Expand All @@ -82,8 +82,8 @@ export const styles = (theme) => ({
transform: 'scale(0) translate(50%, 50%)',
},
},
/* Styles applied to the root element if `anchorOrigin={{ 'top', 'left' }} overlap="rectangle"`. */
anchorOriginTopLeftRectangle: {
/* Styles applied to the root element if `anchorOrigin={{ 'top', 'left' }} overlap="rectangular"`. */
anchorOriginTopLeftRectangular: {
top: 0,
left: 0,
transform: 'scale(1) translate(-50%, -50%)',
Expand All @@ -92,8 +92,8 @@ export const styles = (theme) => ({
transform: 'scale(0) translate(-50%, -50%)',
},
},
/* Styles applied to the root element if `anchorOrigin={{ 'bottom', 'left' }} overlap="rectangle"`. */
anchorOriginBottomLeftRectangle: {
/* Styles applied to the root element if `anchorOrigin={{ 'bottom', 'left' }} overlap="rectangular"`. */
anchorOriginBottomLeftRectangular: {
bottom: 0,
left: 0,
transform: 'scale(1) translate(-50%, 50%)',
Expand All @@ -102,8 +102,8 @@ export const styles = (theme) => ({
transform: 'scale(0) translate(-50%, 50%)',
},
},
/* Styles applied to the root element if `anchorOrigin={{ 'top', 'right' }} overlap="circle"`. */
anchorOriginTopRightCircle: {
/* Styles applied to the root element if `anchorOrigin={{ 'top', 'right' }} overlap="circular"`. */
anchorOriginTopRightCircular: {
top: '14%',
right: '14%',
transform: 'scale(1) translate(50%, -50%)',
Expand All @@ -112,8 +112,8 @@ export const styles = (theme) => ({
transform: 'scale(0) translate(50%, -50%)',
},
},
/* Styles applied to the root element if `anchorOrigin={{ 'bottom', 'right' }} overlap="circle"`. */
anchorOriginBottomRightCircle: {
/* Styles applied to the root element if `anchorOrigin={{ 'bottom', 'right' }} overlap="circular"`. */
anchorOriginBottomRightCircular: {
bottom: '14%',
right: '14%',
transform: 'scale(1) translate(50%, 50%)',
Expand All @@ -122,8 +122,8 @@ export const styles = (theme) => ({
transform: 'scale(0) translate(50%, 50%)',
},
},
/* Styles applied to the root element if `anchorOrigin={{ 'top', 'left' }} overlap="circle"`. */
anchorOriginTopLeftCircle: {
/* Styles applied to the root element if `anchorOrigin={{ 'top', 'left' }} overlap="circular"`. */
anchorOriginTopLeftCircular: {
top: '14%',
left: '14%',
transform: 'scale(1) translate(-50%, -50%)',
Expand All @@ -132,8 +132,8 @@ export const styles = (theme) => ({
transform: 'scale(0) translate(-50%, -50%)',
},
},
/* Styles applied to the root element if `anchorOrigin={{ 'bottom', 'left' }} overlap="circle"`. */
anchorOriginBottomLeftCircle: {
/* Styles applied to the root element if `anchorOrigin={{ 'bottom', 'left' }} overlap="circular"`. */
anchorOriginBottomLeftCircular: {
bottom: '14%',
left: '14%',
transform: 'scale(1) translate(-50%, 50%)',
Expand Down Expand Up @@ -173,7 +173,7 @@ const Badge = React.forwardRef(function Badge(props, ref) {
component: ComponentProp = 'span',
invisible: invisibleProp,
max: maxProp = 99,
overlap: overlapProp = 'rectangle',
overlap: overlapProp = 'rectangular',
showZero = false,
variant: variantProp = 'standard',
...other
Expand Down Expand Up @@ -285,7 +285,7 @@ Badge.propTypes = {
/**
* Wrapped shape the badge should overlap.
*/
overlap: PropTypes.oneOf(['circle', 'rectangle']),
overlap: PropTypes.oneOf(['circular', 'rectangular']),
/**
* Controls whether the badge is hidden when `badgeContent` is zero.
*/
Expand Down
4 changes: 2 additions & 2 deletions packages/material-ui/src/Badge/Badge.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ describe('<Badge />', () => {
badgeContent: 0,
color: 'primary',
variant: 'standard',
overlap: 'circle',
overlap: 'circular',
anchorOrigin: {
vertical: 'bottom',
horizontal: 'left',
Expand All @@ -185,6 +185,6 @@ describe('<Badge />', () => {
expect(findBadge(wrapper.container)).to.have.text('');
expect(findBadge(wrapper.container)).to.have.class(classes.colorSecondary);
expect(findBadge(wrapper.container)).to.have.class(classes.dot);
expect(findBadge(wrapper.container)).to.have.class(classes.anchorOriginTopRightRectangle);
expect(findBadge(wrapper.container)).to.have.class(classes.anchorOriginTopRightRectangular);
});
});

0 comments on commit 89a3cfa

Please sign in to comment.