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

[theme] Rename fade to alpha #22834

Merged
merged 20 commits into from Oct 7, 2020
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 6 additions & 6 deletions docs/src/modules/components/AppDrawerNavItem.js
@@ -1,7 +1,7 @@
import * as React from 'react';
import PropTypes from 'prop-types';
import clsx from 'clsx';
import { makeStyles, fade } from '@material-ui/core/styles';
import { makeStyles, alpha } from '@material-ui/core/styles';
import Collapse from '@material-ui/core/Collapse';
import ButtonBase from '@material-ui/core/ButtonBase';
import ArrowRightIcon from '@material-ui/icons/ArrowRight';
Expand Down Expand Up @@ -29,7 +29,7 @@ const useStyles = makeStyles((theme) => ({
}),
'&:hover': {
color: theme.palette.text.primary,
backgroundColor: fade(theme.palette.text.primary, theme.palette.action.hoverOpacity),
backgroundColor: alpha(theme.palette.text.primary, theme.palette.action.hoverOpacity),
},
'&.Mui-focusVisible': {
backgroundColor: theme.palette.action.focus,
Expand Down Expand Up @@ -58,19 +58,19 @@ const useStyles = makeStyles((theme) => ({
color: theme.palette.text.secondary,
'&.app-drawer-active': {
color: theme.palette.primary.main,
backgroundColor: fade(theme.palette.primary.main, theme.palette.action.selectedOpacity),
backgroundColor: alpha(theme.palette.primary.main, theme.palette.action.selectedOpacity),
'&:hover': {
backgroundColor: fade(
backgroundColor: alpha(
theme.palette.primary.main,
theme.palette.action.selectedOpacity + theme.palette.action.hoverOpacity,
),
// Reset on touch devices, it doesn't add specificity
'@media (hover: none)': {
backgroundColor: fade(theme.palette.primary.main, theme.palette.action.selectedOpacity),
backgroundColor: alpha(theme.palette.primary.main, theme.palette.action.selectedOpacity),
},
},
'&.Mui-focusVisible': {
backgroundColor: fade(
backgroundColor: alpha(
theme.palette.primary.main,
theme.palette.action.selectedOpacity + theme.palette.action.focusOpacity,
),
Expand Down
6 changes: 3 additions & 3 deletions docs/src/modules/components/AppSearch.js
Expand Up @@ -3,7 +3,7 @@ import url from 'url';
import { useSelector } from 'react-redux';
import useLazyCSS from 'docs/src/modules/utils/useLazyCSS';
import useMediaQuery from '@material-ui/core/useMediaQuery';
import { fade, useTheme, makeStyles } from '@material-ui/core/styles';
import { alpha, useTheme, makeStyles } from '@material-ui/core/styles';
import Input from '@material-ui/core/Input';
import SearchIcon from '@material-ui/icons/Search';
import { handleEvent } from 'docs/src/modules/components/MarkdownLinks';
Expand Down Expand Up @@ -77,9 +77,9 @@ const useStyles = makeStyles(
marginRight: theme.spacing(2),
marginLeft: theme.spacing(1),
borderRadius: theme.shape.borderRadius,
backgroundColor: fade(theme.palette.common.white, 0.15),
backgroundColor: alpha(theme.palette.common.white, 0.15),
'&:hover': {
backgroundColor: fade(theme.palette.common.white, 0.25),
backgroundColor: alpha(theme.palette.common.white, 0.25),
},
'& $inputInput': {
transition: theme.transitions.create('width'),
Expand Down
4 changes: 2 additions & 2 deletions docs/src/modules/components/Demo.js
Expand Up @@ -4,7 +4,7 @@ import PropTypes from 'prop-types';
import clsx from 'clsx';
import copy from 'clipboard-copy';
import { useSelector, useDispatch } from 'react-redux';
import { fade, makeStyles, useTheme } from '@material-ui/core/styles';
import { alpha, makeStyles, useTheme } from '@material-ui/core/styles';
import IconButton from '@material-ui/core/IconButton';
import useMediaQuery from '@material-ui/core/useMediaQuery';
import Collapse from '@material-ui/core/Collapse';
Expand Down Expand Up @@ -648,7 +648,7 @@ const useStyles = makeStyles(
/* Isolate the demo with an outline. */
demoBgOutlined: {
padding: theme.spacing(3),
border: `1px solid ${fade(theme.palette.action.active, 0.12)}`,
border: `1px solid ${alpha(theme.palette.action.active, 0.12)}`,
borderLeftWidth: 0,
borderRightWidth: 0,
[theme.breakpoints.up('sm')]: {
Expand Down
4 changes: 2 additions & 2 deletions docs/src/modules/components/ad.styles.js
@@ -1,11 +1,11 @@
import { fade } from '@material-ui/core/styles';
import { alpha } from '@material-ui/core/styles';
import { adShape } from 'docs/src/modules/components/AdManager';

const adBodyImageStyles = (theme) => ({
root: {
display: 'block',
overflow: 'hidden',
border: `1px solid ${fade(theme.palette.action.active, 0.12)}`,
border: `1px solid ${alpha(theme.palette.action.active, 0.12)}`,
padding: `${theme.spacing(1.5)} ${theme.spacing(1.5)} ${theme.spacing(
1.5,
)} calc(${theme.spacing(1.5)} + 130px)`,
Expand Down
6 changes: 3 additions & 3 deletions docs/src/pages/components/app-bar/PrimarySearchAppBar.js
@@ -1,5 +1,5 @@
import * as React from 'react';
import { fade, makeStyles } from '@material-ui/core/styles';
import { alpha, makeStyles } from '@material-ui/core/styles';
import AppBar from '@material-ui/core/AppBar';
import Toolbar from '@material-ui/core/Toolbar';
import IconButton from '@material-ui/core/IconButton';
Expand Down Expand Up @@ -31,9 +31,9 @@ const useStyles = makeStyles((theme) => ({
search: {
position: 'relative',
borderRadius: theme.shape.borderRadius,
backgroundColor: fade(theme.palette.common.white, 0.15),
backgroundColor: alpha(theme.palette.common.white, 0.15),
'&:hover': {
backgroundColor: fade(theme.palette.common.white, 0.25),
backgroundColor: alpha(theme.palette.common.white, 0.25),
},
marginRight: theme.spacing(2),
marginLeft: 0,
Expand Down
6 changes: 3 additions & 3 deletions docs/src/pages/components/app-bar/PrimarySearchAppBar.tsx
@@ -1,6 +1,6 @@
import * as React from 'react';
import {
fade,
alpha,
makeStyles,
Theme,
createStyles,
Expand Down Expand Up @@ -37,9 +37,9 @@ const useStyles = makeStyles((theme: Theme) =>
search: {
position: 'relative',
borderRadius: theme.shape.borderRadius,
backgroundColor: fade(theme.palette.common.white, 0.15),
backgroundColor: alpha(theme.palette.common.white, 0.15),
'&:hover': {
backgroundColor: fade(theme.palette.common.white, 0.25),
backgroundColor: alpha(theme.palette.common.white, 0.25),
},
marginRight: theme.spacing(2),
marginLeft: 0,
Expand Down
6 changes: 3 additions & 3 deletions docs/src/pages/components/app-bar/SearchAppBar.js
Expand Up @@ -4,7 +4,7 @@ import Toolbar from '@material-ui/core/Toolbar';
import IconButton from '@material-ui/core/IconButton';
import Typography from '@material-ui/core/Typography';
import InputBase from '@material-ui/core/InputBase';
import { fade, makeStyles } from '@material-ui/core/styles';
import { alpha, makeStyles } from '@material-ui/core/styles';
import MenuIcon from '@material-ui/icons/Menu';
import SearchIcon from '@material-ui/icons/Search';

Expand All @@ -25,9 +25,9 @@ const useStyles = makeStyles((theme) => ({
search: {
position: 'relative',
borderRadius: theme.shape.borderRadius,
backgroundColor: fade(theme.palette.common.white, 0.15),
backgroundColor: alpha(theme.palette.common.white, 0.15),
'&:hover': {
backgroundColor: fade(theme.palette.common.white, 0.25),
backgroundColor: alpha(theme.palette.common.white, 0.25),
},
marginLeft: 0,
width: '100%',
Expand Down
6 changes: 3 additions & 3 deletions docs/src/pages/components/app-bar/SearchAppBar.tsx
Expand Up @@ -6,7 +6,7 @@ import Typography from '@material-ui/core/Typography';
import InputBase from '@material-ui/core/InputBase';
import {
createStyles,
fade,
alpha,
Theme,
makeStyles,
} from '@material-ui/core/styles';
Expand All @@ -31,9 +31,9 @@ const useStyles = makeStyles((theme: Theme) =>
search: {
position: 'relative',
borderRadius: theme.shape.borderRadius,
backgroundColor: fade(theme.palette.common.white, 0.15),
backgroundColor: alpha(theme.palette.common.white, 0.15),
'&:hover': {
backgroundColor: fade(theme.palette.common.white, 0.25),
backgroundColor: alpha(theme.palette.common.white, 0.25),
},
marginLeft: 0,
width: '100%',
Expand Down
4 changes: 2 additions & 2 deletions docs/src/pages/components/autocomplete/GitHubLabel.js
@@ -1,6 +1,6 @@
/* eslint-disable @typescript-eslint/no-use-before-define */
import * as React from 'react';
import { useTheme, fade, makeStyles } from '@material-ui/core/styles';
import { useTheme, alpha, makeStyles } from '@material-ui/core/styles';
import Popper from '@material-ui/core/Popper';
import ClickAwayListener from '@material-ui/core/ClickAwayListener';
import SettingsIcon from '@material-ui/icons/Settings';
Expand Down Expand Up @@ -68,7 +68,7 @@ const useStyles = makeStyles((theme) => ({
border: '1px solid #ced4da',
fontSize: 14,
'&:focus': {
boxShadow: `${fade(theme.palette.primary.main, 0.25)} 0 0 0 0.2rem`,
boxShadow: `${alpha(theme.palette.primary.main, 0.25)} 0 0 0 0.2rem`,
borderColor: theme.palette.primary.main,
},
},
Expand Down
4 changes: 2 additions & 2 deletions docs/src/pages/components/autocomplete/GitHubLabel.tsx
Expand Up @@ -2,7 +2,7 @@
import * as React from 'react';
import {
useTheme,
fade,
alpha,
makeStyles,
Theme,
createStyles,
Expand Down Expand Up @@ -77,7 +77,7 @@ const useStyles = makeStyles((theme: Theme) =>
border: '1px solid #ced4da',
fontSize: 14,
'&:focus': {
boxShadow: `${fade(theme.palette.primary.main, 0.25)} 0 0 0 0.2rem`,
boxShadow: `${alpha(theme.palette.primary.main, 0.25)} 0 0 0 0.2rem`,
borderColor: theme.palette.primary.main,
},
},
Expand Down
4 changes: 2 additions & 2 deletions docs/src/pages/components/switches/CustomizedSwitches.js
@@ -1,5 +1,5 @@
import * as React from 'react';
import { fade, withStyles } from '@material-ui/core/styles';
import { alpha, withStyles } from '@material-ui/core/styles';
import { purple } from '@material-ui/core/colors';
import FormGroup from '@material-ui/core/FormGroup';
import FormControlLabel from '@material-ui/core/FormControlLabel';
Expand All @@ -13,7 +13,7 @@ const PurpleSwitch = withStyles((theme) => ({
'&$checked': {
color: purple[500],
'&:hover': {
backgroundColor: fade(purple[500], theme.palette.action.hoverOpacity),
backgroundColor: alpha(purple[500], theme.palette.action.hoverOpacity),
},
},
'&$checked + $track': {
Expand Down
7 changes: 5 additions & 2 deletions docs/src/pages/components/switches/CustomizedSwitches.tsx
@@ -1,6 +1,6 @@
import * as React from 'react';
import {
fade,
alpha,
withStyles,
Theme,
createStyles,
Expand All @@ -27,7 +27,10 @@ const PurpleSwitch = withStyles((theme: Theme) =>
'&$checked': {
color: purple[500],
'&:hover': {
backgroundColor: fade(purple[500], theme.palette.action.hoverOpacity),
backgroundColor: alpha(
purple[500],
theme.palette.action.hoverOpacity,
),
},
},
'&$checked + $track': {
Expand Down
6 changes: 3 additions & 3 deletions docs/src/pages/components/text-fields/CustomizedInputs.js
@@ -1,6 +1,6 @@
import * as React from 'react';
import {
fade,
alpha,
ThemeProvider,
useTheme,
withStyles,
Expand Down Expand Up @@ -68,7 +68,7 @@ const BootstrapInput = withStyles((theme) => ({
'"Segoe UI Symbol"',
].join(','),
'&:focus': {
boxShadow: `${fade(theme.palette.primary.main, 0.25)} 0 0 0 0.2rem`,
boxShadow: `${alpha(theme.palette.primary.main, 0.25)} 0 0 0 0.2rem`,
borderColor: theme.palette.primary.main,
},
},
Expand All @@ -90,7 +90,7 @@ const useStylesReddit = makeStyles((theme) => ({
},
'&$focused': {
backgroundColor: 'transparent',
boxShadow: `${fade(theme.palette.primary.main, 0.25)} 0 0 0 2px`,
boxShadow: `${alpha(theme.palette.primary.main, 0.25)} 0 0 0 2px`,
borderColor: theme.palette.primary.main,
},
},
Expand Down
6 changes: 3 additions & 3 deletions docs/src/pages/components/text-fields/CustomizedInputs.tsx
@@ -1,7 +1,7 @@
import * as React from 'react';
import {
createStyles,
fade,
alpha,
Theme,
ThemeProvider,
useTheme,
Expand Down Expand Up @@ -72,7 +72,7 @@ const BootstrapInput = withStyles((theme: Theme) =>
'"Segoe UI Symbol"',
].join(','),
'&:focus': {
boxShadow: `${fade(theme.palette.primary.main, 0.25)} 0 0 0 0.2rem`,
boxShadow: `${alpha(theme.palette.primary.main, 0.25)} 0 0 0 0.2rem`,
borderColor: theme.palette.primary.main,
},
},
Expand All @@ -96,7 +96,7 @@ const useStylesReddit = makeStyles((theme: Theme) =>
},
'&$focused': {
backgroundColor: 'transparent',
boxShadow: `${fade(theme.palette.primary.main, 0.25)} 0 0 0 2px`,
boxShadow: `${alpha(theme.palette.primary.main, 0.25)} 0 0 0 2px`,
borderColor: theme.palette.primary.main,
},
},
Expand Down
4 changes: 2 additions & 2 deletions docs/src/pages/components/tree-view/CustomizedTreeView.js
@@ -1,7 +1,7 @@
import * as React from 'react';
import PropTypes from 'prop-types';
import SvgIcon from '@material-ui/core/SvgIcon';
import { fade, makeStyles, withStyles } from '@material-ui/core/styles';
import { alpha, makeStyles, withStyles } from '@material-ui/core/styles';
import TreeView from '@material-ui/lab/TreeView';
import TreeItem from '@material-ui/lab/TreeItem';
import Collapse from '@material-ui/core/Collapse';
Expand Down Expand Up @@ -74,7 +74,7 @@ const StyledTreeItem = withStyles((theme) => ({
group: {
marginLeft: 15,
paddingLeft: 18,
borderLeft: `1px dashed ${fade(theme.palette.text.primary, 0.4)}`,
borderLeft: `1px dashed ${alpha(theme.palette.text.primary, 0.4)}`,
},
}))((props) => (
<TreeItem {...props} TransitionComponent={TransitionComponent} />
Expand Down
4 changes: 2 additions & 2 deletions docs/src/pages/components/tree-view/CustomizedTreeView.tsx
@@ -1,7 +1,7 @@
import * as React from 'react';
import SvgIcon, { SvgIconProps } from '@material-ui/core/SvgIcon';
import {
fade,
alpha,
makeStyles,
withStyles,
Theme,
Expand Down Expand Up @@ -74,7 +74,7 @@ const StyledTreeItem = withStyles((theme: Theme) =>
group: {
marginLeft: 15,
paddingLeft: 18,
borderLeft: `1px dashed ${fade(theme.palette.text.primary, 0.4)}`,
borderLeft: `1px dashed ${alpha(theme.palette.text.primary, 0.4)}`,
},
}),
)((props: TreeItemProps) => (
Expand Down
14 changes: 14 additions & 0 deletions docs/src/pages/guides/migration-v4/migration-v4.md
Expand Up @@ -196,6 +196,20 @@ const theme = createMuiTheme({
});
```

### Styles

- Renamed `fade` to `alpha` to better describe the it's functionality.

```diff
- import { fade } from '@material-ui/core/styles';
+ import { alpha } from '@material-ui/core/styles';

const classes = makeStyles(theme => ({
- backgroundColor: fade(theme.palette.primary.main, theme.palette.action.selectedOpacity),
+ backgroundColor: alpha(theme.palette.primary.main, theme.palette.action.selectedOpacity),
}));
```

### Alert

- Move the component from the lab to the core. The component is now stable.
Expand Down