Skip to content

Commit

Permalink
[web-components] update components to extend foundation element (#18187)
Browse files Browse the repository at this point in the history
* update accordion to use foundation element

* update anchor to extend foundation element

* update anchored region to extend foundation element

* correct style exports

* update badge to extend foundation

* update breadcrumb to extend foundation element

* update button to extend foundation element

* update checkbox to extend foundation element

* update combobox to extend foundation element

* update dialog to extend foundation element

* update divider styles

* update flipper to extend foundation element

* update horizontal scroll to extend foundation element

* update listbox to extend foundation element

* update listbox option to extend foundation element

* update naming for exported registries

* update menu and menu item to extend foundation

* aupdate number field to extend foundation element

* update progress to extend foundation element

* update radio, radiogroup and select to extend foundation el

* update skeleton to extend foundation element

* update slider to extend foundation element

* update switch to extend foundation component

* correct prefix for export names

* update text area to extend foundation element

* update text field to extend foundation

* update tooltip to extend foundation element

* update tree view to extend foundation element

* update comments v1

* export all custom element definitions

* exportfluent design system and definitions from rollup

* add data grid

* update fast to fluent in rollup

* add beta package to start updating w/ foundation element

* update stories files

* Change files
  • Loading branch information
chrisdholt committed Jul 2, 2021
1 parent 936b451 commit ff89874
Show file tree
Hide file tree
Showing 134 changed files with 3,122 additions and 3,430 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"type": "major",
"packageName": "@fluentui/web-components",
"email": "chhol@microsoft.com",
"dependentChangeType": "patch"
}
2 changes: 1 addition & 1 deletion packages/web-components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
"dependencies": {
"@microsoft/fast-colors": "^5.1.0",
"@microsoft/fast-element": "^1.0.0",
"@microsoft/fast-foundation": "^1.16.0",
"@microsoft/fast-foundation": "2.0.0-beta.0",
"lodash-es": "^4.17.20",
"tslib": "^1.13.0"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ import {
} from '../../styles/';
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 @@ -122,15 +123,15 @@ export const AccordionItemStyles = css`
z-index: 2;
}
`.withBehaviors(
accentFillRestBehavior,
neutralDividerRestBehavior,
neutralForegroundActiveBehavior,
neutralForegroundFocusBehavior,
neutralForegroundRestBehavior,
neutralForegroundHoverBehavior,
neutralFocusBehavior,
forcedColorsStylesheetBehavior(
css`
accentFillRestBehavior,
neutralDividerRestBehavior,
neutralForegroundActiveBehavior,
neutralForegroundFocusBehavior,
neutralForegroundRestBehavior,
neutralForegroundHoverBehavior,
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};
Expand All @@ -139,5 +140,5 @@ export const AccordionItemStyles = css`
fill: ${SystemColors.ButtonText};
}
`,
),
);
),
);
16 changes: 7 additions & 9 deletions packages/web-components/src/accordion/accordion-item/index.ts
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 } from '@microsoft/fast-foundation';
import { AccordionItemStyles as styles } from './accordion-item.styles';
import { AccordionItem, accordionItemTemplate as template } from '@microsoft/fast-foundation';
import { accordionItemStyles as styles } from './accordion-item.styles';

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

/**
* Styles for AccordionItem
* @public
*/
export const AccordionItemStyles = styles;
export const accordionItemStyles = styles;
9 changes: 1 addition & 8 deletions packages/web-components/src/accordion/accordion.stories.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
import { FluentDesignSystemProvider } from '../design-system-provider';
import Examples from './fixtures/base.html';
import { FluentAccordionItem } from './accordion-item';
import { FluentAccordion } from '.';

// Prevent tree-shaking
FluentAccordion;
FluentAccordionItem;
FluentDesignSystemProvider;
import './index';

export default {
title: 'Accordion',
Expand Down
23 changes: 12 additions & 11 deletions packages/web-components/src/accordion/accordion.styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@ import { css } from '@microsoft/fast-element';
import { display } from '@microsoft/fast-foundation';
import { accentFillRestBehavior, neutralDividerRestBehavior, neutralForegroundRestBehavior } from '../styles/';

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(accentFillRestBehavior, 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(accentFillRestBehavior, neutralDividerRestBehavior, neutralForegroundRestBehavior);
21 changes: 8 additions & 13 deletions packages/web-components/src/accordion/index.ts
Original file line number Diff line number Diff line change
@@ -1,30 +1,25 @@
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 FluentUI Accordion Element. Implements {@link @microsoft/fast-foundation#Accordion},
* {@link @microsoft/fast-foundation#AccordionTemplate}
* The Fluent Accordion Element. Implements {@link @microsoft/fast-foundation#Accordion},
* {@link @microsoft/fast-foundation#accordionTemplate}
*
*
* @public
* @remarks
* HTML Element: \<fluent-accordion\>
*/
@customElement({
name: 'fluent-accordion',
export const fluentAccordion = Accordion.compose({
baseName: 'accordion',
template,
styles,
shadowOptions: {
mode: 'closed',
},
})
export class FluentAccordion extends Accordion {}
});

/**
* Styles for Accordion
* @public
*/
export const AccordionStyles = styles;
export const accordionStyles = styles;
7 changes: 1 addition & 6 deletions packages/web-components/src/anchor/anchor.stories.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
import { FluentDesignSystemProvider } from '../design-system-provider';
import AnchorTemplate from './fixtures/anchor.html';
import { FluentAnchor } from './';

// Prevent tree-shaking
FluentAnchor;
FluentDesignSystemProvider;
import './index';

export default {
title: 'Anchor',
Expand Down
19 changes: 10 additions & 9 deletions packages/web-components/src/anchor/anchor.styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@ import {
} from '../styles/';
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: 27 additions & 23 deletions packages/web-components/src/anchor/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
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,26 +10,10 @@ import { AnchorStyles as styles } from './anchor.styles';
export type AnchorAppearance = ButtonAppearance | 'hypertext';

/**
* The Fluent Anchor Element. Implements {@link @microsoft/fast-foundation#Anchor},
* {@link @microsoft/fast-foundation#AnchorTemplate}
*
*
* @public
* @remarks
* HTML Element: \<fluent-anchor\>
*
* {@link https://developer.mozilla.org/en-US/docs/Web/API/ShadowRoot/delegatesFocus | delegatesFocus}
* The Fluent version of Anchor
* @internal
*/
@customElement({
name: 'fluent-anchor',
template,
styles,
shadowOptions: {
delegatesFocus: true,
mode: 'closed',
},
})
export class FluentAnchor extends Anchor {
export class Anchor extends FoundationAnchor {
/**
* The appearance the anchor should have.
*
Expand Down Expand Up @@ -77,4 +61,24 @@ export class FluentAnchor extends Anchor {
* Styles for Anchor
* @public
*/
export const AnchorStyles = styles;
export const anchorStyles = styles;

/**
* The Fluent Anchor Element. Implements {@link @microsoft/fast-foundation#Anchor},
* {@link @microsoft/fast-foundation#anchorTemplate}
*
*
* @public
* @remarks
* HTML Element: \<fluent-anchor\>
*
* {@link https://developer.mozilla.org/en-US/docs/Web/API/ShadowRoot/delegatesFocus | delegatesFocus}
*/
export const fluentAnchor = Anchor.compose({
baseName: 'anchor',
template,
styles,
shadowOptions: {
delegatesFocus: true,
},
});
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
import { STORY_RENDERED } from '@storybook/core-events';
import addons from '@storybook/addons';
import { Direction, RtlScrollConverter } from '@microsoft/fast-web-utilities';
import { FluentDesignSystemProvider } from '../design-system-provider';
import { FluentAnchoredRegion } from '../anchored-region';
import { AnchoredRegion } from '@microsoft/fast-foundation';
import AnchoreRegionTemplate from './fixtures/base.html';

// Prevent tree-shaking
FluentAnchoredRegion;
FluentDesignSystemProvider;
import './index';

let scalingViewportPreviousXValue: number = 250;
let scalingViewportPreviousYValue: number = 250;
Expand Down Expand Up @@ -45,7 +41,7 @@ function scrollViewports(): void {
function handleScrollViaUpdate(ev: Event): void {
if (ev.target instanceof HTMLElement) {
const scalingRegionUpdate: HTMLElement | null = document.getElementById('region-scaling-update');
if (scalingRegionUpdate instanceof FluentAnchoredRegion) {
if (scalingRegionUpdate instanceof AnchoredRegion) {
(scalingRegionUpdate as any).update();
}
}
Expand All @@ -56,7 +52,7 @@ function handleScrollViaOffset(ev: Event): void {
const scroller: HTMLElement = ev.target as HTMLElement;

const scalingRegionOffset: HTMLElement | null = document.getElementById('region-scaling-offset');
if (scalingRegionOffset instanceof FluentAnchoredRegion) {
if (scalingRegionOffset instanceof AnchoredRegion) {
(scalingRegionOffset as any).updateAnchorOffset(
scalingViewportPreviousXValue - scroller.scrollLeft,
scalingViewportPreviousYValue - scroller.scrollTop,
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
16 changes: 7 additions & 9 deletions packages/web-components/src/anchored-region/index.ts
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 } from '@microsoft/fast-foundation';
import { AnchoredRegionStyles as styles } from './anchored-region.styles';
import { AnchoredRegion, anchoredRegionTemplate as template } from '@microsoft/fast-foundation';
import { anchoredRegionStyles as styles } from './anchored-region.styles';

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

/**
* Styles for AnchoredRegion
* @public
*/
export const AnchoredRegionStyles = styles;
export const anchoredRegionStyles = styles;
8 changes: 0 additions & 8 deletions packages/web-components/src/badge/badge.spec.ts

This file was deleted.

7 changes: 1 addition & 6 deletions packages/web-components/src/badge/badge.stories.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
import { FluentDesignSystemProvider } from '../design-system-provider';
import BadgeTemplate from './fixtures/badge.html';
import { FluentBadge } from './';

// Prevent tree-shaking
FluentBadge;
FluentDesignSystemProvider;
import './index';

export default {
title: 'Badge',
Expand Down
Loading

0 comments on commit ff89874

Please sign in to comment.