-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
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] Add square variant and documentation #18116
Conversation
Details of bundle changes.Comparing: 8a78af8...e056a5c
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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:
Button
andPage
componentsround
andsquare
options for thevariant
property (default isround
)Avatar
component documentationyarn typescript
,yarn prettier
andyarn lint
What needs to be done next:
round
orsquare
class has been applied, and that the correctborderRadius
value is setI've not used these test frameworks but I am keen to learn.