Skip to content

Commit

Permalink
chore: replace the deprecated react badge with the FAST web component…
Browse files Browse the repository at this point in the history
…s badge (#4279)

# Description

<!--- Describe your changes. -->
Replaces the deprecated React badge with the `<fast-badge>` from the `@microsoft/fast-components` package.

## Motivation & context

<!--- What problem does this change solve? -->
<!--- Provide a link if you are addressing an open issue. -->
Resolves #4266

## Issue type checklist

<!--- What type of change are you submitting? Put an x in the box that applies: -->

- [x] **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.

<!--- If yes, describe the impact. -->

**Adding or modifying component(s) in `@microsoft/fast-components` checklist**

<!-- Do your changes add or modify components in the @microsoft/fast-components package? Put an x in the box that applies: -->

- [ ] I have added a new component
- [ ] I have modified an existing component
- [ ] I have updated the [definition file](https://github.com/Microsoft/fast/blob/master/packages/web-components/fast-components/CONTRIBUTING.md#definition)
- [ ] I have updated the [configuration file](https://github.com/Microsoft/fast/blob/master/packages/web-components/fast-components/CONTRIBUTING.md#configuration)

## Process & policy checklist

<!--- Review the list and check the boxes that apply. -->

- [ ] I have added tests for my changes.
- [x] I have tested my changes.
- [ ] I have updated the project documentation to reflect my changes.
- [x] I have read the [CONTRIBUTING](https://github.com/Microsoft/fast/blob/master/CONTRIBUTING.md) documentation and followed the [standards](https://www.fast.design/docs/community/code-of-conduct/#our-standards) for this project.

<!---
Formatting guidelines:

Accepted peer review title format:
<type>: <description>

Example titles:
    chore: add unit tests for all components
    feat: add a border radius to button
    fix: update design system to use 3px border radius

    <type> is required to be one of the following:

        - chore: A change that does not impact distributed packages.
        - fix: A change which fixes an issue.
        - feat: A that adds functionality.

    <description> is required for the CHANGELOG and speaks to what the user gets from this PR:

        - Be concise.
        - Use all lowercase characters. 
        - Use imperative, present tense (e.g. `add` not `adds`.)
        - Do not end your description with a period.
        - Avoid redundant words.

For additional information regarding working on FAST, check out our documentation site:
https://www.fast.design/docs/community/contributor-guide
-->
  • Loading branch information
janechu authored Feb 1, 2021
1 parent 4de6b01 commit ca14d1f
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 10 deletions.
2 changes: 1 addition & 1 deletion sites/fast-component-explorer/app/web-components/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
FASTTabs,
} from "@microsoft/fast-components";
import { neutralLayerL1, neutralLayerL3 } from "@microsoft/fast-components-styles-msft";
import h from "./pragma";
import h from "@microsoft/site-utilities/dist/web-components/pragma";

/**
* Ensure tree-shaking doesn't remove these components from the bundle
Expand Down
4 changes: 2 additions & 2 deletions sites/fast-creator/app/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ export default class App extends React.Component<{}, {}> {
public render(): React.ReactNode {
return (
<BrowserRouter>
<div>
<fast-design-system-provider use-defaults>
<DesignSystemProvider designSystem={creatorDesignSystem}>
<Route component={Creator} exact={true} path="/" />
</DesignSystemProvider>
<Route component={Preview} exact={true} path="/preview" />
</div>
</fast-design-system-provider>
</BrowserRouter>
);
}
Expand Down
1 change: 1 addition & 0 deletions sites/site-utilities/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
"@microsoft/fast-foundation": "^1.12.0",
"@microsoft/fast-tooling": "^0.15.0",
"@microsoft/fast-tooling-react": "^2.5.3",
"@skatejs/val": "^0.5.0",
"monaco-editor": "^0.21.2",
"vscode-html-languageservice": "^3.1.3"
}
Expand Down
28 changes: 21 additions & 7 deletions sites/site-utilities/src/components/logo/index.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
/** @jsx h */ /* Note: Set the JSX pragma to the wrapped version of createElement */

import React from "react";
import {
Background,
Badge,
Heading,
HeadingSize,
} from "@microsoft/fast-components-react-msft";
import { Background, Heading, HeadingSize } from "@microsoft/fast-components-react-msft";
import { FASTBadge } from "@microsoft/fast-components";
import h from "../../web-components/pragma";
import { LogoProps } from "./logo.props";

/**
* Ensure tree-shaking doesn't remove these components from the bundle
*/
FASTBadge;

const backgroundStyle = {
display: "flex",
height: "32px",
Expand All @@ -16,6 +20,11 @@ const backgroundStyle = {
};
const imageStyle = { verticalAlign: "middle", height: "32px" };
const spanStyle = { verticalAlign: "middle", margin: "0 10px" };
const style = `
fast-badge {
--badge-fill-primary: #FFD800;
--badge-color-primary: #000000;
}`;

export const Logo: React.FC<LogoProps> = ({
className,
Expand All @@ -25,11 +34,16 @@ export const Logo: React.FC<LogoProps> = ({
}: React.PropsWithChildren<LogoProps>): React.ReactElement => {
return (
<Background className={className} drawBackground={true} style={backgroundStyle}>
<style>{style}</style>
<Heading size={HeadingSize._6}>
<img src={logo} style={imageStyle} />
<span style={spanStyle}>{title}</span>
</Heading>
{version ? <Badge>{version}</Badge> : null}
{version ? (
<fast-badge fill="primary" color="primary">
{version}
</fast-badge>
) : null}
</Background>
);
};
Expand Down
17 changes: 17 additions & 0 deletions sites/site-utilities/src/custom-elements.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// custom-elements.d.ts
declare namespace JSX {
interface IntrinsicElements {
"fast-badge": React.DetailedHTMLProps<
React.HTMLAttributes<HTMLElement>,
HTMLElement
> & {
fill?: string;
color?: string;
};
}
}

/**
* Satisfy TypeScript importing modules without typings
*/
declare module "@skatejs/val";

0 comments on commit ca14d1f

Please sign in to comment.