Skip to content

Commit c440b52

Browse files
authored
Rename fillColor to colorContext (#265)
1 parent 344a5e8 commit c440b52

File tree

19 files changed

+96
-71
lines changed

19 files changed

+96
-71
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "patch",
3+
"comment": "Rename fillColor to colorContext",
4+
"packageName": "@adaptive-web/adaptive-ui",
5+
"email": "[email protected]",
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": "patch",
3+
"comment": "Rename fillColor to colorContext",
4+
"packageName": "@adaptive-web/adaptive-ui-designer-core",
5+
"email": "[email protected]",
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": "patch",
3+
"comment": "Rename fillColor to colorContext",
4+
"packageName": "@adaptive-web/adaptive-web-components",
5+
"email": "[email protected]",
6+
"dependentChangeType": "patch"
7+
}

examples/use-adaptive-components/src/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ AdaptiveDesignSystem.defineComponents({
1919

2020
import {
2121
accentBaseColor,
22-
fillColor,
22+
colorContext,
2323
LayerBaseLuminance,
2424
layerFillBaseLuminance,
2525
layerFillFixedBase
@@ -30,9 +30,9 @@ import { Color } from '@adaptive-web/adaptive-ui';
3030
// This must be called during initialization for the Design Tokens to be setup so the component styling is applied.
3131
DesignToken.registerDefaultStyleTarget();
3232

33-
// The `fillColor` Design Token is the reference for many color recipes - setup the layering system as that basis.
33+
// The `colorContext` Design Token is the reference for many color recipes - setup the layering system as that basis.
3434
// Look at the css for how this displays in the browser in the plain html model.
35-
fillColor.withDefault(layerFillFixedBase);
35+
colorContext.withDefault(layerFillFixedBase);
3636

3737
// Simple event handlers to change Design Token values:
3838

packages/adaptive-ui-designer-core/src/registry/recipes.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import {
1717
bodyFontFamily,
1818
bodyFontStyle,
1919
bodyFontWeight,
20+
colorContext,
2021
cornerRadiusControl,
2122
cornerRadiusLayer,
2223
criticalBaseColor,
@@ -223,6 +224,7 @@ const designTokens: DesignTokenStore = [
223224
];
224225

225226
const colorTokens: DesignTokenOrGroupStore = [
227+
colorContext,
226228
// Layer
227229
layerFillFixedMinus4,
228230
layerFillFixedMinus3,

packages/adaptive-ui-designer-figma-plugin/src/ui/ui-controller-elements.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { customElement, FASTElement, html } from "@microsoft/fast-element";
22
import { DesignToken, StaticDesignTokenValue } from "@microsoft/fast-foundation";
33
import { Color } from "@adaptive-web/adaptive-ui";
4-
import { fillColor } from "@adaptive-web/adaptive-ui/reference";
4+
import { colorContext } from "@adaptive-web/adaptive-ui/reference";
55
import { DesignTokenValue, PluginUINodeData } from "@adaptive-web/adaptive-ui-designer-core";
66
import { UIController } from "./ui-controller.js";
77

@@ -126,7 +126,7 @@ export class ElementsController {
126126
const element = this.getElementForNode(node);
127127
const val = token.getValueFor(element);
128128
// console.log(" getDesignTokenValue", node.id, node.type, token.name, "value", this.valueToString(val));
129-
// console.log(" fill color", fillColor.getValueFor(element)?.toColorString(), element);
129+
// console.log(" color context", colorContext.getValueFor(element)?.toColorString(), element);
130130
return val;
131131
}
132132

@@ -194,7 +194,7 @@ export class ElementsController {
194194
}
195195

196196
private resetFillColorForElement(element: FASTElement) {
197-
this.setDesignTokenForElement(element, fillColor, null);
197+
this.setDesignTokenForElement(element, colorContext, null);
198198
element.childNodes.forEach(child =>
199199
this.resetFillColorForElement(child as unknown as FASTElement)
200200
);

packages/adaptive-ui-designer-figma-plugin/src/ui/ui-controller.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { calc } from '@csstools/css-calc';
22
import { FASTElement, observable } from "@microsoft/fast-element";
33
import { CSSDesignToken, DesignToken, type ValuesOf } from "@microsoft/fast-foundation";
44
import { Color, InteractiveState, InteractiveTokenGroup, StyleProperty, Styles } from "@adaptive-web/adaptive-ui";
5-
import { fillColor } from "@adaptive-web/adaptive-ui/reference";
5+
import { colorContext } from "@adaptive-web/adaptive-ui/reference";
66
import {
77
AdaptiveDesignToken,
88
AdaptiveDesignTokenOrGroup,
@@ -258,7 +258,7 @@ export class UIController {
258258
source,
259259
});
260260
} else {
261-
console.warn(" token type not supported >", typeof token, token);
261+
console.warn(" token type not supported >", typeof token, token, applied.tokenID, applied.value);
262262
}
263263
}
264264
} else if (applied.tokenID) {
@@ -341,7 +341,7 @@ export class UIController {
341341
source,
342342
});
343343
} else {
344-
console.warn(" token type not supported >", typeof value, value);
344+
console.warn(" token type not supported >", typeof value, value, target);
345345
}
346346
}
347347
}
@@ -381,7 +381,7 @@ export class UIController {
381381
if (colorHex) {
382382
const parentElement = this._elements.getElementForNode(node).parentElement as FASTElement;
383383
// console.log(" setting fill color token on parent element", colorHex, parentElement.id, parentElement.title);
384-
this._elements.setDesignTokenForElement(parentElement, fillColor, Color.parse(colorHex));
384+
this._elements.setDesignTokenForElement(parentElement, colorContext, Color.parse(colorHex));
385385
}
386386

387387
const allApplied = this.collectEffectiveAppliedStyles(node);
@@ -420,8 +420,8 @@ export class UIController {
420420
value = ret;
421421
}
422422
}
423-
// const fillColorValue = (this._elements.getDesignTokenValue(node, fillColor) as Color).toColorString();
424-
// console.log(" evaluateEffectiveAppliedDesignToken", target, " : ", token.name, " -> ", value, valueDebug, `(from ${info.source})`, "fillColor", fillColorValue);
423+
// const colorContextValue = (this._elements.getDesignTokenValue(node, colorContext) as Color).toColorString();
424+
// console.log(" evaluateEffectiveAppliedDesignToken", target, " : ", token.name, " -> ", value, valueDebug, `(from ${info.source})`, "colorContext", colorContextValue);
425425

