Skip to content

Commit

Permalink
Merge pull request #1 from siriwatknp/disable-ripple2
Browse files Browse the repository at this point in the history
Use CSS variable
  • Loading branch information
sai6855 authored Sep 12, 2024
2 parents d04a8d4 + 02e1663 commit 9ea0b19
Showing 1 changed file with 8 additions and 16 deletions.
24 changes: 8 additions & 16 deletions packages/mui-material/src/IconButton/IconButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,11 @@ const IconButtonRoot = styled(ButtonBase, {
{
props: (props) => !props.disableRipple,
style: {
'--IconButton-hoverBg': theme.vars
? `rgba(${theme.vars.palette.action.activeChannel} / ${theme.vars.palette.action.hoverOpacity})`
: alpha(theme.palette.action.active, theme.palette.action.hoverOpacity),
'&:hover': {
backgroundColor: theme.vars
? `rgba(${theme.vars.palette.action.activeChannel} / ${theme.vars.palette.action.hoverOpacity})`
: alpha(theme.palette.action.active, theme.palette.action.hoverOpacity),
backgroundColor: 'var(--IconButton-hoverBg)',
// Reset on touch devices, it doesn't add specificity
'@media (hover: none)': {
backgroundColor: 'transparent',
Expand Down Expand Up @@ -113,20 +114,11 @@ const IconButtonRoot = styled(ButtonBase, {
...Object.entries(theme.palette)
.filter(createSimplePaletteValueFilter()) // check all the used fields in the style below
.map(([color]) => ({
props: (props) => props.color === color && !props.disableRipple,
props: { color },
style: {
'&:hover': {
backgroundColor: theme.vars
? `rgba(${(theme.vars || theme).palette[color].mainChannel} / ${theme.vars.palette.action.hoverOpacity})`
: alpha(
(theme.vars || theme).palette[color].main,
theme.palette.action.hoverOpacity,
),
// Reset on touch devices, it doesn't add specificity
'@media (hover: none)': {
backgroundColor: 'transparent',
},
},
'--IconButton-hoverBg': theme.vars
? `rgba(${(theme.vars || theme).palette[color].mainChannel} / ${theme.vars.palette.action.hoverOpacity})`
: alpha((theme.vars || theme).palette[color].main, theme.palette.action.hoverOpacity),
},
})),
{
Expand Down

0 comments on commit 9ea0b19

Please sign in to comment.