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

fix: High contrast mode hover style icon fixes in react-button components #28156

Merged
merged 7 commits into from
Jul 20, 2023
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "fix: high contrast mode hover style icon fixes",
"packageName": "@fluentui/react-button",
"email": "[email protected]",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,23 @@ const useRootStyles = makeStyles({
color: tokens.colorNeutralForeground2BrandPressed,
},
},

'@media (forced-colors: active)': {
':hover': {
color: 'Canvas',

[`& .${buttonClassNames.icon}`]: {
color: 'Canvas',
},
},
':hover:active': {
color: 'Canvas',

[`& .${buttonClassNames.icon}`]: {
color: 'Canvas',
},
},
},
},
transparent: {
backgroundColor: tokens.colorTransparentBackground,
Expand All @@ -225,6 +242,19 @@ const useRootStyles = makeStyles({
...shorthands.borderColor('transparent'),
color: tokens.colorNeutralForeground2BrandPressed,
},

'@media (forced-colors: active)': {
':hover': {
backgroundColor: tokens.colorTransparentBackgroundHover,
...shorthands.borderColor('transparent'),
color: 'Highlight',
},
':hover:active': {
backgroundColor: tokens.colorTransparentBackgroundHover,
...shorthands.borderColor('transparent'),
color: 'Highlight',
},
smhigley marked this conversation as resolved.
Show resolved Hide resolved
},
},

// Shape variations
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,19 @@ const useRootStyles = makeStyles({
color: tokens.colorNeutralForeground2Pressed,
},
},

'@media (forced-colors: active)': {
':hover': {
[`& .${compoundButtonClassNames.secondaryContent}`]: {
color: 'Canvas',
},
},
':hover:active': {
[`& .${compoundButtonClassNames.secondaryContent}`]: {
color: 'Canvas',
},
},
},
},
transparent: {
[`& .${compoundButtonClassNames.secondaryContent}`]: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,14 @@ const useIconExpandedStyles = makeStyles({
transparent: {
color: tokens.colorNeutralForeground2BrandSelected,
},
highContrast: {
// High contrast styles
'@media (forced-colors: active)': {
':hover': {
color: 'Canvas',
},
},
},
});

const useMenuIconStyles = makeStyles({
Expand Down Expand Up @@ -110,7 +118,7 @@ export const useMenuButtonStyles_unstable = (state: MenuButtonState): MenuButton
if (state.icon) {
state.icon.className = mergeClasses(
menuButtonClassNames.icon,
state.root['aria-expanded'] && iconExpandedStyles[state.appearance],
state.root['aria-expanded'] && iconExpandedStyles[state.appearance] && iconExpandedStyles.highContrast,
state.icon.className,
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,12 @@ const useIconCheckedStyles = makeStyles({
subtleOrTransparent: {
color: tokens.colorNeutralForeground2BrandSelected,
},
// High contrast styles
highContrast: {
'@media (forced-colors: active)': {
forcedColorAdjust: 'auto',
},
},
});

const usePrimaryHighContrastStyles = makeStyles({
Expand Down Expand Up @@ -272,7 +278,9 @@ export const useToggleButtonStyles_unstable = (state: ToggleButtonState): Toggle
if (state.icon) {
state.icon.className = mergeClasses(
toggleButtonClassNames.icon,
(appearance === 'subtle' || appearance === 'transparent') && iconCheckedStyles.subtleOrTransparent,
(appearance === 'subtle' || appearance === 'transparent') &&
iconCheckedStyles.subtleOrTransparent &&
iconCheckedStyles.highContrast,
state.icon.className,
);
}
Expand Down