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] Apply custom color if defined in the theme #27923

Merged
merged 2 commits into from
Aug 24, 2021

Conversation

eps1lon
Copy link
Member

@eps1lon eps1lon commented Aug 23, 2021

Given

export default function SvgIconsColor() {
  const theme = createTheme({
    palette: {
      custom: { main: '#ec407a' },
    },
  });

  return (
    <ThemeProvider theme={theme}>
      <FavoriteRounded fontSize="large" />
      <FavoriteRounded fontSize="large" color="secondary" />
      <FavoriteRounded fontSize="large" color="custom" />
    </ThemeProvider>
  );
}

Before:
localhost_5000_regression-SvgIcon_CustomColorSvgIcon_before

After:
localhost_5000_regression-SvgIcon_CustomColorSvgIcon_after

Closes #27831 see https://codesandbox.io/s/material-ui-v5-icons-custom-color-bug-forked-mzyxm

@eps1lon eps1lon added bug 🐛 Something doesn't work component: SvgIcon The React component. labels Aug 23, 2021
@eps1lon eps1lon changed the title [test] Add current behavior for SvgIcon with custom color [SvgIcon] Apply custom color if defined in the theme Aug 23, 2021
@mui-pr-bot
Copy link

mui-pr-bot commented Aug 23, 2021

Details of bundle changes (experimental)

Generated by 🚫 dangerJS against 9240056

@eps1lon eps1lon marked this pull request as ready for review August 23, 2021 13:44
<ThemeProvider theme={theme}>
<FavoriteRounded fontSize="large" />
<FavoriteRounded fontSize="large" color="secondary" />
<FavoriteRounded fontSize="large" color="custom" />
Copy link
Member

Choose a reason for hiding this comment

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

Should we add some instructions for typescript? Or do we already support extending the color prop values?

Copy link
Member

Choose a reason for hiding this comment

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

Ah I saw, we already have it. Nevermind looks good :)

Copy link
Member Author

Choose a reason for hiding this comment

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

Will go through #25934 and add tests accordingly. #25934 just changed documentation but there was no verification of the implementation (either manually or automatically).

Copy link
Member

Choose a reason for hiding this comment

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

Perfect! Thanks for taking this up 💯

Copy link
Member

@mnajdova mnajdova left a comment

Choose a reason for hiding this comment

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

👍

@mnajdova mnajdova merged commit c31db65 into mui:next Aug 24, 2021
@eps1lon eps1lon deleted the fix/Icon/custom-color branch August 24, 2021 09:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something doesn't work component: SvgIcon The React component.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Icon component can't receive custom theme colors
3 participants