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

[web-components] update components to extend foundation element #18187

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
3c76dd5
update accordion to use foundation element
chrisdholt Apr 20, 2021
b39fe2f
update anchor to extend foundation element
chrisdholt Apr 20, 2021
1a8323b
update anchored region to extend foundation element
chrisdholt Apr 20, 2021
093f6a3
correct style exports
chrisdholt Apr 20, 2021
1d1e031
update badge to extend foundation
chrisdholt Apr 20, 2021
3b05f6b
update breadcrumb to extend foundation element
chrisdholt Apr 20, 2021
0882117
update button to extend foundation element
chrisdholt Apr 20, 2021
42b061d
update checkbox to extend foundation element
chrisdholt Apr 20, 2021
7408822
update combobox to extend foundation element
chrisdholt Apr 20, 2021
ac0e8ce
update dialog to extend foundation element
chrisdholt Apr 20, 2021
5fc4bac
update divider styles
chrisdholt Apr 20, 2021
d46ed4d
update flipper to extend foundation element
chrisdholt Apr 20, 2021
7a83214
update horizontal scroll to extend foundation element
chrisdholt Apr 20, 2021
a9cac3b
update listbox to extend foundation element
chrisdholt Apr 20, 2021
4961994
update listbox option to extend foundation element
chrisdholt Apr 20, 2021
3fc2c28
update naming for exported registries
chrisdholt Apr 20, 2021
012ca97
update menu and menu item to extend foundation
chrisdholt Apr 20, 2021
c2574a0
aupdate number field to extend foundation element
chrisdholt Apr 20, 2021
6716593
update progress to extend foundation element
chrisdholt Apr 20, 2021
3f7fe18
update radio, radiogroup and select to extend foundation el
chrisdholt Apr 20, 2021
dad0633
update skeleton to extend foundation element
chrisdholt Apr 20, 2021
1ce3bb5
update slider to extend foundation element
chrisdholt Apr 20, 2021
841c936
update switch to extend foundation component
chrisdholt Apr 20, 2021
59d8b60
correct prefix for export names
chrisdholt Apr 20, 2021
d19b0df
update text area to extend foundation element
chrisdholt Apr 20, 2021
143e8f3
update text field to extend foundation
chrisdholt Apr 21, 2021
f5ffe56
update tooltip to extend foundation element
chrisdholt Apr 21, 2021
25bf211
update tree view to extend foundation element
chrisdholt Apr 21, 2021
29eb86a
update comments v1
chrisdholt Apr 21, 2021
4869d0e
export all custom element definitions
chrisdholt Apr 26, 2021
2d2642b
exportfluent design system and definitions from rollup
chrisdholt Apr 26, 2021
5845f1c
add data grid
chrisdholt Apr 26, 2021
37bd5fa
update fast to fluent in rollup
chrisdholt Apr 26, 2021
abd5ede
add beta package to start updating w/ foundation element
chrisdholt May 14, 2021
adc711d
update stories files
chrisdholt May 14, 2021
153a408
Change files
chrisdholt May 14, 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,6 @@
{
"type": "major",
"packageName": "@fluentui/web-components",
"email": "[email protected]",
"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