Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: update badge API and styles #3147

Merged
merged 3 commits into from
May 15, 2020

Conversation

chrisdholt
Copy link
Member

Description

This PR udpates the badge template to conditionally render the CSS variable map values when one is actually supplied. Additionally, this updates the base styles of Badge in fast-components and adds appearances to fast-components-msft.

Issue type checklist

  • Chore: A change that does not impact distributed packages.
  • Bug fix: A change that fixes an issue, link to the issue above.
  • New feature: A change that adds functionality.

Is this a breaking change?

  • This change causes current functionality to break.

Process & policy checklist

  • I have added tests for my changes.
  • I have tested my changes.
  • I have updated the project documentation to reflect my changes.
  • I have read the CONTRIBUTING documentation and followed the standards for this project.

@chrisdholt chrisdholt force-pushed the users/chhol/update-msft-badge-behavior branch from 48a301b to 9dac442 Compare May 15, 2020 17:40
private appearanceChanged(
oldValue: BadgeAppearance,
newValue: BadgeAppearance
): void {
if (oldValue !== newValue) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This class should be applied through the template or this can cause a runtime error when this is set during construction

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are there alternatives? This isn't global across all badges and ideally we'd reuse the template.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leveraging DOM.queueUpdate() here

@chrisdholt chrisdholt merged commit c86383c into master May 15, 2020
@chrisdholt chrisdholt deleted the users/chhol/update-msft-badge-behavior branch May 15, 2020 18:07
Copy link
Contributor

@EisenbergEffect EisenbergEffect left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just one little logical thing that may need to be addressed.

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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch on "string"

style="background-color: var(--badge-fill-${x =>
x.fill}); color: var(--badge-color-${x => x.color})"
style="${x =>
x.fill || x.color
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible that there's a fill but no color or a color but no fill?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, this isn't ideal. I think we can update but I wanted to mitigate the issue of this being applied when neither was used. I think it's less egregious to have one undefined variable here that's not in use than both. We should fix this though to have both only written if they exist.

chrisdholt added a commit that referenced this pull request May 18, 2020
* feat: update badge API and styles

* add initial package version

BREAKING CHANGE
chrisdholt added a commit that referenced this pull request May 18, 2020
* feat: update badge API and styles

* add initial package version

BREAKING CHANGE
chrisdholt added a commit that referenced this pull request May 18, 2020
* feat: update badge API and styles

* add initial package version

BREAKING CHANGE
chrisdholt added a commit that referenced this pull request May 18, 2020
* feat: update badge API and styles

* add initial package version

BREAKING CHANGE
chrisdholt added a commit that referenced this pull request May 18, 2020
* feat: update badge API and styles

* add initial package version

BREAKING CHANGE
chrisdholt added a commit that referenced this pull request May 18, 2020
* feat: update badge API and styles

* add initial package version

BREAKING CHANGE
chrisdholt added a commit that referenced this pull request May 18, 2020
* feat: update badge API and styles

* add initial package version

BREAKING CHANGE: fundamentally changes and breaks the badge component API and styles
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants