Skip to content

Commit

Permalink
(web-components) Added attribute to allow easy update to the neutral …
Browse files Browse the repository at this point in the history
…palette (microsoft#18910)

* Added attribute to allow easy update to the neutral palette

* Change files
  • Loading branch information
bheston authored and PeterDraex committed Aug 6, 2021
1 parent 7d4fac7 commit 91ee963
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "minor",
"comment": "Added attribute to allow easy update to the neutral palette",
"packageName": "@fluentui/web-components",
"email": "[email protected]",
"dependentChangeType": "patch"
}
1 change: 1 addition & 0 deletions packages/web-components/docs/api-report.md
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,7 @@ export class DesignSystemProvider extends FoundationElement {
disabledOpacity: number;
fillColor: Swatch;
focusStrokeWidth: number;
neutralBaseColor: Swatch;
neutralFillActiveDelta: number;
neutralFillFocusDelta: number;
neutralFillHoverDelta: number;
Expand Down
24 changes: 23 additions & 1 deletion packages/web-components/src/design-system-provider/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
FoundationElement,
} from '@microsoft/fast-foundation';
import { Direction, SystemColors } from '@microsoft/fast-web-utilities';
import { Palette } from '../color/palette';
import { Palette, PaletteRGB } from '../color/palette';
import { Swatch, SwatchRGB } from '../color/swatch';
import {
accentFillActiveDelta,
Expand Down Expand Up @@ -184,6 +184,28 @@ export class DesignSystemProvider extends FoundationElement {
@designToken(fillColor)
public fillColor: Swatch;

/**
* A convenience to recreate the neutralPalette
* @remarks
* HTML attribute: neutral-base-color
*/
@attr({
attribute: 'neutral-base-color',
converter: swatchConverter,
})
public neutralBaseColor: Swatch;

/**
* @internal
*/
private neutralBaseColorChanged(prev: Swatch, next: Swatch): void {
if (next !== undefined && next !== null) {
neutralPalette.setValueFor(this, PaletteRGB.create(next as SwatchRGB));
} else {
neutralPalette.deleteValueFor(this);
}
}

/**
* Defines the palette that all neutral color recipes are derived from.
* This is an array for hexadecimal color strings ordered from light to dark.
Expand Down

0 comments on commit 91ee963

Please sign in to comment.