Skip to content

Commit db450d8

Browse files
authored
fix(clear button): align background color and hover state for disabled variant (#3258)
* chore(clear button): resolve conflict * chore(clear button): adds changeset * chore(clear button): remove declaration + unnecessary stylelint * chore(clear button): add .spectrum-ClearButton.is-disabled selector * chore(clear button): add .spectrum-ClearButton--staticWhite selectors * chore(clear button): update changelog
1 parent d8d0450 commit db450d8

File tree

3 files changed

+56
-18
lines changed

3 files changed

+56
-18
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
"@spectrum-css/clearbutton": minor
3+
---
4+
5+
Improves the visibility of the clear button disabled variant on static color backgrounds by more closely aligning styles with close button.
6+
7+
- Adds `.spectrum-ClearButton--staticWhite` to the mod declarations associated with `.spectrum-ClearButton--overBackground` in advance of the latter being deprecated. The same class has been added to the `:focus` declaration for `spectrum-ClearButton--overBackground`.
8+
- Adds `--spectrum-clear-button-icon-color-disabled: var(--spectrum-disabled-static-white-content-color);` custom property for `.spectrum-ClearButton--staticWhite`.
9+
- Enables `cursor: pointer` for `.spectrum-ClearButton` when it is not disabled.
10+
- Disables hover, active, focus and focus-within states for `:disabled` `.spectrum-ClearButton` elements.
11+
- Adds color styles for `:disabled` and `.is-disabled` `.spectrum-ClearButton` `:disabled` icons.

components/clearbutton/index.css

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@
4646
--mod-clear-button-background-color-key-focus: transparent;
4747
}
4848

49+
/* @deprecated .spectrum-ClearButton--overBackground */
50+
&.spectrum-ClearButton--staticWhite,
4951
&.spectrum-ClearButton--overBackground {
5052
--mod-clear-button-icon-color: var(--spectrum-white);
5153
--mod-clear-button-icon-color-hover: var(--spectrum-white);
@@ -65,13 +67,20 @@
6567
--mod-clear-button-icon-color-down: var(--spectrum-disabled-content-color);
6668
--mod-clear-button-background-color: var(--mod-clear-button-background-color-disabled, transparent);
6769
}
70+
71+
&.spectrum-ClearButton--staticWhite {
72+
--spectrum-clear-button-icon-color-disabled: var(--spectrum-disabled-static-white-content-color);
73+
}
6874
}
6975

7076
.spectrum-ClearButton {
7177
block-size: var(--mod-clear-button-height, var(--spectrum-clear-button-height));
7278
inline-size: var(--mod-clear-button-width, var(--spectrum-clear-button-width));
7379
border-radius: 100%;
74-
cursor: pointer;
80+
81+
&:not(:disabled) {
82+
cursor: pointer;
83+
}
7584

7685
background-color: var(--mod-clear-button-background-color, transparent);
7786
margin: 0;
@@ -86,24 +95,24 @@
8695
margin-inline: auto;
8796
}
8897

