-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
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
[Button] Add startIcon / endIcon props #17600
Conversation
@material-ui/core: parsed: +0.16% , gzip: +0.18% Details of bundle changes.Comparing: e89abcd...7b67635
|
Should we add a demo with the circular progress? |
f183479
to
d86e41c
Compare
afcb6d7 ? 🤷♂ ("Crossed in the post"? 😄) |
45938ff
to
b6ec03f
Compare
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.
I was trying to think how this would affect FABs but it seems okay in its current state.
> | ||
<LanguageIcon /> | ||
<Hidden xsDown implementation="css"> |
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.
This div creates an invalid DOM structure: https://validator.w3.org/nu/?doc=https%3A%2F%2Fdeploy-preview-17600--material-ui.netlify.com%2F
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.
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.
Hidden doesn't support the component
prop. Do we go with the default js
implementation or fix that separately?
@@ -229,16 +226,14 @@ function AppFrame(props) { | |||
onClick={handleLanguageIconClick} | |||
data-ga-event-category="AppBar" | |||
data-ga-event-action="language" | |||
startIcon={<LanguageIcon fontSize="small" />} |
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.
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.
Oops, I should have tried it! I'll partially revert.
One other thought, should |
This would be a strong chance. I see a couple of options:
|
I'm in favour of option 1. Option 2, to change Option 3, agreed. Option 4. This risks a never ending stream of issues to support edge cases not covered by the current implementation. |
Option 1 and 4 seems the most popular alternatives in the other frameworks. I might like 1 better. @fzaninotto any preference? |
yes, I prefer option 1, too. |
@mbrookes I have pushed a commit with the following changes:
|
8f2dc7a
to
946490f
Compare
Should we force a font-size on the provided icon? diff --git a/packages/material-ui/src/Button/Button.js b/packages/material-ui/src/Button/Button.js
index 1f8763984..e4b4f8358 100644
--- a/packages/material-ui/src/Button/Button.js
+++ b/packages/material-ui/src/Button/Button.js
@@ -217,6 +217,24 @@ export const styles = theme => ({
marginRight: -4,
marginLeft: 8,
},
+ /* Styles applied to the icon element if supplied and `size="small"`. */
+ iconSizeSmall: {
+ '& > *': {
+ fontSize: 18,
+ },
+ },
+ /* Styles applied to the icon element if supplied and `size="medium"`. */
+ iconSizeMedium: {
+ '& > *': {
+ fontSize: 20,
+ },
+ },
+ /* Styles applied to the icon element if supplied and `size="large"`. */
+ iconSizeLarge: {
+ '& > *': {
+ fontSize: 22,
+ },
+ },
});
const Button = React.forwardRef(function Button(props, ref) {
@@ -238,8 +256,16 @@ const Button = React.forwardRef(function Button(props, ref) {
...other
} = props;
- const startIcon = startIconProp && <span className={classes.startIcon}>{startIconProp}</span>;
- const endIcon = endIconProp && <span className={classes.endIcon}>{endIconProp}</span>;
+ const startIcon = startIconProp && (
+ <span className={clsx(classes.startIcon, classes[`iconSize${capitalize(size)}`])}>
+ {startIconProp}
+ </span>
+ );
+ const endIcon = endIconProp && (
+ <span className={clsx(classes.endIcon, classes[`iconSize${capitalize(size)}`])}>
+ {endIconProp}
+ </span>
+ );
return (
<ButtonBase so it can be used like this: <Button startIcon={<DeleteIcon />} /> or stick with? <Button startIcon={<DeleteIcon fontSize="small" />} /> |
Providing the correct icon size sounds like a good idea. |
Ok, I'm preparing a new commit. |
I'm not sure that I have used the best approach to apply this CSS, happy to review a better approach. |
946490f
to
eab3331
Compare
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.
Two more...
🎉 |
It's not very clear whether we should start using these props versus children? Is the result the same at this time? |
@Floriferous Use the prop if you want correct visual output out from the box. If you need to custom the position, you might not need it. |
Closes #17494
I have gone with
startIcon
/endIcon
for now.