question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Make theme.palette.augmentColor() pure

See original GitHub issue

We love the theme object, but starting to see how it could be extended.

• In most cases, a primary, secondary, error and grey color palette will support most applications. • I am having to add custom colors to the theme to cover a warning situation.

Rather than extend the theme to custom code new palettes, why not use the power of this theme to handle warning color just like error?

"warning": {
      "light": "#",
      "main": "#",
      "dark": "#",
      "contrastText": "#fff"
    }

Also, I would like to see warning and error as color props for the Button component:

<Button color='primary' variant='raised'>Text</Button>
<Button color='secondary' variant='raised'>Text</Button>
<Button color='error' variant='raised'>Text</Button>
<Button color='warning' variant='raised'>Text</Button>

This will greatly reduce the amount of code developers are having to write for more use cases for buttons, and use the power of the theme to consistently style applications.

Great work!!

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:3
  • Comments:12 (10 by maintainers)

github_iconTop GitHub Comments

2reactions
sveyretcommented, Oct 24, 2018
1reaction
oliviertassinaricommented, Dec 3, 2018

@jacobweber I’m not sure it will be possible, the augmentColor function relies on two theme variables you can provide as options:

const theme = {
  palette: {
    // Used by `getContrastText()` to maximize the contrast between the background and
    // the text.
    contrastThreshold = 3,
    // Used by the functions below to shift a color's luminance by approximately
    // two indexes within its tonal palette.
    // E.g., shift from Red 500 to Red 300 or Red 700.
    tonalOffset = 0.2,
  },
};
Read more comments on GitHub >

github_iconTop Results From Across the Web

Make theme.palette.augmentColor() pure #12390 - GitHub
In most cases, a primary, secondary, error and grey color palette will support most applications. • I am having to add custom colors...
Read more >
Palette - Material UI - MUI
The palette enables you to modify the color of the components to suit your brand. Palette colors. The theme exposes the following palette...
Read more >
How can I extend Color Palette in Material UI with Typescript
I am trying to extend the color palette on a global theme. in my themeConitainer.tsx import { ThemeOptions } from '@material-ui/core/styles/ ...
Read more >
v4.0.0-alpha.0 - material-ui changelog
The theme.palette.augmentColor() method no longer performs a side effect on its input color. In order to use it correctly, you have to use...
Read more >
Customizing the Material-UI Theme Color Palette (MUI v5)
This demo shows how to override palette colors, add new categories to the palette, and create a component that uses the custom colors....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found