Skip to content

Commit 87e88ef

Browse files
committed
Style definition cleanup
1 parent 855069b commit 87e88ef

File tree

3 files changed

+50
-22
lines changed

3 files changed

+50
-22
lines changed

packages/adaptive-ui/src/core/modules/styles.ts

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,25 @@ export const Fill = {
109109
};
110110
},
111111

112-
foregroundNonInteractiveWithDisabled: function(
112+
backgroundNonInteractive: function(
113+
background: TypedCSSDesignToken<Paint>,
114+
disabled?: TypedCSSDesignToken<Paint>,
115+
): StyleProperties {
116+
return {
117+
backgroundFill: {
118+
name: `${background.name}-value`,
119+
rest: background,
120+
hover: background,
121+
active: background,
122+
focus: background,
123+
disabled: disabled || background,
124+
} as InteractiveTokenGroup<Paint>,
125+
}
126+
},
127+
128+
foregroundNonInteractive: function(
113129
foreground: TypedCSSDesignToken<Paint>,
114-
disabled: TypedCSSDesignToken<Paint>,
130+
disabled?: TypedCSSDesignToken<Paint>,
115131
): StyleProperties {
116132
return {
117133
foregroundFill: {
@@ -120,7 +136,7 @@ export const Fill = {
120136
hover: foreground,
121137
active: foreground,
122138
focus: foreground,
123-
disabled,
139+
disabled : disabled || foreground,
124140
} as InteractiveTokenGroup<Paint>,
125141
}
126142
}

packages/adaptive-ui/src/reference/modules.ts

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { ValuesOf } from "@microsoft/fast-foundation";
2-
import { Fill, Styles, StyleValue } from "../core/modules/styles.js";
3-
import { cornerRadiusControl, cornerRadiusLayer, focusStrokeThickness, strokeThickness } from "./appearance.js";
2+
import { Fill, Styles } from "../core/modules/styles.js";
3+
import { cornerRadiusControl, cornerRadiusLayer, focusStrokeThickness } from "./appearance.js";
44
import {
55
accentFillDiscernible,
66
accentFillIdeal,
@@ -116,6 +116,7 @@ import {
116116
typeRampPlus6FontVariations,
117117
typeRampPlus6LineHeight,
118118
} from "./type.js";
119+
import { densityBorderStyles, transparent } from "./util.js";
119120

120121
/**
121122
* Style module for the shape of a control.
@@ -298,18 +299,6 @@ export const layerDensityStyles: Styles = Styles.fromProperties(
298299
"density.layer",
299300
);
300301

301-
const transparent = "transparent";
302-
303-
// TODO: There's a bit of an overlap right now where density calculations assume a border thickness,
304-
// but setting the color is done elsewhere or not at all, producing inconsistent and unpredictable styling.
305-
const densityBorderStyles = (fillValue: StyleValue) => {
306-
return {
307-
borderThickness: strokeThickness,
308-
borderStyle: "solid",
309-
borderFill: fillValue,
310-
}
311-
};
312-
313302
/**
314303
* Convenience style module for an accent-filled stealth control (interactive).
315304
*
@@ -1295,7 +1284,7 @@ export const neutralFillReadableControlStyles: Styles = Styles.fromProperties(
12951284
export const neutralOutlineDiscernibleControlStyles: Styles = Styles.fromProperties(
12961285
{
12971286
...densityBorderStyles(neutralStrokeDiscernible),
1298-
...Fill.foregroundNonInteractiveWithDisabled(neutralStrokeStrong.rest, neutralStrokeStrong.disabled),
1287+
...Fill.foregroundNonInteractive(neutralStrokeStrong.rest, neutralStrokeStrong.disabled),
12991288
backgroundFill: fillColor,
13001289
},
13011290
"color.neutral-outline-discernible-control",
@@ -1313,7 +1302,7 @@ export const neutralOutlineDiscernibleControlStyles: Styles = Styles.fromPropert
13131302
*/
13141303
export const neutralForegroundReadableElementStyles: Styles = Styles.fromProperties(
13151304
{
1316-
...Fill.foregroundNonInteractiveWithDisabled(neutralStrokeReadable.rest, neutralStrokeReadable.disabled),
1305+
...Fill.foregroundNonInteractive(neutralStrokeReadable.rest, neutralStrokeReadable.disabled),
13171306
},
13181307
"color.neutral-foreground-readable-element",
13191308
);
@@ -1330,7 +1319,7 @@ export const neutralForegroundReadableElementStyles: Styles = Styles.fromPropert
13301319
*/
13311320
export const neutralForegroundStrongElementStyles: Styles = Styles.fromProperties(
13321321
{
1333-
...Fill.foregroundNonInteractiveWithDisabled(neutralStrokeStrong.rest, neutralStrokeStrong.disabled),
1322+
...Fill.foregroundNonInteractive(neutralStrokeStrong.rest, neutralStrokeStrong.disabled),
13341323
},
13351324
"color.neutral-foreground-strong-element",
13361325
);
@@ -1347,7 +1336,7 @@ export const neutralForegroundStrongElementStyles: Styles = Styles.fromPropertie
13471336
*/
13481337
export const neutralDividerSubtleElementStyles: Styles = Styles.fromProperties(
13491338
{
1350-
...Fill.foregroundNonInteractiveWithDisabled(neutralStrokeSubtle.rest, neutralStrokeStrong.disabled),
1339+
...Fill.foregroundNonInteractive(neutralStrokeSubtle.rest, neutralStrokeStrong.disabled),
13511340
},
13521341
"color.neutral-divider-subtle-element",
13531342
);
@@ -1364,7 +1353,7 @@ export const neutralDividerSubtleElementStyles: Styles = Styles.fromProperties(
13641353
*/
13651354
export const neutralDividerDiscernibleElementStyles: Styles = Styles.fromProperties(
13661355
{
1367-
...Fill.foregroundNonInteractiveWithDisabled(neutralStrokeDiscernible.rest, neutralStrokeStrong.disabled),
1356+
...Fill.foregroundNonInteractive(neutralStrokeDiscernible.rest, neutralStrokeStrong.disabled),
13681357
},
13691358
"color.neutral-divider-discernible-element",
13701359
);
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { StyleValue } from "../core/modules/styles.js";
2+
import { strokeThickness } from "./appearance.js";
3+
4+
// Note that this file is not exported from the package.
5+
6+
/**
7+
* @internal
8+
*/
9+
export const transparent = "transparent";
10+
11+
// TODO: There's a bit of an overlap right now where density calculations assume a border thickness,
12+
// but setting the color is done elsewhere or not at all, producing inconsistent and unpredictable styling.
13+
14+
/**
15+
* @internal
16+
*/
17+
export const densityBorderStyles = (fillValue: StyleValue) => {
18+
return {
19+
borderThickness: strokeThickness,
20+
borderStyle: "solid",
21+
borderFill: fillValue,
22+
}
23+
};

0 commit comments

Comments
 (0)