89-
&:hover {
98+
&:not(:disabled):hover {
9099
color: var(--highcontrast-clear-button-icon-color-hover, var(--mod-clear-button-icon-color-hover, var(--spectrum-clear-button-icon-color-hover)));
91100

92101
.spectrum-ClearButton-fill {
93102
background-color: var(--mod-clear-button-background-color-hover, var(--spectrum-clear-button-background-color-hover));
94103
}
95104
}
96105

97-
&:active {
106+
&:not(:disabled):active {
98107
color: var(--mod-clear-button-icon-color-down, var(--spectrum-clear-button-icon-color-down));
99108

100109
.spectrum-ClearButton-fill {
101110
background-color: var(--mod-clear-button-background-color-down, var(--spectrum-clear-button-background-color-down));
102111
}
103112
}
104113

105-
&:focus-visible,
106-
&:focus-within {
114+
&:not(:disabled):focus-visible,
115+
&:not(:disabled):focus-within {
107116
color: var(--mod-clear-button-icon-color-key-focus, var(--spectrum-clear-button-icon-color-key-focus));
108117

109118
.spectrum-ClearButton-fill {
@@ -112,6 +121,13 @@
112121
}
113122
}
114123

124+
.spectrum-ClearButton:disabled,
125+
.spectrum-ClearButton.is-disabled {
126+
.spectrum-ClearButton-icon {
127+
color: var( --highcontrast-clear-button-icon-color-disabled, var(--mod-clear-button-icon-color-disabled, var(--spectrum-clear-button-icon-color-disabled)));
128+
}
129+
}
130+
115131
.spectrum-ClearButton-fill {
116132
background-color: var(--mod-clear-button-background-color, var(--spectrum-clear-button-background-color));
117133

@@ -124,6 +140,8 @@
124140
justify-content: center;
125141
}
126142

143+
/* @deprecated .spectrum-ClearButton--overBackground */
144+
.spectrum-ClearButton--staticWhite,
127145
.spectrum-ClearButton--overBackground {
128146
&:focus-visible {
129147
outline: none;

components/clearbutton/metadata/metadata.json

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,34 @@
11
{
22
"sourceFile": "index.css",
33
"selectors": [
4-
".js-focus-within .spectrum-ClearButton[focus-within]",
5-
".js-focus-within .spectrum-ClearButton[focus-within] .spectrum-ClearButton-fill",
4+
".js-focus-within .spectrum-ClearButton:not(:disabled)[focus-within]",
5+
".js-focus-within .spectrum-ClearButton:not(:disabled)[focus-within] .spectrum-ClearButton-fill",
66
".spectrum-ClearButton",
77
".spectrum-ClearButton > .spectrum-Icon",
88
".spectrum-ClearButton--overBackground:focus-visible",
9+
".spectrum-ClearButton--staticWhite:focus-visible",
910
".spectrum-ClearButton-fill",
1011
".spectrum-ClearButton.is-disabled",
12+
".spectrum-ClearButton.is-disabled .spectrum-ClearButton-icon",
1113
".spectrum-ClearButton.spectrum-ClearButton--overBackground",
1214
".spectrum-ClearButton.spectrum-ClearButton--quiet",
1315
".spectrum-ClearButton.spectrum-ClearButton--sizeL",
1416
".spectrum-ClearButton.spectrum-ClearButton--sizeS",
1517
".spectrum-ClearButton.spectrum-ClearButton--sizeXL",
16-
".spectrum-ClearButton:active",
17-
".spectrum-ClearButton:active .spectrum-ClearButton-fill",
18+
".spectrum-ClearButton.spectrum-ClearButton--staticWhite",
1819
".spectrum-ClearButton:disabled",
19-
".spectrum-ClearButton:focus-visible",
20-
".spectrum-ClearButton:focus-visible .spectrum-ClearButton-fill",
21-
".spectrum-ClearButton:focus-within",
22-
".spectrum-ClearButton:focus-within .spectrum-ClearButton-fill",
23-
".spectrum-ClearButton:hover",
24-
".spectrum-ClearButton:hover .spectrum-ClearButton-fill",
20+
".spectrum-ClearButton:disabled .spectrum-ClearButton-icon",
2521
".spectrum-ClearButton:not(:disabled)",
26-
".spectrum-ClearButton[focus-within].js-focus-within",
27-
".spectrum-ClearButton[focus-within].js-focus-within .spectrum-ClearButton-fill"
22+
".spectrum-ClearButton:not(:disabled):active",
23+
".spectrum-ClearButton:not(:disabled):active .spectrum-ClearButton-fill",
24+
".spectrum-ClearButton:not(:disabled):focus-visible",
25+
".spectrum-ClearButton:not(:disabled):focus-visible .spectrum-ClearButton-fill",
26+
".spectrum-ClearButton:not(:disabled):focus-within",
27+
".spectrum-ClearButton:not(:disabled):focus-within .spectrum-ClearButton-fill",
28+
".spectrum-ClearButton:not(:disabled):hover",
29+
".spectrum-ClearButton:not(:disabled):hover .spectrum-ClearButton-fill",
30+
".spectrum-ClearButton:not(:disabled)[focus-within].js-focus-within",
31+
".spectrum-ClearButton:not(:disabled)[focus-within].js-focus-within .spectrum-ClearButton-fill"
2832
],
2933
"modifiers": [
3034
"--mod-clear-button-background-color",
@@ -48,6 +52,7 @@
4852
"--spectrum-clear-button-background-color-key-focus",
4953
"--spectrum-clear-button-height",
5054
"--spectrum-clear-button-icon-color",
55+
"--spectrum-clear-button-icon-color-disabled",
5156
"--spectrum-clear-button-icon-color-down",
5257
"--spectrum-clear-button-icon-color-hover",
5358
"--spectrum-clear-button-icon-color-key-focus",
@@ -60,6 +65,7 @@
6065
"--spectrum-component-height-300",
6166
"--spectrum-component-height-75",
6267
"--spectrum-disabled-content-color",
68+
"--spectrum-disabled-static-white-content-color",
6369
"--spectrum-gray-200",
6470
"--spectrum-gray-300",
6571
"--spectrum-gray-400",
@@ -79,5 +85,8 @@
7985
"--system-spectrum-clearbutton-spectrum-clear-button-background-color-key-focus"
8086
],
8187
"passthroughs": [],
82-
"high-contrast": ["--highcontrast-clear-button-icon-color-hover"]
88+
"high-contrast": [
89+
"--highcontrast-clear-button-icon-color-disabled",
90+
"--highcontrast-clear-button-icon-color-hover"
91+
]
8392
}

0 commit comments

Comments
 (0)