Skip to content

Commit

Permalink
[Table] Use primary cover over secondary for selected state (#25182)
Browse files Browse the repository at this point in the history
  • Loading branch information
beaudry authored Mar 4, 2021
1 parent 7cd99f4 commit 7855f2b
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 23 deletions.
20 changes: 9 additions & 11 deletions docs/src/pages/components/tables/EnhancedTable.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as React from 'react';
import PropTypes from 'prop-types';
import clsx from 'clsx';
import { lighten, makeStyles } from '@material-ui/core/styles';
import { alpha, makeStyles } from '@material-ui/core/styles';
import Table from '@material-ui/core/Table';
import TableBody from '@material-ui/core/TableBody';
import TableCell from '@material-ui/core/TableCell';
Expand Down Expand Up @@ -141,6 +141,7 @@ function EnhancedTableHead(props) {
<TableRow>
<TableCell padding="checkbox">
<Checkbox
color="primary"
indeterminate={numSelected > 0 && numSelected < rowCount}
checked={rowCount > 0 && numSelected === rowCount}
onChange={onSelectAllClick}
Expand Down Expand Up @@ -190,16 +191,12 @@ const useToolbarStyles = makeStyles((theme) => ({
paddingLeft: theme.spacing(2),
paddingRight: theme.spacing(1),
},
highlight:
theme.palette.mode === 'light'
? {
color: theme.palette.secondary.main,
backgroundColor: lighten(theme.palette.secondary.light, 0.85),
}
: {
color: theme.palette.text.primary,
backgroundColor: theme.palette.secondary.dark,
},
highlight: {
backgroundColor: alpha(
theme.palette.primary.main,
theme.palette.action.activatedOpacity,
),
},
title: {
flex: '1 1 100%',
},
Expand Down Expand Up @@ -357,6 +354,7 @@ export default function EnhancedTable() {
>
<TableCell padding="checkbox">
<Checkbox
color="primary"
checked={isItemSelected}
inputProps={{
'aria-labelledby': labelId,
Expand Down
20 changes: 9 additions & 11 deletions docs/src/pages/components/tables/EnhancedTable.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from 'react';
import clsx from 'clsx';
import { createStyles, lighten, makeStyles, Theme } from '@material-ui/core/styles';
import { createStyles, alpha, makeStyles, Theme } from '@material-ui/core/styles';
import Table from '@material-ui/core/Table';
import TableBody from '@material-ui/core/TableBody';
import TableCell from '@material-ui/core/TableCell';
Expand Down Expand Up @@ -184,6 +184,7 @@ function EnhancedTableHead(props: EnhancedTableProps) {
<TableRow>
<TableCell padding="checkbox">
<Checkbox
color="primary"
indeterminate={numSelected > 0 && numSelected < rowCount}
checked={rowCount > 0 && numSelected === rowCount}
onChange={onSelectAllClick}
Expand Down Expand Up @@ -224,16 +225,12 @@ const useToolbarStyles = makeStyles((theme: Theme) =>
paddingLeft: theme.spacing(2),
paddingRight: theme.spacing(1),
},
highlight:
theme.palette.mode === 'light'
? {
color: theme.palette.secondary.main,
backgroundColor: lighten(theme.palette.secondary.light, 0.85),
}
: {
color: theme.palette.text.primary,
backgroundColor: theme.palette.secondary.dark,
},
highlight: {
backgroundColor: alpha(
theme.palette.primary.main,
theme.palette.action.activatedOpacity,
),
},
title: {
flex: '1 1 100%',
},
Expand Down Expand Up @@ -394,6 +391,7 @@ export default function EnhancedTable() {
>
<TableCell padding="checkbox">
<Checkbox
color="primary"
checked={isItemSelected}
inputProps={{
'aria-labelledby': labelId,
Expand Down
2 changes: 1 addition & 1 deletion packages/material-ui/src/TableRow/TableRow.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const TableRowRoot = experimentalStyled(
backgroundColor: theme.palette.action.hover,
},
'&.Mui-selected, &.Mui-selected:hover': {
backgroundColor: alpha(theme.palette.secondary.main, theme.palette.action.selectedOpacity),
backgroundColor: alpha(theme.palette.primary.main, theme.palette.action.selectedOpacity),
},
}));

Expand Down

0 comments on commit 7855f2b

Please sign in to comment.