Skip to content

Commit

Permalink
vNext: update components to extend FoundationElement (#4570)
Browse files Browse the repository at this point in the history
* support foundation element on accordion and accordion item

* update anchor to use foundation element

* update AnchoredRegion to extend FoundationElement

* update Badge to extend FoundationElement

* update breadcrumb and breadcrumb item to extend FoundationElement

* update Button to extend FoundationElement

* update checkbox to extend from FoundationElement

* update Dialog to extend FoundationElement

* update disclosure to extend FoundationElement

* update divider to extend FoundationElement

* update Flipper to extend FoundationElement

* update horizontal scroll to extend FoundationElement

* update Listbox and ListboxOption to extend FoundationElement

* update combobox to extend FoundationElement

* update select to extend combobox and update tests

* fix listbox option styles and export

* update tests (wip)

* update Menu and MenuItem to extend FoundationElement

* update number field to extend FoundationElement

* update base name values

* fix: prevent the mixin helper from copying over constructor properties

* feat: fixture ergonomic improvements for foundation elements

* test: fix Anchor and associated unit tests based on new system

* remove incorrect tagFor usage

* update radio and radiogroup

* update skeleton

* update slider and slider label

* update switch

* update tabs et all to use FoundationElement

* update text area and text field to use foundation el

* Update tooltip to use FoundationElement

* update tests and tree item and view

* remove website from lerna packages in favor of npm registry to prevent breaking changes for the time being

* update progress and progress ring to use Foundation element

* fixing the tests

* feat: enable fixtures to handle N foundation elements and custom system

* fixing tests!

* Change files

* fix errors in fast-website

* update typings for explorer

* update naming convention to lowercase fast

* update imports for sites

* Change files

* update template names to lowercase

* update style casing and apply updates to component registries

* update tsdoc links for templates

Co-authored-by: Rob Eisenberg <[email protected]>
  • Loading branch information
2 people authored and nicholasrice committed Apr 22, 2021
1 parent 679f9f0 commit 0fe93ec
Show file tree
Hide file tree
Showing 208 changed files with 3,301 additions and 2,675 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "major",
"comment": "update components to extend FoundationElement",
"packageName": "@microsoft/fast-components",
"email": "[email protected]",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "major",
"comment": "update components to extend FoundationElement",
"packageName": "@microsoft/fast-foundation",
"email": "[email protected]",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "none",
"comment": "update fast-tooling references to web components",
"packageName": "@microsoft/fast-tooling-react",
"email": "[email protected]",
"dependentChangeType": "none"
}
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
/** @jsx h */ /* Note: Set the JSX pragma to the wrapped version of createElement */
import h from "../../utilities/web-components/pragma"; /* Note: Import wrapped createElement. */

import {
fastCheckbox,
fastNumberField,
fastOption,
fastSelect,
fastTextField,
} from "@microsoft/fast-components";
import { FASTColorPicker } from "@microsoft/fast-tooling/dist/esm/web-components";
import React from "react";
import {
RenderRefControlConfig,
RenderSelectControlConfig,
} from "./control.css.utilities.props";
import {
FASTCheckbox,
FASTNumberField,
FASTOption,
FASTSelect,
FASTTextField,
} from "@microsoft/fast-components";
import { FASTColorPicker } from "@microsoft/fast-tooling/dist/esm/web-components";

/**
* Ensure tree-shaking doesn't remove these components from the bundle.
*/
FASTCheckbox;
FASTNumberField;
FASTOption;
FASTSelect;
FASTTextField;
fastCheckbox;
fastNumberField;
fastOption;
fastSelect;
fastTextField;
FASTColorPicker;

