Skip to content

Commit

Permalink
[List] Improve hover/select/focus UI display (#21930)
Browse files Browse the repository at this point in the history
  • Loading branch information
joshwooding authored Aug 3, 2020
1 parent 914f063 commit 08c4736
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions packages/material-ui/src/ListItem/ListItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import PropTypes from 'prop-types';
import clsx from 'clsx';
import { chainPropTypes, elementTypeAcceptingRef } from '@material-ui/utils';
import withStyles from '../styles/withStyles';
import { fade } from '../styles/colorManipulator';
import ButtonBase from '../ButtonBase';
import isMuiElement from '../utils/isMuiElement';
import useForkRef from '../utils/useForkRef';
Expand All @@ -22,13 +23,19 @@ export const styles = (theme) => ({
paddingTop: 8,
paddingBottom: 8,
'&$focusVisible': {
backgroundColor: theme.palette.action.selected,
backgroundColor: theme.palette.action.focus,
},
'&$selected, &$selected:hover': {
backgroundColor: theme.palette.action.selected,
'&$selected': {
backgroundColor: fade(theme.palette.primary.main, theme.palette.action.selectedOpacity),
'&$focusVisible': {
backgroundColor: fade(
theme.palette.primary.main,
theme.palette.action.selectedOpacity + theme.palette.action.focusOpacity,
),
},
},
'&$disabled': {
opacity: 0.5,
opacity: theme.palette.action.disabledOpacity,
},
},
/* Styles applied to the `container` element if `children` includes `ListItemSecondaryAction`. */
Expand Down Expand Up @@ -71,6 +78,16 @@ export const styles = (theme) => ({
backgroundColor: 'transparent',
},
},
'&$selected:hover': {
backgroundColor: fade(
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),
},
},
},
/* Styles applied to the `component` element if `children` includes `ListItemSecondaryAction`. */
secondaryAction: {
Expand Down

0 comments on commit 08c4736

Please sign in to comment.