426426
const applied = new AppliedStyleValue(value);
427427
node.effectiveAppliedStyleValues.set(target, applied);

packages/adaptive-ui-explorer/src/components/color-block.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {
1010
accentHueShiftGradientFillSubtleElementStyles,
1111
accentOutlineDiscernibleControlStyles,
1212
accentToHighlightGradientFillSubtleElementStyles,
13-
fillColor,
13+
colorContext,
1414
highlightFillDiscernibleControlStyles,
1515
highlightFillIdealControlStyles,
1616
highlightFillReadableControlStyles,
@@ -205,7 +205,7 @@ const styles = css`
205205
min-height: 100%;
206206
padding: 36px;
207207
gap: 24px;
208-
background-color: ${fillColor};
208+
background-color: ${colorContext};
209209
color: ${neutralStrokeReadable.rest};
210210
}
211211
@@ -273,7 +273,7 @@ export class ColorBlock extends FASTElement {
273273
if (this.color && this.$fastController.isConnected) {
274274
const color = Color.parse(this.color)
275275
if (color) {
276-
fillColor.setValueFor(this, color);
276+
colorContext.setValueFor(this, color);
277277
}
278278
}
279279
}

packages/adaptive-ui-explorer/src/components/layer-background/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Color } from '@adaptive-web/adaptive-ui';
22
import {
3-
fillColor,
3+
colorContext,
44
layerFillBaseLuminance,
55
layerFillFixedBase,
66
layerFillFixedMinus1,
@@ -23,7 +23,7 @@ const layerBackgroundStyles = css`
2323
2424
:host {
2525
display: block;
26-
background: ${fillColor};
26+
background: ${colorContext};
2727
color: ${neutralStrokeStrongRest};
2828
}
2929
`;
@@ -93,7 +93,7 @@ export class LayerBackground extends FASTElement {
9393
}
9494

9595
if (swatch !== null) {
96-
fillColor.setValueFor(this, swatch);
96+
colorContext.setValueFor(this, swatch);
9797
}
9898
}
9999
}

packages/adaptive-ui-explorer/src/components/style-example.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Color, InteractiveTokenGroup, StyleProperty, Styles, TypedCSSDesignToken } from "@adaptive-web/adaptive-ui";
2-
import { densityControl, fillColor } from '@adaptive-web/adaptive-ui/reference';
2+
import { colorContext, densityControl } from '@adaptive-web/adaptive-ui/reference';
33
import { componentBaseStyles } from "@adaptive-web/adaptive-web-components";
44
import { css, customElement, FASTElement, html, observable, repeat, volatile, when } from "@microsoft/fast-element";
55
import { AdaptiveComponent } from "./adaptive-component.js";
@@ -76,10 +76,10 @@ export class StyleExample extends FASTElement {
7676
public get styleValues(): StyleValue[] {
7777
const values: StyleValue[] = [];
7878

79-
let backgroundRest = fillColor;
80-
let backgroundHover = fillColor;
81-
let backgroundActive = fillColor;
82-
let backgroundFocus = fillColor;
79+
let backgroundRest = colorContext;
80+
let backgroundHover = colorContext;
81+
let backgroundActive = colorContext;
82+
let backgroundFocus = colorContext;
8383

8484
const backgroundValue = this.styles?.effectiveProperties?.get(StyleProperty.backgroundFill);
8585
if (backgroundValue) {

0 commit comments

Comments
 (0)