Skip to content

vNext: update components to extend FoundationElement #4570

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

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
28a0ffd
support foundation element on accordion and accordion item
chrisdholt Apr 5, 2021
c303614
update anchor to use foundation element
chrisdholt Apr 5, 2021
f4b60b6
update AnchoredRegion to extend FoundationElement
chrisdholt Apr 5, 2021
ee1faf5
update Badge to extend FoundationElement
chrisdholt Apr 5, 2021
1df5ee1
update breadcrumb and breadcrumb item to extend FoundationElement
chrisdholt Apr 5, 2021
a609ea0
update Button to extend FoundationElement
chrisdholt Apr 5, 2021
deb09be
update checkbox to extend from FoundationElement
chrisdholt Apr 5, 2021
2361b0a
update Dialog to extend FoundationElement
chrisdholt Apr 6, 2021
aa005e4
update disclosure to extend FoundationElement
chrisdholt Apr 6, 2021
5972cb7
update divider to extend FoundationElement
chrisdholt Apr 6, 2021
e6f3f73
update Flipper to extend FoundationElement
chrisdholt Apr 6, 2021
333cecc
update horizontal scroll to extend FoundationElement
chrisdholt Apr 6, 2021
ddf9ff9
update Listbox and ListboxOption to extend FoundationElement
chrisdholt Apr 6, 2021
02cbfcf
update combobox to extend FoundationElement
chrisdholt Apr 6, 2021
536387d
update select to extend combobox and update tests
chrisdholt Apr 6, 2021
1c6f1d6
fix listbox option styles and export
chrisdholt Apr 6, 2021
270eb3e
update tests (wip)
chrisdholt Apr 6, 2021
65272f2
update Menu and MenuItem to extend FoundationElement
chrisdholt Apr 6, 2021
7494984
update number field to extend FoundationElement
chrisdholt Apr 6, 2021
a081717
update base name values
chrisdholt Apr 6, 2021
63adf59
fix: prevent the mixin helper from copying over constructor properties
Apr 7, 2021
2161262
feat: fixture ergonomic improvements for foundation elements
Apr 7, 2021
c4d22e8
test: fix Anchor and associated unit tests based on new system
Apr 7, 2021
b6a43f5
remove incorrect tagFor usage
chrisdholt Apr 7, 2021
55708e2
update radio and radiogroup
chrisdholt Apr 7, 2021
118fe6c
update skeleton
chrisdholt Apr 7, 2021
8ce6c69
update slider and slider label
chrisdholt Apr 7, 2021
85d6ec9
update switch
chrisdholt Apr 7, 2021
cc092cc
update tabs et all to use FoundationElement
chrisdholt Apr 7, 2021
a89446d
update text area and text field to use foundation el
chrisdholt Apr 7, 2021
628ec9b
Update tooltip to use FoundationElement
chrisdholt Apr 7, 2021
8244a97
update tests and tree item and view
chrisdholt Apr 7, 2021
a97c0a3
remove website from lerna packages in favor of npm registry to preven…
chrisdholt Apr 7, 2021
ba42bc0
update progress and progress ring to use Foundation element
chrisdholt Apr 7, 2021
40fe7f7
fixing the tests
chrisdholt Apr 8, 2021
eac1189
feat: enable fixtures to handle N foundation elements and custom system
Apr 8, 2021
390520f
fixing tests!
chrisdholt Apr 9, 2021
5aa218a
Change files
chrisdholt Apr 9, 2021
cba6989
fix errors in fast-website
chrisdholt Apr 9, 2021
c782af1
update typings for explorer
chrisdholt Apr 9, 2021
dbdef28
update naming convention to lowercase fast
chrisdholt Apr 19, 2021
856974d
update imports for sites
chrisdholt Apr 19, 2021
2fab56a
Change files
chrisdholt Apr 19, 2021
48d9077
update template names to lowercase
chrisdholt Apr 20, 2021
f3b18c0
update style casing and apply updates to component registries
chrisdholt Apr 20, 2021
3695a75
update tsdoc links for templates
chrisdholt Apr 20, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Expand Up @@ -2,26 +2,26 @@
import h from "../../utilities/web-components/pragma"; /* Note: Import wrapped createElement. */

import React from "react";
import {
fastCheckbox,
fastNumberField,
fastOption,
fastSelect,
fastTextField,
} from "@microsoft/fast-components";
import {
RenderRefControlConfig,
RenderSelectControlConfig,
} from "./control.css.utilities.props";
import {
FASTCheckbox,
FASTNumberField,
FASTOption,
FASTSelect,
FASTTextField,
} from "@microsoft/fast-components";
import { FASTColorPicker } from "./css";
/**
* 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\>
Copy link
Contributor

Choose a reason for hiding this comment

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

We'll probably want to change the comments on these since this is not exporting an element but exporting a factory for a component registration.

Copy link
Member Author

Choose a reason for hiding this comment

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

@EisenbergEffect @nicholasrice thoughts on the comment syntax and what we should include for these?

Copy link
Contributor

Choose a reason for hiding this comment

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

@nicholasrice How should we handle the comments in this case? We probably needs a new comment for the function that says something like "Creates a component registration for fast-accordion-item usable with the DesignSystem." Thoughts?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think that works, but I'd make sure that the DesignSystem reference is an {@link @micorosoft/fast-foundation:DesignSystem} so that our docs are referential. Or perhaps we have a link to a new tutorial-like section on how to use these definitions. Maybe both?

Copy link
Member Author

Choose a reason for hiding this comment

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

Leaving these for a follow-up PR - but happy to make the updates

*/
@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