Skip to content

Commit

Permalink
[Alert] improve filled variant coloring
Browse files Browse the repository at this point in the history
  • Loading branch information
ahtcx committed Jan 10, 2020
1 parent 95841fb commit e6aea69
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
10 changes: 6 additions & 4 deletions packages/material-ui-lab/src/Alert/Alert.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react';
import PropTypes from 'prop-types';
import clsx from 'clsx';
import { hsl, parseToHsl } from 'polished';
import { withStyles, lighten, darken } from '@material-ui/core/styles';
import Paper from '@material-ui/core/Paper';
import SuccessOutlinedIcon from '../internal/svg-icons/SuccessOutlined';
Expand All @@ -14,6 +15,7 @@ import { capitalize } from '@material-ui/core/utils';
export const styles = theme => {
const getColor = theme.palette.type === 'light' ? darken : lighten;
const getBackgroundColor = theme.palette.type === 'light' ? lighten : darken;
const getColorWithLightness = (color, lightness) => hsl({ ...parseToHsl(color), lightness });

return {
/* Styles applied to the root element. */
Expand Down Expand Up @@ -92,25 +94,25 @@ export const styles = theme => {
filledSuccess: {
color: '#fff',
fontWeight: theme.typography.fontWeightMedium,
backgroundColor: theme.palette.success.main,
backgroundColor: getColorWithLightness(theme.palette.success.main, 0.45),
},
/* Styles applied to the root element if `variant="filled"` and `color="info"`. */
filledInfo: {
color: '#fff',
fontWeight: theme.typography.fontWeightMedium,
backgroundColor: theme.palette.info.main,
backgroundColor: getColorWithLightness(theme.palette.info.main, 0.45),
},
/* Styles applied to the root element if `variant="filled"` and `color="warning"`. */
filledWarning: {
color: '#fff',
fontWeight: theme.typography.fontWeightMedium,
backgroundColor: theme.palette.warning.main,
backgroundColor: getColorWithLightness(theme.palette.warning.main, 0.45),
},
/* Styles applied to the root element if `variant="filled"` and `color="error"`. */
filledError: {
color: '#fff',
fontWeight: theme.typography.fontWeightMedium,
backgroundColor: theme.palette.error.main,
backgroundColor: getColorWithLightness(theme.palette.error.main, 0.45),
},
/* Styles applied to the icon wrapper element. */
icon: {
Expand Down
1 change: 1 addition & 0 deletions packages/material-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
"convert-css-length": "^2.0.1",
"hoist-non-react-statics": "^3.2.1",
"normalize-scroll-left": "^0.2.0",
"polished": "^3.4.2",
"popper.js": "^1.14.1",
"prop-types": "^15.7.2",
"react-is": "^16.8.0",
Expand Down
7 changes: 7 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -11532,6 +11532,13 @@ pngjs@^2.2.0:
resolved "https://registry.yarnpkg.com/pngjs/-/pngjs-2.3.1.tgz#11d1e12b9cb64d63e30c143a330f4c1f567da85f"
integrity sha1-EdHhK5y2TWPjDBQ6Mw9MH1Z9qF8=

polished@^3.4.2:
version "3.4.2"
resolved "https://registry.yarnpkg.com/polished/-/polished-3.4.2.tgz#b4780dad81d64df55615fbfc77acb52fd17d88cd"
integrity sha512-9Rch6iMZckABr6EFCLPZsxodeBpXMo9H4fRlfR/9VjMEyy5xpo1/WgXlJGgSjPyVhEZNycbW7UmYMNyWS5MI0g==
dependencies:
"@babel/runtime" "^7.6.3"

popper.js@^1.14.1:
version "1.16.0"
resolved "https://registry.yarnpkg.com/popper.js/-/popper.js-1.16.0.tgz#2e1816bcbbaa518ea6c2e15a466f4cb9c6e2fbb3"
Expand Down

0 comments on commit e6aea69

Please sign in to comment.