Skip to content

Commit 4eea58d

Browse files
committed
fix(clear-button,styles): style updates from latest release
1 parent 352ec80 commit 4eea58d

File tree

5 files changed

+76
-25
lines changed

5 files changed

+76
-25
lines changed

.changeset/hot-cups-report.md

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'@spectrum-web-components/clear-button': patch
3+
'@spectrum-web-components/styles': patch
4+
---
5+
6+
More details forthcoming

packages/button/src/ClearButton.ts

+8-1
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,16 @@ export class ClearButton extends SizedMixin(StyledButton, {
6666

6767
/**
6868
* The visual variant to apply to this button.
69+
* @deprecated Use `static-color='white'` instead.
6970
*/
7071
@property({ reflect: true })
71-
public variant: 'overBackground' | '' = '';
72+
public variant: 'overBackground' | undefined;
73+
74+
/**
75+
* The visual variant to apply to this button.
76+
*/
77+
@property({ reflect: true })
78+
public staticColor: 'white' | undefined;
7279

7380
protected override get buttonContent(): TemplateResult[] {
7481
return [crossIcon[this.size]()];

packages/clear-button/src/clear-button-overrides.css

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ governing permissions and limitations under the License.
2626
);
2727
}
2828

29-
:host .spectrum-ClearButton--staticWhite {
29+
:host([static-color='white']) {
3030
--spectrum-clear-button-background-color-hover: var(
3131
--system-clear-button-static-white-background-color-hover
3232
);

packages/clear-button/src/spectrum-clear-button.css

+6-7
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,14 @@ governing permissions and limitations under the License.
4444
--spectrum-clear-button-width: var(--spectrum-component-height-300);
4545
}
4646

47-
:host .spectrum-ClearButton--quiet {
47+
:host([quiet]) {
4848
--mod-clear-button-background-color: transparent;
4949
--mod-clear-button-background-color-hover: transparent;
5050
--mod-clear-button-background-color-down: transparent;
5151
--mod-clear-button-background-color-key-focus: transparent;
5252
}
5353

54-
:host .spectrum-ClearButton--staticWhite {
54+
:host([static-color='white']) {
5555
--mod-clear-button-icon-color: var(--spectrum-white);
5656
--mod-clear-button-icon-color-hover: var(--spectrum-white);
5757
--mod-clear-button-icon-color-down: var(--spectrum-white);
@@ -60,7 +60,6 @@ governing permissions and limitations under the License.
6060
--mod-clear-button-background-color: transparent;
6161
}
6262

63-
:host([disabled]),
6463
:host([disabled]) {
6564
--mod-clear-button-icon-color: var(--mod-clear-button-icon-color-disabled, var(--spectrum-disabled-content-color));
6665
--mod-clear-button-icon-color-hover: var(--spectrum-disabled-content-color);
@@ -78,11 +77,11 @@ governing permissions and limitations under the License.
7877
}
7978

8079
@media (hover: hover) {
81-
:host:not(:disabled):hover {
80+
:host(:hover):not(:disabled) {
8281
color: var(--highcontrast-clear-button-icon-color-hover, var(--mod-clear-button-icon-color-hover, var(--spectrum-clear-button-icon-color-hover)));
8382
}
8483

85-
:host:not(:disabled):hover .fill {
84+
:host(:hover):not(:disabled) .fill {
8685
background-color: var(--mod-clear-button-background-color-hover, var(--spectrum-clear-button-background-color-hover));
8786
}
8887
}
@@ -105,7 +104,7 @@ governing permissions and limitations under the License.
105104
background-color: var(--mod-clear-button-background-color-key-focus, var(--spectrum-clear-button-background-color-key-focus));
106105
}
107106

108-
.spectrum-ClearButton-icon {
107+
.icon {
109108
color: inherit;
110109
}
111110

@@ -120,7 +119,7 @@ governing permissions and limitations under the License.
120119
}
121120

122121
:host([variant='overBackground']:focus-visible),
123-
.spectrum-ClearButton--staticWhite:focus-visible {
122+
:host([static-color='white']:focus-visible) {
124123
outline: none;
125124
}
126125

packages/clear-button/src/spectrum-config.js

+55-16
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,20 @@ OF ANY KIND, either express or implied. See the License for the specific languag
1111
governing permissions and limitations under the License.
1212
*/
1313

14-
import { converterFor } from '../../../tasks/process-spectrum-utils.js';
14+
import {
15+
builder,
16+
converterFor,
17+
} from '../../../tasks/process-spectrum-utils.js';
1518

1619
const converter = converterFor('spectrum-ClearButton');
1720

21+
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
22+
const notDisabled = (type = 'pseudoClass') => ({
23+
type: 'pseudo-class',
24+
kind: 'not',
25+
selectors: builder[type]?.('disabled'),
26+
});
27+
1828
/**
1929
* @type { import('../../../tasks/spectrum-css-converter').SpectrumCSSConverter }
2030
*/
@@ -24,13 +34,15 @@ const config = {
2434
inPackage: '@spectrum-css/clearbutton',
2535
outPackage: 'clear-button',
2636
fileName: 'clear-button',
37+
excludeByComponents: [
38+
// is-disabled is a duplicate of the :disabled pseudo-class
39+
builder.class('is-disabled'),
40+
],
2741
components: [
2842
converter.classToHost(),
43+
converter.classToAttribute('spectrum-ClearButton--quiet'),
2944
{
30-
find: {
31-
type: 'pseudo-class',
32-
kind: 'active',
33-
},
45+
find: builder.pseudoClass('active'),
3446
replace: {
3547
type: 'pseudo-class',
3648
kind: 'is',
@@ -52,14 +64,12 @@ const config = {
5264
hoist: true,
5365
},
5466
converter.pseudoToAttribute('disabled', 'disabled'),
55-
converter.classToAttribute('is-disabled', 'disabled'),
5667
...converter.enumerateAttributes(
5768
[
58-
['spectrum-ClearButton--cta'],
59-
['spectrum-ClearButton--primary'],
60-
['spectrum-ClearButton--secondary'],
61-
['spectrum-ClearButton--overBackground'],
62-
['spectrum-ClearButton--warning', 'negative'],
69+
[
70+
'spectrum-ClearButton--overBackground',
71+
'overBackground',
72+
],
6373
],
6474
'variant'
6575
),
@@ -75,12 +85,41 @@ const config = {
7585
),
7686
converter.classToClass('spectrum-Icon', 'icon'),
7787
converter.classToClass('spectrum-ClearButton-fill'),
78-
],
79-
excludeByComponents: [
88+
converter.classToClass('spectrum-ClearButton-icon'),
89+
...converter.enumerateAttributes(
90+
[['spectrum-ClearButton--staticWhite', 'white']],
91+
'static-color'
92+
),
93+
{
94+
find: builder.pseudoClass('hover'),
95+
replace: builder.pseudoClass('hover'),
96+
hoist: true,
97+
},
8098
{
81-
type: 'pseudo-element',
82-
kind: 'custom',
83-
name: '-moz-focus-inner',
99+
find: notDisabled(),
100+
replace: notDisabled('attribute'),
101+
hoist: true,
102+
},
103+
{
104+
find: [notDisabled(), builder.pseudoClass('focus-visible')],
105+
replace: [
106+
builder.pseudoClass('focus-visible'),
107+
notDisabled('attribute'),
108+
],
109+
hoist: true,
110+
},
111+
{
112+
find: [notDisabled(), builder.pseudoClass('focus-within')],
113+
replace: [
114+
builder.attribute('focus-within'),
115+
notDisabled('attribute'),
116+
],
117+
hoist: true,
118+
},
119+
{
120+
find: notDisabled(),
121+
replace: notDisabled('attribute'),
122+
hoist: true,
84123
},
85124
],
86125
},

0 commit comments

Comments
 (0)