Skip to content
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

Merged

Conversation

alex-dikusar
Copy link
Contributor

@alex-dikusar alex-dikusar commented Nov 29, 2021

Fix #18782

Based on previous PR dedicated to that issue, just fixed last unresolved comments and opened my own PR on it.

@alex-dikusar alex-dikusar changed the title Svgicon/pass viewbox from custom component [SvgIcon] Allow viewBox to inherit from Component through inheritViewBox prop Nov 29, 2021
@alex-dikusar alex-dikusar force-pushed the svgicon/pass-viewbox-from-custom-component branch from 288f435 to 90cedcc Compare November 29, 2021 19:35
@mui-pr-bot
Copy link

mui-pr-bot commented Nov 29, 2021

Details of bundle changes

Generated by 🚫 dangerJS against 453769b

@alex-dikusar alex-dikusar reopened this Nov 29, 2021
@dainius-tamosiunas-tg
Copy link

@alex-dikusar are you planning to finish this PR anytime soon? :)

@alex-dikusar alex-dikusar requested a review from mnajdova December 9, 2021 13:24
Copy link
Member

@michaldudak michaldudak left a 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!

@michaldudak michaldudak merged commit 2663458 into mui:master Dec 30, 2021
@oliviertassinari oliviertassinari added component: SvgIcon The React component. new feature New feature or request labels Dec 31, 2021
Copy link
Member

@oliviertassinari oliviertassinari left a 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) => (
Copy link
Member

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.

Suggested change
const customSvg = (props) => (
const CustomSvg = (props) => (

Comment on lines 71 to +72
titleAccess,
inheritViewBox = false,
Copy link
Member

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

Suggested change
titleAccess,
inheritViewBox = false,
inheritViewBox = false,
titleAccess,

Comment on lines +52 to +56
* 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
Copy link
Member

@oliviertassinari oliviertassinari Dec 31, 2021

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:

Suggested change
* 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).
Copy link
Member

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.

Suggested change
- 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.

wladimirguerra pushed a commit to wladimirguerra/material-ui that referenced this pull request Feb 2, 2022
…Box prop (mui#29954)

Co-authored-by: Gonçalo Vieira Figueiredo <me@goncalovf.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: SvgIcon The React component. new feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[SvgIcon] allow viewBox to inherit from component
7 participants