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(button -> negative): corrects interior label background color to align with parent #3078

Merged
merged 7 commits into from
Sep 17, 2024
5 changes: 5 additions & 0 deletions .changeset/little-cows-hang.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@spectrum-css/button": minor
---

Includes fixes and updates to the colors used in forced-colors / high contrast mode. In Windows high contrast, a different background was showing behind the label text, as a result of extra text readability backplates being rendered. `forced-color-adjust: none` is now applied to the child label element to fix this. The appropriate `ButtonFace`/`ButtonText` system colors are also now defined instead of relying on the default. The existing use of `Highlight` is now paired with `HighlightText` to ensure contrast by using a matching foreground/background pair.
34 changes: 26 additions & 8 deletions components/button/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -306,11 +306,30 @@ a.spectrum-Button {
/* Windows High Contrast Mode */
@media (forced-colors: active) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While we're cleaning up these high contrast styles, could you bring over some of the changes I made in the spectrum 2 migration here? The use of the Highlight background should be paired with HighlightText: 597d33f

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me know if this lines up with what you're expecting 853ddac#diff-97b5a7e747486aca74b3076354c28a00ef69dab3c91dc0806d926078198571a2R335

Thanks for taking a look! 🙂

Copy link
Collaborator

@jawinn jawinn Sep 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Could you keep the &.spectrum-Button--accent.spectrum-Button--fill selector the same for now? Removing the fill class hasn't been done yet in S1, so keeping that the same should avoid needing changes on the SWC side.
Also, really minor but it looks like the indentation needs an update there.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep! Just reverted that.

.spectrum-Button {
--highcontrast-button-content-color-default: ButtonText;
--highcontrast-button-content-color-hover: ButtonText;
--highcontrast-button-content-color-focus: ButtonText;
--highcontrast-button-content-color-down: ButtonText;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In addition, I think it would be a good idea to be explicit about setting the matching background color too. Right now we're relying on the default.

--highcontrast-button-background-color-default: ButtonFace;
--highcontrast-button-background-color-hover: ButtonFace;
--highcontrast-button-background-color-down: ButtonFace;
--highcontrast-button-background-color-focus: ButtonFace;
--highcontrast-button-background-color-disabled: ButtonFace;

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

--highcontrast-button-border-color-default: ButtonBorder;
--highcontrast-button-border-color-hover: ButtonBorder;
--highcontrast-button-border-color-focus: ButtonBorder;
--highcontrast-button-border-color-down: ButtonBorder;
--highcontrast-button-background-color-default: ButtonFace;
--highcontrast-button-background-color-hover: ButtonFace;
--highcontrast-button-background-color-down: ButtonFace;
--highcontrast-button-background-color-focus: ButtonFace;
--highcontrast-button-background-color-disabled: ButtonFace;
--highcontrast-button-content-color-disabled: GrayText;
--highcontrast-button-border-color-disabled: GrayText;

--mod-progress-circle-track-border-color: ButtonText;
--mod-progress-circle-track-border-color-over-background: ButtonText;
--mod-progress-circle-thickness: var(--spectrum-progress-circle-thickness-medium);
--mod-button-animation-duration: 0s;

.spectrum-Button-label {
forced-color-adjust: none;
}

&:focus-visible {
&::after {
Expand All @@ -322,18 +341,17 @@ a.spectrum-Button {
&.spectrum-Button--accent.spectrum-Button--fill {
--highcontrast-button-background-color-default: ButtonText;
--highcontrast-button-content-color-default: ButtonFace;
--highcontrast-button-content-color-hover: HighlightText;
--highcontrast-button-content-color-down: HighlightText;
--highcontrast-button-content-color-focus: HighlightText;
--highcontrast-button-background-color-disabled: ButtonFace;

--highcontrast-button-background-color-hover: Highlight;
--highcontrast-button-background-color-down: Highlight;
--highcontrast-button-background-color-focus: Highlight;
--highcontrast-button-content-color-hover: ButtonFace;
--highcontrast-button-content-color-down: ButtonFace;
--highcontrast-button-content-color-focus: ButtonFace;

.spectrum-Button-label {
forced-color-adjust: none;
}
--highcontrast-button-border-color-default: ButtonText;
--highcontrast-button-border-color-hover: Highlight;
--highcontrast-button-border-color-focus: Highlight;
--highcontrast-button-border-color-down: Highlight;
cdransf marked this conversation as resolved.
Show resolved Hide resolved
}
}
}
1 change: 0 additions & 1 deletion components/button/metadata/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
".spectrum-Button.is-selected.spectrum-Button--emphasized",
".spectrum-Button.spectrum-Button--accent",
".spectrum-Button.spectrum-Button--accent.spectrum-Button--fill",
".spectrum-Button.spectrum-Button--accent.spectrum-Button--fill .spectrum-Button-label",
".spectrum-Button.spectrum-Button--accent.spectrum-Button--outline",
".spectrum-Button.spectrum-Button--iconOnly",
".spectrum-Button.spectrum-Button--iconOnly .spectrum-Icon",
Expand Down
Loading