Skip to content

Commit f00737e

Browse files
chrisdholtCopilot
andauthored
fix(web-components): remove behaviors for forced-colors and match-media directives (#36092)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 0d337b9 commit f00737e

26 files changed

Lines changed: 103 additions & 330 deletions
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "patch",
3+
"comment": "fix: remove behaviors in favor of direct css inclusion",
4+
"packageName": "@fluentui/chart-web-components",
5+
"email": "13071055+chrisdholt@users.noreply.github.com",
6+
"dependentChangeType": "patch"
7+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "prerelease",
3+
"comment": "fix: remove behaviors in favor of direct css inclusion",
4+
"packageName": "@fluentui/web-components",
5+
"email": "13071055+chrisdholt@users.noreply.github.com",
6+
"dependentChangeType": "patch"
7+
}

packages/charts/chart-web-components/src/donut-chart/donut-chart.styles.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import {
99
colorStrokeFocus2,
1010
colorTransparentStroke,
1111
display,
12-
forcedColorsStylesheetBehavior,
1312
spacingHorizontalL,
1413
spacingHorizontalNone,
1514
spacingHorizontalS,
@@ -139,8 +138,8 @@ export const styles = css`
139138
.tooltip-content-y {
140139
${typographyTitle2Styles}
141140
}
142-
`.withBehaviors(
143-
forcedColorsStylesheetBehavior(css`
141+
142+
@media (forced-colors: active) {
144143
.text-inside-donut {
145144
fill: CanvasText;
146145
}
@@ -155,5 +154,5 @@ export const styles = css`
155154
forced-color-adjust: auto;
156155
color: CanvasText;
157156
}
158-
`),
159-
);
157+
}
158+
`;

packages/charts/chart-web-components/src/horizontal-bar-chart/horizontal-bar-chart.styles.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import {
55
colorNeutralForeground1,
66
colorNeutralStrokeAccessible,
77
display,
8-
forcedColorsStylesheetBehavior,
98
shadow4,
109
spacingHorizontalL,
1110
spacingHorizontalNone,
@@ -171,8 +170,8 @@ export const styles: ElementStyles = css`
171170
${typographyBody1StrongStyles}
172171
color: ${colorNeutralForeground1};
173172
}
174-
`.withBehaviors(
175-
forcedColorsStylesheetBehavior(css`
173+
174+
@media (forced-colors: active) {
176175
.legend-rect,
177176
.tooltip-line,
178177
.triangle {
@@ -186,5 +185,5 @@ export const styles: ElementStyles = css`
186185
.bar-label {
187186
fill: CanvasText !important;
188187
}
189-
`),
190-
);
188+
}
189+
`;

packages/web-components/docs/web-components.api.md

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ import { ElementStyles } from '@microsoft/fast-element';
1111
import { ElementViewTemplate } from '@microsoft/fast-element';
1212
import { FASTElement } from '@microsoft/fast-element';
1313
import { FASTElementDefinition } from '@microsoft/fast-element';
14-
import type { HostBehavior } from '@microsoft/fast-element';
15-
import type { HostController } from '@microsoft/fast-element';
1614
import { HTMLDirective } from '@microsoft/fast-element';
1715
import { Orientation } from '@microsoft/fast-web-utilities';
1816
import { SyntheticViewTemplate } from '@microsoft/fast-element';
@@ -2517,9 +2515,6 @@ export const curveEasyEaseMax = "var(--curveEasyEaseMax)";
25172515
// @public
25182516
export const curveLinear = "var(--curveLinear)";
25192517

2520-
// @public
2521-
export const darkModeStylesheetBehavior: (styles: ElementStyles) => MatchMediaStyleSheetBehavior;
2522-
25232518
// @public
25242519
export class Dialog extends FASTElement {
25252520
ariaDescribedby?: string;
@@ -2980,9 +2975,6 @@ export const fontWeightRegular = "var(--fontWeightRegular)";
29802975
// @public
29812976
export const fontWeightSemibold = "var(--fontWeightSemibold)";
29822977

2983-
// @public
2984-
export const forcedColorsStylesheetBehavior: (styles: ElementStyles) => MatchMediaStyleSheetBehavior;
2985-
29862978
// @public
29872979
export const getDirection: (rootNode: HTMLElement) => Direction;
29882980

@@ -3088,9 +3080,6 @@ export const LabelWeight: {
30883080
// @public
30893081
export type LabelWeight = ValuesOf<typeof LabelWeight>;
30903082

3091-
// @public
3092-
export const lightModeStylesheetBehavior: (styles: ElementStyles) => MatchMediaStyleSheetBehavior;
3093-
30943083
// @public
30953084
export const lineHeightBase100 = "var(--lineHeightBase100)";
30963085

@@ -3201,29 +3190,6 @@ export const ListboxTemplate: ElementViewTemplate<Listbox>;
32013190
// @public
32023191
export function listboxTemplate<T extends Listbox>(): ElementViewTemplate<T>;
32033192

3204-
// @public
3205-
export abstract class MatchMediaBehavior implements HostBehavior {
3206-
constructor(query: MediaQueryList);
3207-
connectedCallback(controller: HostController): void;
3208-
protected abstract constructListener(controller: HostController): MediaQueryListListener;
3209-
disconnectedCallback(controller: HostController): void;
3210-
readonly query: MediaQueryList;
3211-
}
3212-
3213-
// @public
3214-
export class MatchMediaStyleSheetBehavior extends MatchMediaBehavior {
3215-
constructor(query: MediaQueryList, styles: ElementStyles);
3216-
protected constructListener(controller: HostController): MediaQueryListListener;
3217-
readonly query: MediaQueryList;
3218-
// @internal
3219-
removedCallback(controller: HostController<any>): void;
3220-
readonly styles: ElementStyles;
3221-
static with(query: MediaQueryList): (styles: ElementStyles) => MatchMediaStyleSheetBehavior;
3222-
}
3223-
3224-
// @public
3225-
export type MediaQueryListListener = (this: MediaQueryList, ev?: MediaQueryListEvent) => void;
3226-
32273193
// @public
32283194
export class Menu extends FASTElement {
32293195
closeMenu: (event?: Event) => void;
Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { css } from '@microsoft/fast-element';
22
import { baseButtonStyles } from '../button/button.styles.js';
3-
import { forcedColorsStylesheetBehavior } from '../utils/index.js';
43

54
// Need to support icon hover styles
65
export const styles = css`
@@ -10,11 +9,11 @@ export const styles = css`
109
position: absolute;
1110
inset: 0;
1211
}
13-
`.withBehaviors(
14-
forcedColorsStylesheetBehavior(css`
12+
13+
@media (forced-colors: active) {
1514
:host {
1615
border-color: LinkText;
1716
color: LinkText;
1817
}
19-
`),
20-
);
18+
}
19+
`;

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

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { css } from '@microsoft/fast-element';
2-
import { forcedColorsStylesheetBehavior } from '../utils/index.js';
32
import {
43
badgeBaseStyles,
54
badgeFilledStyles,
@@ -32,12 +31,12 @@ export const styles = css`
3231
${badgeFilledStyles}
3332
${badgeSizeStyles}
3433
${badgeBaseStyles}
35-
`.withBehaviors(
36-
forcedColorsStylesheetBehavior(css`
34+
35+
@media (forced-colors: active) {
3736
:host,
3837
:host([appearance='outline']),
3938
:host([appearance='tint']) {
4039
border-color: CanvasText;
4140
}
42-
`),
43-
);
41+
}
42+
`;

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { css } from '@microsoft/fast-element';
2-
import { display, forcedColorsStylesheetBehavior } from '../utils/index.js';
2+
import { display } from '../utils/index.js';
33
import {
44
borderRadiusCircular,
55
borderRadiusLarge,
@@ -310,8 +310,8 @@ export const styles = css`
310310
border-color: transparent;
311311
background-color: ${colorTransparentBackground};
312312
}
313-
`.withBehaviors(
314-
forcedColorsStylesheetBehavior(css`
313+
314+
@media (forced-colors: active) {
315315
:host {
316316
background-color: ButtonFace;
317317
color: ButtonText;
@@ -332,5 +332,5 @@ export const styles = css`
332332
color: GrayText;
333333
border-color: ButtonText;
334334
}
335-
`),
336-
);
335+
}
336+
`;

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

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import {
2222
strokeWidthThick,
2323
strokeWidthThin,
2424
} from '../theme/design-tokens.js';
25-
import { forcedColorsStylesheetBehavior } from '../utils/behaviors/match-media-stylesheet-behavior.js';
2625
import { display } from '../utils/display.js';
2726

2827
/** Checkbox styles
@@ -153,8 +152,8 @@ export const styles = css`
153152
:host([disabled]${checkedState}) .checked-indicator {
154153
color: ${colorNeutralStrokeDisabled};
155154
}
156-
`.withBehaviors(
157-
forcedColorsStylesheetBehavior(css`
155+
156+
@media (forced-colors: active) {
158157
:host {
159158
border-color: FieldText;
160159
}
@@ -196,5 +195,5 @@ export const styles = css`
196195
:host([disabled]${checkedState}) .checked-indicator {
197196
color: GrayText;
198197
}
199-
`),
200-
);
198+
}
199+
`;

packages/web-components/src/compound-button/compound-button.styles.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import {
1818
spacingHorizontalSNudge,
1919
spacingHorizontalXS,
2020
} from '../theme/design-tokens.js';
21-
import { forcedColorsStylesheetBehavior } from '../utils/index.js';
2221

2322
// Need to support icon hover styles
2423
export const styles = css`
@@ -118,11 +117,11 @@ export const styles = css`
118117
:host([size='large']) ::slotted([slot='description']) {
119118
font-size: ${fontSizeBase300};
120119
}
121-
`.withBehaviors(
122-
forcedColorsStylesheetBehavior(css`
120+
121+
@media (forced-colors: active) {
123122
:host([appearance='primary']:not(:hover, :focus-visible, :disabled, [disabled-focusable]))
124123
::slotted([slot='description']) {
125124
color: HighlightText;
126125
}
127-
`),
128-
);
126+
}
127+
`;

0 commit comments

Comments
 (0)