export function renderDefault(config: RenderRefControlConfig): React.ReactNode {
Expand Down
791 changes: 578 additions & 213 deletions packages/web-components/fast-components/docs/api-report.md

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ import {
} from "../styles/recipes";
import { heightNumber } from "../styles/size";

export const AccordionItemStyles = css`
export const accordionItemStyles = (context, definition) =>
css`
${display("flex")} :host {
box-sizing: border-box;
font-family: var(--body-font);
Expand Down Expand Up @@ -130,19 +131,19 @@ export const AccordionItemStyles = css`
z-index: 2;
}
`.withBehaviors(
accentFillRestBehavior,
neutralDividerRestBehavior,
neutralForegroundActiveBehavior,
neutralForegroundFocusBehavior,
neutralForegroundHoverBehavior,
neutralForegroundRestBehavior,
neutralFocusBehavior,
forcedColorsStylesheetBehavior(
css`
accentFillRestBehavior,
neutralDividerRestBehavior,
neutralForegroundActiveBehavior,
neutralForegroundFocusBehavior,
neutralForegroundHoverBehavior,
neutralForegroundRestBehavior,
neutralFocusBehavior,
forcedColorsStylesheetBehavior(
css`
.button:${focusVisible}::before {
border-color: ${SystemColors.Highlight};
box-shadow: 0 0 0 calc((var(--focus-outline-width) - var(--outline-width)) * 1px) ${SystemColors.Highlight};
}
`
)
);
)
);
Original file line number Diff line number Diff line change
@@ -1,25 +1,23 @@
import { customElement } from "@microsoft/fast-element";
import {
AccordionItem,
AccordionItemTemplate as template,
accordionItemTemplate as template,
} from "@microsoft/fast-foundation";
import { AccordionItemStyles as styles } from "./accordion-item.styles";
import { accordionItemStyles as styles } from "./accordion-item.styles";

/**
* The FAST Accordion Item Element. Implements {@link @microsoft/fast-foundation#AccordionItem},
* {@link @microsoft/fast-foundation#AccordionItemTemplate}
* {@link @microsoft/fast-foundation#accordionItemTemplate}
*
*
* @public
* @remarks
* HTML Element: \<fast-accordion-item\>
*/
@customElement({
name: "fast-accordion-item",
export const fastAccordionItem = AccordionItem.compose({
baseName: "accordion-item",
template,
styles,
})
export class FASTAccordionItem extends AccordionItem {}
});

/**
* Styles for AccordionItem
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,16 @@ import {
neutralForegroundRestBehavior,
} from "../styles/recipes";

export const AccordionStyles = css`
${display("flex")} :host {
box-sizing: border-box;
flex-direction: column;
font-family: var(--body-font);
font-size: var(--type-ramp-minus-1-font-size);
line-height: var(--type-ramp-minus-1-line-height);
color: ${neutralForegroundRestBehavior.var};
border-top: calc(var(--outline-width) * 1px) solid
${neutralDividerRestBehavior.var};
}
`.withBehaviors(neutralDividerRestBehavior, neutralForegroundRestBehavior);
export const accordionStyles = (context, definition) =>
css`
${display("flex")} :host {
box-sizing: border-box;
flex-direction: column;
font-family: var(--body-font);
font-size: var(--type-ramp-minus-1-font-size);
line-height: var(--type-ramp-minus-1-line-height);
color: ${neutralForegroundRestBehavior.var};
border-top: calc(var(--outline-width) * 1px) solid
${neutralDividerRestBehavior.var};
}
`.withBehaviors(neutralDividerRestBehavior, neutralForegroundRestBehavior);
14 changes: 6 additions & 8 deletions packages/web-components/fast-components/src/accordion/index.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,22 @@
import { customElement } from "@microsoft/fast-element";
import { Accordion, AccordionTemplate as template } from "@microsoft/fast-foundation";
import { AccordionStyles as styles } from "./accordion.styles";
import { Accordion, accordionTemplate as template } from "@microsoft/fast-foundation";
import { accordionStyles as styles } from "./accordion.styles";

export * from "../accordion-item/index";

/**
* The FAST Accordion Element. Implements {@link @microsoft/fast-foundation#Accordion},
* {@link @microsoft/fast-foundation#AccordionTemplate}
* {@link @microsoft/fast-foundation#accordionTemplate}
*
*
* @public
* @remarks
* HTML Element: \<fast-accordion\>
*/
@customElement({
name: "fast-accordion",
export const fastAccordion = Accordion.compose({
baseName: "accordion",
template,
styles,
})
export class FASTAccordion extends Accordion {}
});

/**
* Styles for Accordion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@ import {
} from "../styles/index";
import { appearanceBehavior } from "../utilities/behaviors";

export const AnchorStyles = css`
${BaseButtonStyles}
`.withBehaviors(
appearanceBehavior("accent", AccentButtonStyles),
appearanceBehavior("hypertext", HypertextStyles),
appearanceBehavior("lightweight", LightweightButtonStyles),
appearanceBehavior("outline", OutlineButtonStyles),
appearanceBehavior("stealth", StealthButtonStyles)
);
export const anchorStyles = (context, definition) =>
css`
${BaseButtonStyles}
`.withBehaviors(
appearanceBehavior("accent", AccentButtonStyles),
appearanceBehavior("hypertext", HypertextStyles),
appearanceBehavior("lightweight", LightweightButtonStyles),
appearanceBehavior("outline", OutlineButtonStyles),
appearanceBehavior("stealth", StealthButtonStyles)
);
50 changes: 29 additions & 21 deletions packages/web-components/fast-components/src/anchor/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import { attr, customElement } from "@microsoft/fast-element";
import { Anchor, AnchorTemplate as template } from "@microsoft/fast-foundation";
import { attr } from "@microsoft/fast-element";
import {
Anchor as FoundationAnchor,
anchorTemplate as template,
} from "@microsoft/fast-foundation";
import { ButtonAppearance } from "../button";
import { AnchorStyles as styles } from "./anchor.styles";
import { anchorStyles as styles } from "./anchor.styles";

/**
* Types of anchor appearance.
Expand All @@ -10,25 +13,10 @@ import { AnchorStyles as styles } from "./anchor.styles";
export type AnchorAppearance = ButtonAppearance | "hypertext";

/**
* The FAST Anchor Element. Implements {@link @microsoft/fast-foundation#Anchor},
* {@link @microsoft/fast-foundation#AnchorTemplate}
*
*
* @public
* @remarks
* HTML Element: \<fast-anchor\>
*
* {@link https://developer.mozilla.org/en-US/docs/Web/API/ShadowRoot/delegatesFocus | delegatesFocus}
* The FAST components version of Anchor
* @internal
*/
@customElement({
name: "fast-anchor",
template,
styles,
shadowOptions: {
delegatesFocus: true,
},
})
export class FASTAnchor extends Anchor {
export class Anchor extends FoundationAnchor {
/**
* The appearance the anchor should have.
*
Expand Down Expand Up @@ -79,3 +67,23 @@ export class FASTAnchor extends Anchor {
* @public
*/
export const AnchorStyles = styles;

/**
* The FAST Anchor Element. Implements {@link @microsoft/fast-foundation#Anchor},
* {@link @microsoft/fast-foundation#anchorTemplate}
*
*
* @public
* @remarks
* HTML Element: \<fast-anchor\>
*
* {@link https://developer.mozilla.org/en-US/docs/Web/API/ShadowRoot/delegatesFocus | delegatesFocus}
*/
export const fastAnchor = Anchor.compose({
baseName: "anchor",
template,
styles,
shadowOptions: {
delegatesFocus: true,
},
});
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Direction, RtlScrollConverter } from "@microsoft/fast-web-utilities";
import addons from "@storybook/addons";
import { STORY_RENDERED } from "@storybook/core-events";
import { AnchoredRegion as FoundationAnchoredRegion } from "@microsoft/fast-foundation";
import AnchoredRegionTemplate from "./fixtures/base.html";
import type { FASTAnchoredRegion } from "./index";
import "./index";

let scalingViewportPreviousXValue: number = 250;
Expand Down Expand Up @@ -67,14 +67,14 @@ addons.getChannel().addListener(STORY_RENDERED, (name: string) => {

const regionScalingUpdate = document.getElementById(
"region-scaling-update"
) as FASTAnchoredRegion;
) as FoundationAnchoredRegion;
document
.getElementById("viewport-scaling-update")!
.addEventListener("scroll", () => regionScalingUpdate.update());

const regionScalingOffset = document.getElementById(
"region-scaling-offset"
) as FASTAnchoredRegion;
) as FoundationAnchoredRegion;
document
.getElementById("viewport-scaling-offset")
?.addEventListener("scroll", (e: MouseEvent) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { css } from "@microsoft/fast-element";

export const AnchoredRegionStyles = css`
export const anchoredRegionStyles = (context, definition) => css`
:host {
contain: layout;
display: block;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,23 @@
import { customElement } from "@microsoft/fast-element";
import {
AnchoredRegion,
AnchoredRegionTemplate as template,
anchoredRegionTemplate as template,
} from "@microsoft/fast-foundation";
import { AnchoredRegionStyles as styles } from "./anchored-region.styles";
import { anchoredRegionStyles as styles } from "./anchored-region.styles";

/**
* The FAST AnchoredRegion Element. Implements {@link @microsoft/fast-foundation#AnchoredRegion},
* {@link @microsoft/fast-foundation#AnchoredRegionTemplate}
* {@link @microsoft/fast-foundation#anchoredRegionTemplate}
*
*
* @beta
* @remarks
* HTML Element: \<fast-anchored-region\>
*/
@customElement({
name: "fast-anchored-region",
export const fastAnchoredRegion = AnchoredRegion.compose({
baseName: "anchored-region",
template,
styles,
})
export class FASTAnchoredRegion extends AnchoredRegion {}
});

/**
* Styles for AnchoredRegion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import { css } from "@microsoft/fast-element";
import { display } from "@microsoft/fast-foundation";
import { accentForegroundRestBehavior, heightNumber } from "../styles/index";

export const BadgeStyles = css`
export const badgeStyles = (context, definition) =>
css`
${display("inline-block")} :host {
box-sizing: border-box;
font-family: var(--body-font);
Expand Down
14 changes: 6 additions & 8 deletions packages/web-components/fast-components/src/badge/index.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
import { customElement } from "@microsoft/fast-element";
import { Badge, BadgeTemplate as template } from "@microsoft/fast-foundation";
import { BadgeStyles as styles } from "./badge.styles";
import { Badge, badgeTemplate as template } from "@microsoft/fast-foundation";
import { badgeStyles as styles } from "./badge.styles";

/**
* The FAST Badge Element. Implements {@link @microsoft/fast-foundation#Badge},
* {@link @microsoft/fast-foundation#BadgeTemplate}
* {@link @microsoft/fast-foundation#badgeTemplate}
*
*
* @public
* @remarks
* HTML Element: \<fast-badge\>
*/
@customElement({
name: "fast-badge",
export const fastBadge = Badge.compose({
baseName: "badge",
template,
styles,
})
export class FASTBadge extends Badge {}
});

/**
* Styles for Badge
Expand Down
Loading

0 comments on commit 0fe93ec

Please sign in to comment.