-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
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
[Icon] Add a fontSize prop which accepts default and inherit #11986
Changes from 2 commits
7735280
d6746a6
8fc45fb
f30f4ec
6bb2bf9
1a9838f
efabf06
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,6 @@ import { capitalize } from '../utils/helpers'; | |
export const styles = theme => ({ | ||
root: { | ||
userSelect: 'none', | ||
fontSize: 24, | ||
width: '1em', | ||
height: '1em', | ||
display: 'inline-block', | ||
|
@@ -32,6 +31,12 @@ export const styles = theme => ({ | |
colorDisabled: { | ||
color: theme.palette.action.disabled, | ||
}, | ||
fontSizeDefault: { | ||
fontSize: 24, | ||
}, | ||
fontSizeInherit: { | ||
fontSize: 'inherit', | ||
}, | ||
}); | ||
|
||
function SvgIcon(props) { | ||
|
@@ -40,6 +45,7 @@ function SvgIcon(props) { | |
classes, | ||
className: classNameProp, | ||
color, | ||
fontSize, | ||
nativeColor, | ||
titleAccess, | ||
viewBox, | ||
|
@@ -48,6 +54,7 @@ function SvgIcon(props) { | |
|
||
const className = classNames( | ||
classes.root, | ||
classes[`fontSize${capitalize(fontSize)}`], | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can be simplified following your previous comment. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you mean like we do with color or sth more static like: |
||
{ | ||
[classes[`color${capitalize(color)}`]]: color !== 'inherit', | ||
}, | ||
|
@@ -88,6 +95,10 @@ SvgIcon.propTypes = { | |
* You can use the `nativeColor` property to apply a color attribute to the SVG element. | ||
*/ | ||
color: PropTypes.oneOf(['inherit', 'primary', 'secondary', 'action', 'error', 'disabled']), | ||
/** | ||
* The fontSize applied to the icon. Defaults to 24px, but can be configure to inherit font size. | ||
*/ | ||
fontSize: PropTypes.oneOf(['inherit', 'default']), | ||
/** | ||
* Applies a color attribute to the SVG element. | ||
*/ | ||
|
@@ -110,6 +121,7 @@ SvgIcon.propTypes = { | |
SvgIcon.defaultProps = { | ||
color: 'inherit', | ||
viewBox: '0 0 24 24', | ||
fontSize: 'default', | ||
}; | ||
|
||
SvgIcon.muiName = 'SvgIcon'; | ||
|
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.
it probably makes more sense to set this inside root and remove the whole
fontSizeDefault
class, does it?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 agree 👍