Skip to content

Commit 8697c37

Browse files
authored
fix(button): add explicit highcontrast variables for disabled color (#1985)
* fix(button): add explicit highcontrast variables for disabled color * refactor(button): use variables instead of css * fix(button): add back no forced color adjust for label * chore(button): test chromatic whcm * chore(button): testing out explicitly defining parameters for story
1 parent 56c7cfc commit 8697c37

File tree

2 files changed

+21
-14
lines changed

2 files changed

+21
-14
lines changed

components/button/index.css

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,9 @@ a.spectrum-Button {
239239
/* windows high contrast mode over-writes for accent variant */
240240
@media (forced-colors: active) {
241241
.spectrum-Button {
242+
--highcontrast-button-content-color-disabled: GrayText;
243+
--highcontrast-button-border-color-disabled: GrayText;
244+
242245
&:focus-ring {
243246
&:after {
244247
forced-color-adjust: none;
@@ -248,25 +251,21 @@ a.spectrum-Button {
248251

249252
&.spectrum-Button--accent {
250253
&.spectrum-Button--fill {
251-
background-color: ButtonText;
252-
color: ButtonFace;
254+
--highcontrast-button-background-color-default: ButtonText;
255+
--highcontrast-button-content-color-default: ButtonFace;
256+
--highcontrast-button-background-color-disabled: ButtonFace;
253257

254-
&:disabled,
255-
&.is-disabled {
256-
background-color: ButtonFace;
257-
color: GrayText;
258-
}
258+
--highcontrast-button-background-color-hover: Highlight;
259+
--highcontrast-button-background-color-down: Highlight;
260+
--highcontrast-button-background-color-focus: Highlight;
261+
--highcontrast-button-content-color-hover: ButtonFace;
262+
--highcontrast-button-content-color-down: ButtonFace;
263+
--highcontrast-button-content-color-focus: ButtonFace;
259264

260-
/* simplified for a lot of state for high contrast mode */
261-
&:active,
262-
&:hover,
263-
&:focus-ring,
264-
&.is-focused {
265-
background-color: Highlight;
266-
}
267265
.spectrum-Button-label {
268266
forced-color-adjust: none;
269267
}
268+
270269
}
271270
}
272271
}

components/button/stories/button.stories.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,3 +166,11 @@ Disabled.args = {
166166
isDisabled: true,
167167
iconName: "Actions",
168168
};
169+
170+
export const WithForcedColors = CustomButton.bind({});
171+
WithForcedColors.parameters = {
172+
chromatic: { forcedColors: "active" },
173+
};
174+
WithForcedColors.args = {
175+
iconName: "Actions",
176+
};

0 commit comments

Comments
 (0)