-
-
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
[SvgIcon] Allow viewBox to inherit from Component through inheritViewBox prop #29954
[SvgIcon] Allow viewBox to inherit from Component through inheritViewBox prop #29954
Conversation
288f435
to
90cedcc
Compare
@alex-dikusar are you planning to finish this PR anytime soon? :) |
d483e37
to
453769b
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.
Looks OK to me. Thanks for your contribution, @alex-dikusar!
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.
In https://mui.com/components/icons/#component-prop I believe we can replace viewBox="0 0 600 476.6"
for this new prop. This seems important to update.
@@ -96,4 +96,24 @@ describe('<SvgIcon />', () => { | |||
expect(container.firstChild).to.have.class(classes.fontSizeInherit); | |||
}); | |||
}); | |||
|
|||
describe('prop: inheritViewBox', () => { | |||
const customSvg = (props) => ( |
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 is a component, it's should be uppercased.
const customSvg = (props) => ( | |
const CustomSvg = (props) => ( |
titleAccess, | ||
inheritViewBox = false, |
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.
To keep it sorted ASC
titleAccess, | |
inheritViewBox = false, | |
inheritViewBox = false, | |
titleAccess, |
* Useful when you want to reference a custom `component` and have `SvgIcon` pass that | ||
* `component`'s viewBox to the root node. | ||
* If `true`, the root node will inherit the custom `component`'s viewBox and the `viewBox` | ||
* prop will be ignored. | ||
* @default false |
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.
In the other props description, I believe we first describe what the prop does, and only after why it might be used for:
* Useful when you want to reference a custom `component` and have `SvgIcon` pass that | |
* `component`'s viewBox to the root node. | |
* If `true`, the root node will inherit the custom `component`'s viewBox and the `viewBox` | |
* prop will be ignored. | |
* @default false | |
* If `true`, the root node will inherit the custom `component`'s viewBox and the `viewBox` | |
* prop will be ignored. | |
* Useful when you want to reference a custom `component` and have `SvgIcon` pass that | |
* `component`'s viewBox to the root node. | |
* @default false |
@@ -97,7 +97,7 @@ If you need a custom SVG icon (not available in the [Material Icons](/components | |||
This component extends the native `<svg>` element: | |||
|
|||
- It comes with built-in accessibility. | |||
- SVG elements should be scaled for a 24x24px viewport so that the resulting icon can be used as is, or included as a child for other MUI components that use icons. (This can be customized with the `viewBox` attribute). | |||
- SVG elements should be scaled for a 24x24px viewport so that the resulting icon can be used as is, or included as a child for other MUI components that use icons. (This can be customized with the `viewBox` attribute, to inherit `viewBox` value from original image `inheritViewBox` attribute can be used). |
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.
At this point, the parenthesis probably is not relevant.
- SVG elements should be scaled for a 24x24px viewport so that the resulting icon can be used as is, or included as a child for other MUI components that use icons. (This can be customized with the `viewBox` attribute, to inherit `viewBox` value from original image `inheritViewBox` attribute can be used). | |
- SVG elements should be scaled for a 24x24px viewport so that the resulting icon can be used as-is, or included as a child for other MUI components that use icons. This can be customized with the `viewBox` attribute, to inherit `viewBox` value from the original image `inheritViewBox` attribute can be used. |
…Box prop (mui#29954) Co-authored-by: Gonçalo Vieira Figueiredo <me@goncalovf.com>
Fix #18782
Based on previous PR dedicated to that issue, just fixed last unresolved comments and opened my own PR on it.