From a4cfbbbe4a3caf07213bf83b2856920b5f0c8076 Mon Sep 17 00:00:00 2001 From: nicholasrice Date: Tue, 9 Jun 2020 09:35:06 -0700 Subject: [PATCH 01/11] adds access to css custom property from behavior and replaces where appropriate --- .../fast-components/docs/api-report.md | 3 - .../accordion-item/accordion-item.styles.ts | 14 +- .../src/accordion/accordion.styles.ts | 12 +- .../src/accordion/fixtures/base.html | 2 +- .../src/anchor/anchor.styles.ts | 43 +----- .../fast-components/src/badge/badge.styles.ts | 2 +- .../src/button/button.styles.ts | 40 ------ .../fast-components/src/card/card.styles.ts | 4 +- .../src/checkbox/checkbox.styles.ts | 40 +++--- .../src/divider/divider.styles.ts | 3 +- .../src/flipper/flipper.styles.ts | 30 +++-- .../src/menu-item/menu-item.styles.ts | 32 ++--- .../fast-components/src/menu/menu.styles.ts | 2 +- .../progress-ring/progress-ring.styles.ts | 10 +- .../src/progress/progress/progress.styles.ts | 12 +- .../src/radio-group/fixtures/base.html | 16 +-- .../fast-components/src/radio/radio.styles.ts | 40 +++--- .../src/slider-label/slider-label.styles.ts | 6 +- .../src/slider/fixtures/base.html | 4 +- .../src/slider/slider.styles.ts | 14 +- .../src/styles/patterns/button.ts | 125 ++++++++++++------ .../src/switch/switch.styles.ts | 42 +++--- .../src/tabs/tab/tab.styles.ts | 38 +++--- .../fast-components/src/tabs/tabs.styles.ts | 6 +- .../src/text-area/text-area.styles.ts | 26 ++-- .../src/text-field/text-field.styles.ts | 30 ++--- .../fast-components/temp/api-report.md | 3 - .../fast-foundation/docs/api-report.md | 11 +- .../src/custom-properties/behavior.ts | 112 +++++++++++----- 29 files changed, 378 insertions(+), 344 deletions(-) diff --git a/packages/web-components/fast-components/docs/api-report.md b/packages/web-components/fast-components/docs/api-report.md index 9cc4d730a2a..e7d2409a6a5 100644 --- a/packages/web-components/fast-components/docs/api-report.md +++ b/packages/web-components/fast-components/docs/api-report.md @@ -181,7 +181,6 @@ export class FASTCheckbox extends Checkbox { // // @public (undocumented) export class FASTDesignSystemProvider extends DesignSystemProvider implements FASTDesignSystem { - // (undocumented) accentBaseColor: string; // (undocumented) accentFillActiveDelta: number; @@ -201,7 +200,6 @@ export class FASTDesignSystemProvider extends DesignSystemProvider implements FA accentForegroundHoverDelta: number; // (undocumented) accentForegroundRestDelta: number; - // (undocumented) accentPalette: string[]; backgroundColor: string; // (undocumented) @@ -274,7 +272,6 @@ export class FASTDesignSystemProvider extends DesignSystemProvider implements FA neutralOutlineHoverDelta: number; // (undocumented) neutralOutlineRestDelta: number; - // (undocumented) neutralPalette: string[]; // (undocumented) outlineWidth: number; diff --git a/packages/web-components/fast-components/src/accordion/accordion-item/accordion-item.styles.ts b/packages/web-components/fast-components/src/accordion/accordion-item/accordion-item.styles.ts index 371c03ea72b..4d804029e2f 100644 --- a/packages/web-components/fast-components/src/accordion/accordion-item/accordion-item.styles.ts +++ b/packages/web-components/fast-components/src/accordion/accordion-item/accordion-item.styles.ts @@ -4,14 +4,15 @@ import { focusVisible, forcedColorsStylesheetBehavior, } from "@microsoft/fast-foundation"; +import { SystemColors } from "@microsoft/fast-web-utilities"; import { neutralDividerRestBehavior, neutralFocusBehavior, neutralForegroundActiveBehavior, neutralForegroundFocusBehavior, + neutralForegroundHoverBehavior, neutralForegroundRestBehavior, } from "../../styles/recipes"; -import { SystemColors } from "@microsoft/fast-web-utilities"; import { heightNumber } from "../../styles/size"; export const AccordionItemStyles = css` @@ -46,16 +47,16 @@ export const AccordionItemStyles = css` padding: 0 calc((6 + (var(--design-unit) * 2 * var(--density))) * 1px); text-align: left; height: calc(${heightNumber} * 1px); - color: var(--neutral-foreground-rest); + color: ${neutralForegroundRestBehavior.var}; cursor: pointer; } .button:hover { - color: var(--neutral-foreground-hover); + color: ${neutralForegroundHoverBehavior.var}; } .button:active { - color: var(--neutral-foreground-active); + color: ${neutralForegroundActiveBehavior.var}; } .button::before { @@ -71,9 +72,9 @@ export const AccordionItemStyles = css` .button:${focusVisible}::before { outline: none; - border: calc(var(--outline-width) * 1px) solid var(--neutral-focus); + border: calc(var(--outline-width) * 1px) solid ${neutralFocusBehavior.var}; box-shadow: 0 0 0 calc((var(--focus-outline-width) - var(--outline-width)) * 1px) - var(--neutral-focus); + ${neutralFocusBehavior.var}; } :host(.expanded) .region { @@ -124,6 +125,7 @@ export const AccordionItemStyles = css` neutralDividerRestBehavior, neutralForegroundActiveBehavior, neutralForegroundFocusBehavior, + neutralForegroundHoverBehavior, neutralForegroundRestBehavior, neutralFocusBehavior, forcedColorsStylesheetBehavior( diff --git a/packages/web-components/fast-components/src/accordion/accordion.styles.ts b/packages/web-components/fast-components/src/accordion/accordion.styles.ts index 2b03070c2e1..2529f9ec9dc 100644 --- a/packages/web-components/fast-components/src/accordion/accordion.styles.ts +++ b/packages/web-components/fast-components/src/accordion/accordion.styles.ts @@ -1,7 +1,6 @@ import { css } from "@microsoft/fast-element"; import { display } from "@microsoft/fast-foundation"; import { - accentFillRestBehavior, neutralDividerRestBehavior, neutralForegroundRestBehavior, } from "../styles/recipes"; @@ -13,11 +12,8 @@ export const AccordionStyles = css` font-family: var(--body-font); font-size: var(--type-ramp-minus-1-font-size); line-height: var(--type-ramp-minus-1-line-height); - color: var(--neutral-foreground-rest); - border-top: calc(var(--outline-width) * 1px) solid var(--neutral-divider-rest); + color: ${neutralForegroundRestBehavior.var}; + border-top: calc(var(--outline-width) * 1px) solid + ${neutralDividerRestBehavior.var}; } -`.withBehaviors( - accentFillRestBehavior, - neutralDividerRestBehavior, - neutralForegroundRestBehavior -); +`.withBehaviors(neutralDividerRestBehavior, neutralForegroundRestBehavior); diff --git a/packages/web-components/fast-components/src/accordion/fixtures/base.html b/packages/web-components/fast-components/src/accordion/fixtures/base.html index 3b85ca61cad..f7f6eac0017 100644 --- a/packages/web-components/fast-components/src/accordion/fixtures/base.html +++ b/packages/web-components/fast-components/src/accordion/fixtures/base.html @@ -1,7 +1,7 @@