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

[Icon] Allow customizing the 'material-icons' base class name #23613

Merged
merged 4 commits into from Nov 21, 2020

Conversation

rart
Copy link
Contributor

@rart rart commented Nov 19, 2020

The Icon component always adds the material-icons class to the element; however, per the docs, you may use other icon fonts with this component so always having this base class doesn't make sense in all cases. Best case scenario, the class is ignored but if someone is mixing two icon fonts (material-icons + some other), this may cause issues.

Also, now that the different Material Icon variants can be used via icon font, it would be convenient to be able to swap out material-icons for material-icons-round, for example.

@mui-pr-bot
Copy link

mui-pr-bot commented Nov 19, 2020

Details of bundle changes

Generated by 🚫 dangerJS against 9ff4d23

Copy link
Member

@eps1lon eps1lon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll repeat here what I said numerous times. The Icon component is for usage with Material-UI which is why it is published form @material-ui/core.

If you need it for different purposes I'd recommend copying it and adjusting it for your own purposes.

@rart
Copy link
Contributor Author

rart commented Nov 19, 2020

@eps1lon perhaps the docs referencing that it can be used with other fonts too is a source of confusion then?

Event if it is to be used with only material ui, material icons have the various base classes for the different icon variants (rounded, sharp, two-tone) so I felt it makes sense anyway.

From your comment, I understand I should just go ahead and close this PR as it won't be accepted?

@oliviertassinari oliviertassinari added component: Icon The React component. new feature New feature or request labels Nov 19, 2020
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.

The Icon component is for usage with Material-UI which is why it is published form @material-ui/core.

@eps1lon I don't follow the reasoning. Soon or later, developers need to add icons that aren't available in http://material.io/. We need a story to extend it. The value for using the component range between the integration with the theme, the extra features we apply, the right set of defaults. I think that the Icon should be able to host any font icons so is the SvgIcon to host any SVG icons. Material-UI !== Material Design. I think that Vuetify does it correctly: https://vuetifyjs.com/en/features/icons/.

docs/src/pages/components/icons/FontAwesomeIcon.js Outdated Show resolved Hide resolved
packages/material-ui/src/Icon/Icon.d.ts Outdated Show resolved Hide resolved
@oliviertassinari oliviertassinari changed the title [Icon] Add ability to change or omit the 'material-icons' base class of the component [Icon] Allow customizing the 'material-icons' base class name Nov 19, 2020
…e framer build`. Address Olivier's PR reviews: baseClass => baseClassName, small tweak to docs
@oliviertassinari oliviertassinari dismissed eps1lon’s stale review November 19, 2020 22:23

updated to keep emphasize on material.io/icons with the two-tone

@mbrookes
Copy link
Member

mbrookes commented Nov 21, 2020

What a about taking the base class name from the className prop:

If the className contains two values, the first values overrides the base classname. So no API change, and more concise.

-<Icon baseClassName="fas" className="fa-plus-circle" />
+<Icon className="fas fa-plus-circle" />

@oliviertassinari
Copy link
Member

oliviertassinari commented Nov 21, 2020

@mbrookes The current proposal allows to leverage theme.components.MuiIcon.defaultProps.baseClassName="material-icons-two-tone". I think that it's important to avoid forcing the creation of a wrapper Icon component. In practice, I expect developers to almost never do:

<Icon baseClassName="fas" className="fa-plus-circle" />

At least, I wouldn't. I would configure the base class name once, abstract it, somehow.

<Icon className="fa-plus-circle" />

We might want to document this.

@mbrookes
Copy link
Member

Good point. That seems worth adding to the docs.

```jsx
<Icon>add_circle</Icon>
```

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@oliviertassinari oliviertassinari merged commit d20687d into mui:next Nov 21, 2020
@eps1lon
Copy link
Member

eps1lon commented Nov 22, 2020

I don't follow the reasoning. Soon or later, developers need to add icons that aren't available in http://material.io.

Ok?

We need a story to extend it.

No? How did you make the logical jump?

@eps1lon
Copy link
Member

eps1lon commented Nov 22, 2020

And please don't dismiss my reviews. Unless you don't want to me review PRs

@oliviertassinari
Copy link
Member

oliviertassinari commented Nov 22, 2020

How did you make the logical jump?

@eps1lon Do you mean the logical jump between 1. developers need more icons than the one available in the filled theme of Material Design and 2. we need a story to extend it? 1. is the problem 2. is the solution.
So I assume the underlying question is: Why should we support anything else than the filled theme of Material Design?

I believe we already support it. Developers can apply the material-material-icons-two-tone class name manually for a different them of Material Design, or fas for the FA Solid theme. I think that the main value proposition of this pull request by @rart is a new API that makes it simpler to configure this globally with the theme and improved documentation for it.

Still why?

  1. Integration with the theme, access to the system props, similar to why: https://chakra-ui.com/docs/components/icon#using-a-third-party-icon-library
  2. Solve a few issues: aria-hidden for accessibility, notranslate, for Google trad, overflow hidden to reduce flash when loading the font.
  3. Consistency, I think that it makes it easier to use two different sets of icons on the same page with a consistent DX and UX. You might need one icon from MD, another from your custom set of icons.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: Icon The React component. new feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants