Skip to content

Commit

Permalink
(web-components) create recipes and update component styles to levera…
Browse files Browse the repository at this point in the history
…ge tokens (#18226)

* add design tokens

* update accordion and accordiioin item to use tokens

* update badge with tokens

* update breadcrumb and breadcrumb item to use tokens

* add button tokens and add elevated corner radius token

* update card with elevated corner radius token

* update checkbox to use tokens

* update combobox to use tokens

* update data grid to use tokens

* update dialog to use tokens

* update divider to use tokens

* update flipper to use tokens

* update listbox and listbox option to use tokens

* update menu and menu item to use tokens

* update number field to use tokens

* update progress and progress ring to use tokens

* update radio and radio group to use tokens

* update select styles to use tokens

* update skeleton to use tokens

* update slider and slider label to use tokens

* update button pattern to use tokens

* update base button styles to use tokens

* update input fill state styles

* update switch to use tokens

* update tabs to use tokens

* update text area to use tokens

* update text field to use tokens

* add neutral contrast fill recipe and algo

* update tooltip to leverage tokens

* update tree view to use tokens

* update API report

* update default luminance to light mode

* update outlineWidth tokens

* update storybook

* update default token values and register fluent name

* fix eslint and update to use findResponsibleContainer

* Change files

* disable disallowedChangeTypes for beachball major versioning

* fix broken stories
  • Loading branch information
chrisdholt committed Jul 2, 2021
1 parent 41c289d commit 888bb39
Show file tree
Hide file tree
Showing 54 changed files with 6,843 additions and 7,354 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "major",
"comment": "create recipes and tokens on DI and update components to leverage tokens",
"packageName": "@fluentui/web-components",
"email": "[email protected]",
"dependentChangeType": "patch"
}
1 change: 1 addition & 0 deletions packages/web-components/.storybook/manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ import { addons } from '@storybook/addons';
import theme from './theme';

addons.setConfig({
enableShortcuts: false,
theme,
});
7 changes: 7 additions & 0 deletions packages/web-components/.storybook/preview.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import * as Fluent from '../src/index-rollup';

Fluent;

export const parameters = {
layout: 'fullscreen',
};
2 changes: 1 addition & 1 deletion packages/web-components/api-extractor.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

"docModel": {
"enabled": true,
"apiJsonFilePath": "dist/fast-components-msft.api.json"
"apiJsonFilePath": "dist/fluent-web-components.api.json"
},

"dtsRollup": {
Expand Down
20 changes: 15 additions & 5 deletions packages/web-components/docs/api-report.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ import { TabPanel } from '@microsoft/fast-foundation';
import { Tabs } from '@microsoft/fast-foundation';
import { TextArea as TextArea_2 } from '@microsoft/fast-foundation';
import { TextField as TextField_2 } from '@microsoft/fast-foundation';
import { Tooltip } from '@microsoft/fast-foundation';
import { Tooltip as Tooltip_2 } from '@microsoft/fast-foundation';
import { TreeItem } from '@microsoft/fast-foundation';
import { TreeView } from '@microsoft/fast-foundation';

Expand Down Expand Up @@ -260,10 +260,10 @@ export type BadgeAppearance = 'accent' | 'lightweight' | 'neutral' | string;
// @public
export const badgeStyles: (context: any, definition: any) => import("@microsoft/fast-element").ElementStyles;

// Warning: (ae-internal-missing-underscore) The name "BaseButtonStyles" should be prefixed with an underscore because the declaration is marked as @internal
// Warning: (ae-internal-missing-underscore) The name "baseButtonStyles" should be prefixed with an underscore because the declaration is marked as @internal
//
// @internal (undocumented)
export const BaseButtonStyles: ElementStyles;
export const baseButtonStyles: (context: any, definition: any) => ElementStyles;

// @public
export const breadcrumbItemStyles: (context: any, definition: any) => import("@microsoft/fast-element").ElementStyles;
Expand Down Expand Up @@ -469,10 +469,10 @@ export const dividerStyles: (context: any, definition: any) => import("@microsof
// @public
export const elevation: string;

// Warning: (ae-internal-missing-underscore) The name "FillStateStyles" should be prefixed with an underscore because the declaration is marked as @internal
// Warning: (ae-internal-missing-underscore) The name "fillStateStyles" should be prefixed with an underscore because the declaration is marked as @internal
//
// @internal (undocumented)
export const FillStateStyles: ElementStyles;
export const fillStateStyles: (context: any, definition: any) => ElementStyles;

// @public
export const flipperStyles: (context: any, definition: any) => import("@microsoft/fast-element").ElementStyles;
Expand Down Expand Up @@ -1095,6 +1095,8 @@ export const fluentTextField: (overrideDefinition?: import("@microsoft/fast-foun
};
}, typeof TextField>;

// Warning: (ae-incompatible-release-tags) The symbol "fluentTooltip" is marked as @public, but its signature references "Tooltip" which is marked as @internal
//
// @public
export const fluentTooltip: (overrideDefinition?: import("@microsoft/fast-foundation").OverrideFoundationElementDefinition<{
baseName: string;
Expand Down Expand Up @@ -1715,6 +1717,14 @@ export type TextFieldAppearance = 'filled' | 'outline';
// @public
export const textFieldStyles: (context: any, definition: any) => import("@microsoft/fast-element").ElementStyles;

// Warning: (ae-internal-missing-underscore) The name "Tooltip" should be prefixed with an underscore because the declaration is marked as @internal
//
// @internal
export class Tooltip extends Tooltip_2 {
// (undocumented)
connectedCallback(): void;
}

// @public
export const treeItemStyles: (context: any, definition: any) => import("@microsoft/fast-element").ElementStyles;

Expand Down
10 changes: 6 additions & 4 deletions packages/web-components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
"main": "dist/esm/index.js",
"types": "dist/web-components.d.ts",
"unpkg": "dist/web-components.min.js",
"beachball": {
"disallowedChangeTypes": []
},
"scripts": {
"clean": "node ./build/clean.js dist",
"doc": "api-extractor run --local",
Expand Down Expand Up @@ -49,10 +52,9 @@
"devDependencies": {
"@microsoft/eslint-config-fast-dna": "^1.2.0",
"@microsoft/api-extractor": "7.7.1",
"@storybook/addons": "^5.3.8",
"@storybook/cli": "^5.3.8",
"@storybook/html": "^5.3.8",
"@storybook/theming": "^5.3.8",
"@storybook/addons": "^6.1.17",
"@storybook/html": "^6.1.17",
"@storybook/theming": "^6.1.17",
"@types/chai": "^4.2.11",
"@types/chai-spies": "^1.0.1",
"@types/karma": "^5.0.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,34 @@ import { css } from '@microsoft/fast-element';
import { display, focusVisible, forcedColorsStylesheetBehavior } from '@microsoft/fast-foundation';
import { SystemColors } from '@microsoft/fast-web-utilities';
import {
accentFillRestBehavior,
neutralDividerRestBehavior,
neutralFocusBehavior,
neutralForegroundActiveBehavior,
neutralForegroundFocusBehavior,
neutralForegroundHoverBehavior,
neutralForegroundRestBehavior,
} from '../../styles/';
accentFillRest,
bodyFont,
density,
designUnit,
focusOutlineWidth,
neutralDivider,
neutralFocus,
neutralForegroundRest,
outlineWidth,
typeRampMinus1FontSize,
typeRampMinus1LineHeight,
} from '../../design-tokens';
import { heightNumber } from '../../styles/size';

export const accordionItemStyles = (context, definition) =>
css`
${display('flex')} :host {
box-sizing: border-box;
font-family: var(--body-font);
font-family: ${bodyFont};
flex-direction: column;
font-size: var(--type-ramp-minus-1-font-size);
line-height: var(--type-ramp-minus-1-line-height);
border-bottom: calc(var(--outline-width) * 1px) solid ${neutralDividerRestBehavior.var};
font-size: ${typeRampMinus1FontSize};
line-height: ${typeRampMinus1LineHeight};
border-bottom: calc(${outlineWidth} * 1px) solid ${neutralDivider};
}
.region {
display: none;
padding: calc((6 + (var(--design-unit) * 2 * var(--density))) * 1px);
padding: calc((6 + (${designUnit} * 2 * ${density})) * 1px);
}
.heading {
Expand All @@ -42,20 +46,17 @@ export const accordionItemStyles = (context, definition) =>
grid-column: 2;
grid-row: 1;
outline: none;
padding: 0 calc((6 + (var(--design-unit) * 2 * var(--density))) * 1px);
padding: 0 calc((6 + (${designUnit} * 2 * ${density})) * 1px);
text-align: left;
height: calc(${heightNumber} * 1px);
color: ${neutralForegroundRestBehavior.var};
color: ${neutralForegroundRest};
cursor: pointer;
font-family: inherit;
}
.button:hover {
color: ${neutralForegroundHoverBehavior.var};
}
.button:hover,
.button:active {
color: ${neutralForegroundActiveBehavior.var};
color: ${neutralForegroundRest};
}
.button::before {
Expand All @@ -71,9 +72,9 @@ export const accordionItemStyles = (context, definition) =>
.button:${focusVisible}::before {
outline: none;
border: calc(var(--outline-width) * 1px) solid ${neutralFocusBehavior.var};
box-shadow: 0 0 0 calc((var(--focus-outline-width) - var(--outline-width)) * 1px)
${neutralFocusBehavior.var};
border: calc(${outlineWidth} * 1px) solid ${neutralFocus};
box-shadow: 0 0 0 calc((${focusOutlineWidth} - ${outlineWidth}) * 1px)
${neutralFocus};
}
:host(.expanded) .region {
Expand All @@ -87,7 +88,7 @@ export const accordionItemStyles = (context, definition) =>
grid-column: 4;
z-index: 2;
pointer-events: none;
fill: ${accentFillRestBehavior.var};
fill: ${accentFillRest};
}
slot[name="collapsed-icon"] {
Expand All @@ -109,7 +110,7 @@ export const accordionItemStyles = (context, definition) =>
.start {
display: flex;
align-items: center;
padding-inline-start: calc(var(--design-unit) * 1px);
padding-inline-start: calc(${designUnit} * 1px);
justify-content: center;
grid-column: 1;
z-index: 2;
Expand All @@ -123,18 +124,11 @@ export const accordionItemStyles = (context, definition) =>
z-index: 2;
}
`.withBehaviors(
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};
box-shadow: 0 0 0 calc((${focusOutlineWidth} - ${outlineWidth}) * 1px) ${SystemColors.Highlight};
}
.icon {
fill: ${SystemColors.ButtonText};
Expand Down
21 changes: 14 additions & 7 deletions packages/web-components/src/accordion/accordion.styles.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
import { css } from '@microsoft/fast-element';
import { display } from '@microsoft/fast-foundation';
import { accentFillRestBehavior, neutralDividerRestBehavior, neutralForegroundRestBehavior } from '../styles/';
import {
bodyFont,
neutralDivider,
neutralForegroundRest,
outlineWidth,
typeRampMinus1FontSize,
typeRampMinus1LineHeight,
} from '../design-tokens';

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};
font-family: ${bodyFont};
font-size: ${typeRampMinus1FontSize};
line-height: ${typeRampMinus1LineHeight};
color: ${neutralForegroundRest};
border-top: calc(${outlineWidth} * 1px) solid ${neutralDivider};
}
`.withBehaviors(accentFillRestBehavior, neutralDividerRestBehavior, neutralForegroundRestBehavior);
`;
4 changes: 2 additions & 2 deletions packages/web-components/src/anchor/anchor.styles.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { css } from '@microsoft/fast-element';
import {
AccentButtonStyles,
BaseButtonStyles,
baseButtonStyles,
HypertextStyles,
LightweightButtonStyles,
OutlineButtonStyles,
Expand All @@ -11,7 +11,7 @@ import { appearanceBehavior } from '../utilities/behaviors';

export const anchorStyles = (context, definition) =>
css`
${BaseButtonStyles}
${baseButtonStyles(context, definition)}
`.withBehaviors(
appearanceBehavior('accent', AccentButtonStyles),
appearanceBehavior('hypertext', HypertextStyles),
Expand Down
42 changes: 21 additions & 21 deletions packages/web-components/src/badge/badge.styles.ts
Original file line number Diff line number Diff line change
@@ -1,44 +1,44 @@
import { css } from '@microsoft/fast-element';
import { display } from '@microsoft/fast-foundation';
import {
accentFillRestBehavior,
accentForegroundCutRestBehavior,
neutralFillRestBehavior,
neutralForegroundRestBehavior,
} from '../styles';
accentForegroundRest,
bodyFont,
cornerRadius,
designUnit,
neutralForegroundRest,
typeRampMinus1FontSize,
typeRampMinus1LineHeight,
neutralFillRest,
accentForegroundCut,
} from '../design-tokens';

export const badgeStyles = (context, definition) =>
css`
${display('inline-block')} :host {
box-sizing: border-box;
font-family: var(--body-font);
font-size: var(--type-ramp-minus-1-font-size);
line-height: var(--type-ramp-minus-1-height);
font-family: ${bodyFont};
font-size: ${typeRampMinus1FontSize};
line-height: ${typeRampMinus1LineHeight};
}
.control {
border-radius: calc(var(--corner-radius) * 1px);
padding: calc(var(--design-unit) * 0.5px) calc(var(--design-unit) * 1px);
border-radius: calc(${cornerRadius} * 1px);
padding: calc(${designUnit} * 0.5px) calc(${designUnit} * 1px);
}
:host(.lightweight) .control {
background: transparent;
color: ${neutralForegroundRestBehavior.var};
color: ${neutralForegroundRest};
font-weight: 600;
}
:host(.accent) .control {
background: ${accentFillRestBehavior.var};
color: ${accentForegroundCutRestBehavior.var};
background: ${accentForegroundRest};
color: ${accentForegroundCut};
}
:host(.neutral) .control {
background: ${neutralFillRestBehavior.var};
color: ${neutralForegroundRestBehavior.var};
background: ${neutralFillRest};
color: ${neutralForegroundRest};
}
`.withBehaviors(
accentFillRestBehavior,
accentForegroundCutRestBehavior,
neutralFillRestBehavior,
neutralForegroundRestBehavior,
);
`;
Loading

0 comments on commit 888bb39

Please sign in to comment.