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

[List] Improve hover/select/focus UI display #21930

Merged
merged 2 commits into from
Aug 3, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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