Skip to content

Commit 62d8aaa

Browse files
authored
chore(web-components): replace state partials with state function (#33037)
1 parent a126ed1 commit 62d8aaa

12 files changed

+692
-287
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "prerelease",
3+
"comment": "replace state partials with stateSelector function",
4+
"packageName": "@fluentui/web-components",
5+
"email": "[email protected]",
6+
"dependentChangeType": "patch"
7+
}

packages/web-components/src/avatar/avatar.styles.ts

+64-31
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,38 @@
11
import { css } from '@microsoft/fast-element';
22
import { display } from '../utils/index.js';
3+
import {
4+
anchorState,
5+
beigeState,
6+
blueState,
7+
brandState,
8+
brassState,
9+
brownState,
10+
cornflowerState,
11+
cranberryState,
12+
darkGreenState,
13+
darkRedState,
14+
forestState,
15+
goldState,
16+
grapeState,
17+
lavenderState,
18+
lightTealState,
19+
lilacState,
20+
magentaState,
21+
marigoldState,
22+
minkState,
23+
navyState,
24+
peachState,
25+
pinkState,
26+
platinumState,
27+
plumState,
28+
pumpkinState,
29+
purpleState,
30+
redState,
31+
royalBlueState,
32+
seafoamState,
33+
steelState,
34+
tealState,
35+
} from '../styles/states/index.js';
336
import {
437
borderRadiusCircular,
538
borderRadiusLarge,
@@ -322,157 +355,157 @@ export const styles = css`
322355
border-radius: ${borderRadiusXLarge};
323356
}
324357
325-
:host(:is([state--brand], :state(brand))) {
358+
:host(${brandState}) {
326359
color: ${colorNeutralForegroundStaticInverted};
327360
background-color: ${colorBrandBackgroundStatic};
328361
}
329362
330-
:host(:is([state--dark-red], :state(dark-red))) {
363+
:host(${darkRedState}) {
331364
color: ${colorPaletteDarkRedForeground2};
332365
background-color: ${colorPaletteDarkRedBackground2};
333366
}
334367
335-
:host(:is([state--cranberry], :state(cranberry))) {
368+
:host(${cranberryState}) {
336369
color: ${colorPaletteCranberryForeground2};
337370
background-color: ${colorPaletteCranberryBackground2};
338371
}
339372
340-
:host(:is([state--red], :state(red))) {
373+
:host(${redState}) {
341374
color: ${colorPaletteRedForeground2};
342375
background-color: ${colorPaletteRedBackground2};
343376
}
344377
345-
:host(:is([state--pumpkin], :state(pumpkin))) {
378+
:host(${pumpkinState}) {
346379
color: ${colorPalettePumpkinForeground2};
347380
background-color: ${colorPalettePumpkinBackground2};
348381
}
349382
350-
:host(:is([state--peach], :state(peach))) {
383+
:host(${peachState}) {
351384
color: ${colorPalettePeachForeground2};
352385
background-color: ${colorPalettePeachBackground2};
353386
}
354387
355-
:host(:is([state--marigold], :state(marigold))) {
388+
:host(${marigoldState}) {
356389
color: ${colorPaletteMarigoldForeground2};
357390
background-color: ${colorPaletteMarigoldBackground2};
358391
}
359392
360-
:host(:is([state--gold], :state(gold))) {
393+
:host(${goldState}) {
361394
color: ${colorPaletteGoldForeground2};
362395
background-color: ${colorPaletteGoldBackground2};
363396
}
364397
365-
:host(:is([state--brass], :state(brass))) {
398+
:host(${brassState}) {
366399
color: ${colorPaletteBrassForeground2};
367400
background-color: ${colorPaletteBrassBackground2};
368401
}
369402
370-
:host(:is([state--brown], :state(brown))) {
403+
:host(${brownState}) {
371404
color: ${colorPaletteBrownForeground2};
372405
background-color: ${colorPaletteBrownBackground2};
373406
}
374407
375-
:host(:is([state--forest], :state(forest))) {
408+
:host(${forestState}) {
376409
color: ${colorPaletteForestForeground2};
377410
background-color: ${colorPaletteForestBackground2};
378411
}
379412
380-
:host(:is([state--seafoam], :state(seafoam))) {
413+
:host(${seafoamState}) {
381414
color: ${colorPaletteSeafoamForeground2};
382415
background-color: ${colorPaletteSeafoamBackground2};
383416
}
384417
385-
:host(:is([state--dark-green], :state(dark-green))) {
418+
:host(${darkGreenState}) {
386419
color: ${colorPaletteDarkGreenForeground2};
387420
background-color: ${colorPaletteDarkGreenBackground2};
388421
}
389422
390-
:host(:is([state--light-teal], :state(light-teal))) {
423+
:host(${lightTealState}) {
391424
color: ${colorPaletteLightTealForeground2};
392425
background-color: ${colorPaletteLightTealBackground2};
393426
}
394427
395-
:host(:is([state--teal], :state(teal))) {
428+
:host(${tealState}) {
396429
color: ${colorPaletteTealForeground2};
397430
background-color: ${colorPaletteTealBackground2};
398431
}
399432
400-
:host(:is([state--steel], :state(steel))) {
433+
:host(${steelState}) {
401434
color: ${colorPaletteSteelForeground2};
402435
background-color: ${colorPaletteSteelBackground2};
403436
}
404437
405-
:host(:is([state--blue], :state(blue))) {
438+
:host(${blueState}) {
406439
color: ${colorPaletteBlueForeground2};
407440
background-color: ${colorPaletteBlueBackground2};
408441
}
409442
410-
:host(:is([state--royal-blue], :state(royal-blue))) {
443+
:host(${royalBlueState}) {
411444
color: ${colorPaletteRoyalBlueForeground2};
412445
background-color: ${colorPaletteRoyalBlueBackground2};
413446
}
414447
415-
:host(:is([state--cornflower], :state(cornflower))) {
448+
:host(${cornflowerState}) {
416449
color: ${colorPaletteCornflowerForeground2};
417450
background-color: ${colorPaletteCornflowerBackground2};
418451
}
419452
420-
:host(:is([state--navy], :state(navy))) {
453+
:host(${navyState}) {
421454
color: ${colorPaletteNavyForeground2};
422455
background-color: ${colorPaletteNavyBackground2};
423456
}
424457
425-
:host(:is([state--lavender], :state(lavender))) {
458+
:host(${lavenderState}) {
426459
color: ${colorPaletteLavenderForeground2};
427460
background-color: ${colorPaletteLavenderBackground2};
428461
}
429462
430-
:host(:is([state--purple], :state(purple))) {
463+
:host(${purpleState}) {
431464
color: ${colorPalettePurpleForeground2};
432465
background-color: ${colorPalettePurpleBackground2};
433466
}
434467
435-
:host(:is([state--grape], :state(grape))) {
468+
:host(${grapeState}) {
436469
color: ${colorPaletteGrapeForeground2};
437470
background-color: ${colorPaletteGrapeBackground2};
438471
}
439472
440-
:host(:is([state--lilac], :state(lilac))) {
473+
:host(${lilacState}) {
441474
color: ${colorPaletteLilacForeground2};
442475
background-color: ${colorPaletteLilacBackground2};
443476
}
444477
445-
:host(:is([state--pink], :state(pink))) {
478+
:host(${pinkState}) {
446479
color: ${colorPalettePinkForeground2};
447480
background-color: ${colorPalettePinkBackground2};
448481
}
449482
450-
:host(:is([state--magenta], :state(magenta))) {
483+
:host(${magentaState}) {
451484
color: ${colorPaletteMagentaForeground2};
452485
background-color: ${colorPaletteMagentaBackground2};
453486
}
454487
455-
:host(:is([state--plum], :state(plum))) {
488+
:host(${plumState}) {
456489
color: ${colorPalettePlumForeground2};
457490
background-color: ${colorPalettePlumBackground2};
458491
}
459492
460-
:host(:is([state--beige], :state(beige))) {
493+
:host(${beigeState}) {
461494
color: ${colorPaletteBeigeForeground2};
462495
background-color: ${colorPaletteBeigeBackground2};
463496
}
464497
465-
:host(:is([state--mink], :state(mink))) {
498+
:host(${minkState}) {
466499
color: ${colorPaletteMinkForeground2};
467500
background-color: ${colorPaletteMinkBackground2};
468501
}
469502
470-
:host(:is([state--platinum], :state(platinum))) {
503+
:host(${platinumState}) {
471504
color: ${colorPalettePlatinumForeground2};
472505
background-color: ${colorPalettePlatinumBackground2};
473506
}
474507
475-
:host(:is([state--anchor], :state(anchor))) {
508+
:host(${anchorState}) {
476509
color: ${colorPaletteAnchorForeground2};
477510
background-color: ${colorPaletteAnchorBackground2};
478511
}

packages/web-components/src/checkbox/checkbox.styles.ts

+1-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { css } from '@microsoft/fast-element';
2-
import { checkedState, circularState, largeState } from '../styles/states/index.js';
2+
import { checkedState, circularState, indeterminateState, largeState } from '../styles/states/index.js';
33
import {
44
borderRadiusCircular,
55
borderRadiusMedium,
@@ -25,12 +25,6 @@ import {
2525
import { forcedColorsStylesheetBehavior } from '../utils/behaviors/match-media-stylesheet-behavior.js';
2626
import { display } from '../utils/display.js';
2727

28-
/**
29-
* Selector for the `indeterminate` state.
30-
* @public
31-
*/
32-
const indeterminateState = css.partial`:is([state--indeterminate], :state(indeterminate))`;
33-
3428
/** Checkbox styles
3529
*
3630
* @public

packages/web-components/src/counter-badge/counter-badge.styles.ts

+1-7
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,7 @@
11
import { css } from '@microsoft/fast-element';
22
import { badgeBaseStyles, badgeFilledStyles, badgeGhostStyles, badgeSizeStyles } from '../styles/index.js';
33
import { borderRadiusMedium, borderRadiusSmall } from '../theme/design-tokens.js';
4-
import { extraSmallState, roundedState, smallState, tinyState } from '../styles/states/index.js';
5-
6-
/**
7-
* Selector for the `dot` state.
8-
* @public
9-
*/
10-
const dotState = css.partial`:is([state--dot], :state(dot))`;
4+
import { dotState, extraSmallState, roundedState, smallState, tinyState } from '../styles/states/index.js';
115

126
/** Badge styles
137
* @public

packages/web-components/src/field/field.styles.ts

+16-79
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,20 @@
11
import { css } from '@microsoft/fast-element';
2-
import { disabledState } from '../styles/states/index.js';
2+
import {
3+
badInputState,
4+
customErrorState,
5+
disabledState,
6+
focusVisibleState,
7+
hasMessageState,
8+
patternMismatchState,
9+
rangeOverflowState,
10+
rangeUnderflowState,
11+
stepMismatchState,
12+
tooLongState,
13+
tooShortState,
14+
typeMismatchState,
15+
validState,
16+
valueMissingState,
17+
} from '../styles/states/index.js';
318
import {
419
borderRadiusMedium,
520
colorNeutralForeground1,
@@ -23,84 +38,6 @@ import {
2338
import { display } from '../utils/display.js';
2439
import { ValidationFlags } from './field.options.js';
2540

26-
/**
27-
* Selector for the `focus-visible` state.
28-
* @public
29-
*/
30-
const focusVisibleState = css.partial`:is([state--focus-visible], :state(focus-visible))`;
31-
32-
/**
33-
* Selector for the `bad-input` state.
34-
* @public
35-
*/
36-
const badInputState = css.partial`:is([state--${ValidationFlags.badInput}], :state(${ValidationFlags.badInput}))`;
37-
38-
/**
39-
* Selector for the `custom-error` state.
40-
* @public
41-
*/
42-
const customErrorState = css.partial`:is([state--${ValidationFlags.customError}], :state(${ValidationFlags.customError}))`;
43-
44-
/**
45-
* Selector for the `pattern-mismatch` state.
46-
* @public
47-
*/
48-
const patternMismatchState = css.partial`:is([state--${ValidationFlags.patternMismatch}], :state(${ValidationFlags.patternMismatch}))`;
49-
50-
/**
51-
* Selector for the `range-overflow` state.
52-
* @public
53-
*/
54-
const rangeOverflowState = css.partial`:is([state--${ValidationFlags.rangeOverflow}], :state(${ValidationFlags.rangeOverflow}))`;
55-
56-
/**
57-
* Selector for the `range-underflow` state.
58-
* @public
59-
*/
60-
const rangeUnderflowState = css.partial`:is([state--${ValidationFlags.rangeUnderflow}], :state(${ValidationFlags.rangeUnderflow}))`;
61-
62-
/**
63-
* Selector for the `step-mismatch` state.
64-
* @public
65-
*/
66-
const stepMismatchState = css.partial`:is([state--${ValidationFlags.stepMismatch}], :state(${ValidationFlags.stepMismatch}))`;
67-
68-
/**
69-
* Selector for the `too-long` state.
70-
* @public
71-
*/
72-
const tooLongState = css.partial`:is([state--${ValidationFlags.tooLong}], :state(${ValidationFlags.tooLong}))`;
73-
74-
/**
75-
* Selector for the `too-short` state.
76-
* @public
77-
*/
78-
const tooShortState = css.partial`:is([state--${ValidationFlags.tooShort}], :state(${ValidationFlags.tooShort}))`;
79-
80-
/**
81-
* Selector for the `type-mismatch` state.
82-
* @public
83-
*/
84-
const typeMismatchState = css.partial`:is([state--${ValidationFlags.typeMismatch}], :state(${ValidationFlags.typeMismatch}))`;
85-
86-
/**
87-
* Selector for the `valid` state.
88-
* @public
89-
*/
90-
const validState = css.partial`:is([state-${ValidationFlags.valid}], :state(${ValidationFlags.valid}))`;
91-
92-
/**
93-
* Selector for the `value-missing` state.
94-
* @public
95-
*/
96-
const valueMissingState = css.partial`:is([state--${ValidationFlags.valueMissing}], :state(${ValidationFlags.valueMissing}))`;
97-
98-
/**
99-
* Selector for the `has-message` state.
100-
* @public
101-
*/
102-
const hasMessageState = css.partial`:is([state--has-message], :state(has-message))`;
103-
10441
/**
10542
* The styles for the {@link Field} component.
10643
*

0 commit comments

Comments
 (0)