[Avatar] Add square variant and documentation#18116
Conversation
Details of bundle changes.Comparing: 8a78af8...e056a5c
|
|
Paper:
How do we reconcile these APIs? (We did a big job for v1 to standardise this sort of thing, but drift is inevitable unless kept in check.)
Can we avoid the use of "Want X? Do Y." where possible? (it doesn't read so well in English.) "If you need square or rounded avatars, use the |
|
@mbrookes Great question, I have been keen to solve this Paper concern since v1 :). What do you think of this normalization changes:
diff --git a/packages/material-ui/src/Paper/Paper.js b/packages/material-ui/src/Paper/Paper.js
index cf6c41260..85395f8c2 100644
--- a/packages/material-ui/src/Paper/Paper.js
+++ b/packages/material-ui/src/Paper/Paper.js
@@ -18,11 +18,12 @@ export const styles = theme => {
backgroundColor: theme.palette.background.paper,
color: theme.palette.text.primary,
transition: theme.transitions.create('box-shadow'),
- },
- /* Styles applied to the root element if `square={false}`. */
- rounded: {
borderRadius: theme.shape.borderRadius,
},
+ /* Styles applied to the root element if `square={true}`. */
+ square: {
+ borderRadius: 0,
+ },
...elevations,
};
};
@@ -51,7 +52,7 @@ const Paper = React.forwardRef(function Paper(props, ref) {
classes.root,
classes[`elevation${elevation}`],
{
- [classes.rounded]: !square,
+ [classes.square]: square,
},
className,
)}
👍 |
"circular" is synonymous with "round", while a circle is "a two-dimensional geometric figure, a line, consisting of the set of all those points in a plane that are equally distant from another point". The Fab isn't a circle. What's wrong with "round" though?
How does changing the class name help reconcile the API difference ( |
@mbrookes The main motivation for the proposal was to find the least amount of changes required to unify the API at the library level. We use "circle" over "round" for a couple of other cases: Badge and Skeleton.
The API shape difference (boolean vs enum) could be justified by the number of cases supported. Paper has 2, Avatar would have 3. I believe it's something we document in the API guide. |
|
@mattdotam Well done |

Closes #8426
What I did:
ButtonandPagecomponentsroundandsquareoptions for thevariantproperty (default isround)Avatarcomponent documentationyarn typescript,yarn prettierandyarn lintWhat needs to be done next:
roundorsquareclass has been applied, and that the correctborderRadiusvalue is setI've not used these test frameworks but I am keen to learn.