-
Notifications
You must be signed in to change notification settings - Fork 597
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: update badge API and styles (#3147)
* feat: update badge API and styles * add initial package version BREAKING CHANGE
- Loading branch information
1 parent
78c5f9e
commit 00f039f
Showing
9 changed files
with
97 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 18 additions & 3 deletions
21
packages/web-components/fast-components-msft/src/badge/fixtures/badge.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,34 @@ | ||
<fast-design-system-provider use-defaults> | ||
<style> | ||
fast-badge { | ||
--badge-fill-highlight: #FFD800; | ||
--badge-fill-lowlight: #333; | ||
--badge-color-highlight: #000; | ||
--badge-color-lowlight: #FFF; | ||
} | ||
</style> | ||
<h1>Badge</h1> | ||
<h4>Default</h4> | ||
<fast-badge> | ||
Badge | ||
</fast-badge> | ||
<h4>Lightweight</h4> | ||
<fast-badge fill="lightweight"> | ||
<fast-badge appearance="lightweight"> | ||
Badge | ||
</fast-badge> | ||
<h4>Accent</h4> | ||
<fast-badge fill="accent"> | ||
<fast-badge appearance="accent"> | ||
Badge | ||
</fast-badge> | ||
<h4>Neutral</h4> | ||
<fast-badge fill="neutral"> | ||
<fast-badge appearance="neutral"> | ||
Badge | ||
</fast-badge> | ||
<h4>With map</h4> | ||
<fast-badge fill="highlight" color="highlight"> | ||
Badge | ||
</fast-badge> | ||
<fast-badge fill="lowlight" color="lowlight"> | ||
Badge | ||
</fast-badge> | ||
</fast-design-system-provider> |
19 changes: 12 additions & 7 deletions
19
packages/web-components/fast-components-msft/src/badge/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,26 @@ | ||
import { attr, customElement } from "@microsoft/fast-element"; | ||
import { attr, customElement, DOM } from "@microsoft/fast-element"; | ||
import { Badge, BadgeTemplate as template } from "@microsoft/fast-foundation"; | ||
import { BadgeStyles as styles } from "./badge.styles"; | ||
|
||
export type BadgeFill = "accent" | "lightweight" | "neutral" | "string"; | ||
export type BadgeAppearance = "accent" | "lightweight" | "neutral" | string; | ||
|
||
@customElement({ | ||
name: "fast-badge", | ||
template, | ||
styles, | ||
}) | ||
export class FASTBadge extends Badge { | ||
@attr | ||
public fill: BadgeFill = "lightweight"; | ||
private fillChanged(oldValue: BadgeFill, newValue: BadgeFill): void { | ||
@attr({ mode: "fromView" }) | ||
public appearance: BadgeAppearance = "lightweight"; | ||
private appearanceChanged( | ||
oldValue: BadgeAppearance, | ||
newValue: BadgeAppearance | ||
): void { | ||
if (oldValue !== newValue) { | ||
this.classList.add(newValue); | ||
this.classList.remove(oldValue); | ||
DOM.queueUpdate(() => { | ||
this.classList.add(newValue); | ||
this.classList.remove(oldValue); | ||
}); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters