Skip to content

Commit

Permalink
AUI: Improve StyleProperty shorthand capabilities (#231)
Browse files Browse the repository at this point in the history
  • Loading branch information
bheston authored Oct 17, 2024
1 parent 4607477 commit 8fd5b7f
Show file tree
Hide file tree
Showing 18 changed files with 272 additions and 157 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "minor",
"comment": "AUI: Improve StyleProperty shorthand capabilities",
"packageName": "@adaptive-web/adaptive-ui",
"email": "[email protected]",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "minor",
"comment": "AUI: Improve StyleProperty shorthand capabilities",
"packageName": "@adaptive-web/adaptive-ui-designer-core",
"email": "[email protected]",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "minor",
"comment": "AUI: Improve StyleProperty shorthand capabilities",
"packageName": "@adaptive-web/adaptive-web-components",
"email": "[email protected]",
"dependentChangeType": "patch"
}
3 changes: 1 addition & 2 deletions examples/customize-component/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import {
BorderFill,
createForegroundSet,
Styles
} from "@adaptive-web/adaptive-ui";
Expand Down Expand Up @@ -39,7 +38,7 @@ AdaptiveDesignSystem.defineComponents({
// Define a custom style module.
const accentOutlineReadableControlStyles: Styles = Styles.fromProperties({
backgroundFill: neutralFillSubtle,
...BorderFill.all(accentStrokeReadable),
borderFill: accentStrokeReadable,
foregroundFill: createForegroundSet(accentStrokeReadableRecipe, neutralFillSubtle),
});

Expand Down
64 changes: 32 additions & 32 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
Palette,
PaletteRGB,
StyleProperty,
stylePropertyBorderFillAll,
StylePropertyShorthand,
Swatch,
} from "@adaptive-web/adaptive-ui";
import {
Expand All @@ -34,7 +34,7 @@ export const docPalette = createNonCss<Palette>("doc-palette").withDefault(

export const docForegroundRecipe = createTokenColorRecipe(
"doc-foreground",
[...stylePropertyBorderFillAll, StyleProperty.foregroundFill],
[...StylePropertyShorthand.borderFill, StyleProperty.foregroundFill],
(resolve: DesignTokenResolver, params?: ColorRecipeParams) =>
contrastSwatch(
resolve(docPalette),
Expand Down
21 changes: 9 additions & 12 deletions packages/adaptive-ui-designer-figma-plugin/src/ui/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@ import { css, customElement, FASTElement, html, observable, repeat, when } from
import { staticallyCompose } from "@microsoft/fast-foundation";
import {
StyleProperty,
stylePropertyBorderFillAll,
stylePropertyBorderThicknessAll,
stylePropertyCornerRadiusAll,
stylePropertyPaddingAll
StylePropertyShorthand,
} from "@adaptive-web/adaptive-ui";
import {
cornerRadiusControl,
Expand Down Expand Up @@ -283,7 +280,7 @@ const template = html<App>`
TokenGlyphType.backgroundSwatch)}
${(x) =>
availableTokensTemplate(
stylePropertyBorderFillAll,
StylePropertyShorthand.borderFill,
"Stroke",
"stack",
TokenGlyphType.borderSwatch
Expand Down Expand Up @@ -312,12 +309,12 @@ const template = html<App>`
${(x) => availableStylesTemplate("Shape")}
${(x) =>
availableTokensTemplate(
stylePropertyCornerRadiusAll,
StylePropertyShorthand.cornerRadius,
"Corner radius",
)}
${(x) =>
availableTokensTemplate(
stylePropertyBorderThicknessAll,
StylePropertyShorthand.borderThickness,
"Stroke thickness",
)}
</div>
Expand All @@ -336,7 +333,7 @@ const template = html<App>`
${(x) => availableStylesTemplate("Density")}
${(x) =>
availableTokensTemplate(
[...stylePropertyPaddingAll, StyleProperty.gap],
[...StylePropertyShorthand.padding, StyleProperty.gap],
"Density",
)}
</div>
Expand Down Expand Up @@ -673,10 +670,10 @@ export class App extends FASTElement {
private refreshObservables() {
this.backgroundTokens = this.controller.styles.getAppliedDesignTokens([StyleProperty.backgroundFill]);
this.foregroundTokens = this.controller.styles.getAppliedDesignTokens([StyleProperty.foregroundFill]);
this.borderFillTokens = this.controller.styles.getAppliedDesignTokens(stylePropertyBorderFillAll);
this.borderThicknessTokens = this.controller.styles.getAppliedDesignTokens(stylePropertyBorderThicknessAll);
this.densityTokens = this.controller.styles.getAppliedDesignTokens([...stylePropertyPaddingAll, StyleProperty.gap]);
this.cornerRadiusTokens = this.controller.styles.getAppliedDesignTokens(stylePropertyCornerRadiusAll);
this.borderFillTokens = this.controller.styles.getAppliedDesignTokens(StylePropertyShorthand.borderFill);
this.borderThicknessTokens = this.controller.styles.getAppliedDesignTokens(StylePropertyShorthand.borderThickness);
this.densityTokens = this.controller.styles.getAppliedDesignTokens([...StylePropertyShorthand.padding, StyleProperty.gap]);
this.cornerRadiusTokens = this.controller.styles.getAppliedDesignTokens(StylePropertyShorthand.cornerRadius);
this.textTokens = this.controller.styles.getAppliedDesignTokens([
StyleProperty.fontFamily,
StyleProperty.fontStyle,
Expand Down
Loading

0 comments on commit 8fd5b7f

Please sign in to comment.