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

Adding web component Tabs, Tab and TabPanel #27167

Merged
Merged
Show file tree
Hide file tree
Changes from 94 commits
Commits
Show all changes
102 commits
Select commit Hold shift + click to select a range
1366138
adding tab list spec
bearcat-msft Feb 23, 2023
35e8769
adding files for tab list, tab, and tab-panel
bearcat-msft Feb 23, 2023
bc2ef11
adding files for tab list, tab, and tab-panel
bearcat-msft Feb 23, 2023
425c969
adding tab
bearcat-msft Feb 24, 2023
a88d993
fixing merge conflict
bearcat-msft Feb 24, 2023
b5bdd4a
working tab list web components. no styling. no re-referencing of att…
bearcat-msft Feb 24, 2023
16d3d34
adding styling for tabList
bearcat-msft Feb 27, 2023
6c42437
commenting out unused styling
bearcat-msft Feb 27, 2023
45df501
adding tab-list styles
bearcat-msft Mar 1, 2023
6814462
basic api working. styling not correct in all cases.
bearcat-msft Mar 1, 2023
9dd933b
Adding svgs. they are not rendering for some reason
bearcat-msft Mar 1, 2023
8fffe27
svgs working
bearcat-msft Mar 1, 2023
630d44e
updating styling
bearcat-msft Mar 2, 2023
9858609
removing fill on svg
bearcat-msft Mar 3, 2023
f7709eb
Merge branch 'web-components-v3' of https://github.com/microsoft/flue…
bearcat-msft Mar 3, 2023
3045064
adding logic to track tab selection and css variables. broken
bearcat-msft Mar 7, 2023
787a4bf
commit before refactor
bearcat-msft Mar 8, 2023
3adac60
addint html data attr
bearcat-msft Mar 8, 2023
3c4c019
updating how tab data is handled
bearcat-msft Mar 8, 2023
65d0134
Animations not working
bearcat-msft Mar 8, 2023
637917f
animations not working
bearcat-msft Mar 8, 2023
9678764
broken animation
bearcat-msft Mar 9, 2023
4830903
location of tab is not correct
bearcat-msft Mar 9, 2023
4500bef
refactoring dataActiveTabChanged
bearcat-msft Mar 9, 2023
29f3847
removing class field for current active tab
bearcat-msft Mar 9, 2023
9a9e16d
adding method to add and remove classes
bearcat-msft Mar 9, 2023
62d2f1c
tab animates to offset location
bearcat-msft Mar 10, 2023
2694e72
animating almost correctly
bearcat-msft Mar 10, 2023
828625a
horizontal animations working
bearcat-msft Mar 10, 2023
2618756
adding vertical positioning logic
bearcat-msft Mar 10, 2023
8335c28
tabs animations working vertical and horizontal
bearcat-msft Mar 10, 2023
1b2200a
Adding tab-list options. adding comments
bearcat-msft Mar 10, 2023
f276996
adjusting styling
bearcat-msft Mar 10, 2023
23b6b11
removing unused vars
bearcat-msft Mar 10, 2023
1ff575d
removing comments
bearcat-msft Mar 10, 2023
87aebb0
Merge branch 'web-components-v3' of https://github.com/microsoft/flue…
bearcat-msft Mar 10, 2023
12cd3db
Adding change file
bearcat-msft Mar 13, 2023
f950be4
updating readme. fixing naming conflict in exports of tab-panel index
bearcat-msft Mar 13, 2023
ae9c216
fixing default value for tablist size
bearcat-msft Mar 13, 2023
39b8572
removing check for activeid in setTabData
bearcat-msft Mar 13, 2023
7de8c8c
removing patch for removing activeIndicator
bearcat-msft Mar 13, 2023
61a7cdd
moving pointer events none to disabled fluent tab
bearcat-msft Mar 13, 2023
3088406
removing boolean converters, adding type consts, renaming TabList to …
bearcat-msft Mar 13, 2023
f955fa1
documenting difference between tabs and tab list
bearcat-msft Mar 13, 2023
b36e177
updating tabs index.js
bearcat-msft Mar 13, 2023
524e9e2
fixing circular dependency import
bearcat-msft Mar 13, 2023
de51c9d
Merge branch 'web-components-v3' of https://github.com/microsoft/flue…
bearcat-msft Mar 13, 2023
428e76f
removing references to TabList, renaming to Tabs. Removing Tabs orien…
bearcat-msft Mar 15, 2023
389f9b0
Refactoring tab into tabs
bearcat-msft Mar 16, 2023
1eb38bf
updating token names object
bearcat-msft Mar 16, 2023
69ec62a
updating css for tab token names
bearcat-msft Mar 16, 2023
00d7695
updating tab token names in tabs.ts
bearcat-msft Mar 16, 2023
456cbcf
removing unused vars
bearcat-msft Mar 16, 2023
842b491
Merge branch 'web-components-v3' of https://github.com/microsoft/flue…
bearcat-msft Mar 16, 2023
9ba818a
adding pseudo element to account for spacing difference of bold and u…
bearcat-msft Mar 21, 2023
906db51
adding placeholder element to render active indicator
bearcat-msft Mar 21, 2023
fe4968e
updating :focus-visible style
bearcat-msft Mar 21, 2023
a721863
removing unused vars
bearcat-msft Mar 21, 2023
6bb2271
adding tab-content span and 2px margin for tab-content span
bearcat-msft Mar 21, 2023
cf5ed8e
updating color foreground for unselected and selected tabs
bearcat-msft Mar 21, 2023
89ab608
removing unused var
bearcat-msft Mar 21, 2023
20a81b3
removing host-context
bearcat-msft Mar 22, 2023
4a2e5ea
removing tab content part
bearcat-msft Mar 22, 2023
e4a112d
putting back tab content part
bearcat-msft Mar 22, 2023
dc878be
removing unecessary dom element
bearcat-msft Mar 22, 2023
06f9081
removing unecessary z index
bearcat-msft Mar 22, 2023
7923495
adding tab-content class. removing tab-content part
bearcat-msft Mar 24, 2023
08b8ab4
adding display helper function to tab-panel
bearcat-msft Mar 24, 2023
122f266
shorthanding tab padding in tab styles
bearcat-msft Mar 24, 2023
9a3fec2
removing duplicate selector
bearcat-msft Mar 24, 2023
fbd99bb
fixing display helper implementation
bearcat-msft Mar 24, 2023
f25a4fa
removing divs in storybook.ts
bearcat-msft Mar 24, 2023
39f1b9f
removing divs from stories.ts
bearcat-msft Mar 24, 2023
cace80f
adding second display helper
bearcat-msft Mar 24, 2023
bcf095b
adding display helper in tab.styles
bearcat-msft Mar 24, 2023
b31e02e
removing stray div in stories.ts
bearcat-msft Mar 24, 2023
5dd9d27
adding display helper in tabs.styles
bearcat-msft Mar 24, 2023
1af7359
removing active indicator css
bearcat-msft Mar 24, 2023
629185a
removing important
bearcat-msft Mar 24, 2023
53cdf06
removing unused vars
bearcat-msft Mar 28, 2023
47fa9c1
renaming getSelectedTab to getTab, since tab is passed into method
bearcat-msft Mar 28, 2023
6ea7501
updating TabData
bearcat-msft Mar 28, 2023
e78cdad
updating check for previous tab for first render
bearcat-msft Mar 28, 2023
30726e8
replacing document add style with fast controller add style
bearcat-msft Mar 28, 2023
f7f7afd
grabbing scale and offset token names from const
bearcat-msft Mar 28, 2023
c62096c
updating stories, removing redundant code and renaming tabids
bearcat-msft Mar 29, 2023
c445244
using const objects to provide default values
bearcat-msft Mar 29, 2023
1c5aeae
Removing animation clear method. apparently not needed
bearcat-msft Mar 29, 2023
d792560
updating comments
bearcat-msft Mar 29, 2023
46d8786
removing duplicate display
bearcat-msft Mar 29, 2023
6521a4d
setting display to inline-flex
bearcat-msft Mar 29, 2023
0b5a80c
removing unnecessary disabled font-weight in tab
bearcat-msft Mar 29, 2023
a68577a
removing unnecessary outline
bearcat-msft Mar 29, 2023
f4998af
replacing margin-right with margin-inline-end
bearcat-msft Mar 29, 2023
2a68cfe
Reducing number of duplicarte border radius
bearcat-msft Mar 30, 2023
731debb
adding margin-inline-end
bearcat-msft Mar 30, 2023
b8dffde
Adding max width on tab content
bearcat-msft Apr 3, 2023
1da1150
Revert "Adding max width on tab content"
bearcat-msft Apr 3, 2023
f7efa9b
fixing focus visible border
bearcat-msft Apr 3, 2023
4dba12f
combining padding
bearcat-msft Apr 3, 2023
2969de4
Removing margin auto on right margin
bearcat-msft Apr 3, 2023
f5a3c83
Merge branch 'web-components-v3' into bearcat/tabListComponent
chrisdholt Apr 4, 2023
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": "prerelease",
"comment": "Adding TabList, Tab, and TabPanel web components",
"packageName": "@fluentui/web-components",
"email": "[email protected]",
"dependentChangeType": "patch"
}
3 changes: 3 additions & 0 deletions packages/web-components/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ export * from './image/index.js';
export * from './progress-bar/index.js';
export * from './spinner/index.js';
export * from './switch/index.js';
export * from './tabs/index.js';
export * from './tab/index.js';
export * from './tab-panel/index.js';
export * from './text/index.js';

export * from './theme/index.js';
4 changes: 4 additions & 0 deletions packages/web-components/src/tab-panel/define.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { FluentDesignSystem } from '../fluent-design-system.js';
import { definition } from './tab-panel.definition.js';

definition.define(FluentDesignSystem.registry);
4 changes: 4 additions & 0 deletions packages/web-components/src/tab-panel/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export * from './tab-panel.js';
export { template as TabPanelTemplate } from './tab-panel.template.js';
export { styles as TabPanelStyles } from './tab-panel.styles.js';
export { definition as TabPanelDefinition } from './tab-panel.definition.js';
10 changes: 10 additions & 0 deletions packages/web-components/src/tab-panel/tab-panel.definition.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { FluentDesignSystem } from '../fluent-design-system.js';
import { TabPanel } from './tab-panel.js';
import { template } from './tab-panel.template.js';
import { styles } from './tab-panel.styles.js';

export const definition = TabPanel.compose({
name: `${FluentDesignSystem.prefix}-tab-panel`,
template,
styles,
});
12 changes: 12 additions & 0 deletions packages/web-components/src/tab-panel/tab-panel.styles.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { css } from '@microsoft/fast-element';
import { display } from '@microsoft/fast-foundation';
import { spacingHorizontalM, spacingHorizontalMNudge } from '../theme/design-tokens.js';

export const styles = css`
${display('block')}

:host {
box-sizing: border-box;
padding: ${spacingHorizontalM} ${spacingHorizontalMNudge};
}
`;
3 changes: 3 additions & 0 deletions packages/web-components/src/tab-panel/tab-panel.template.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { tabPanelTemplate } from '@microsoft/fast-foundation';

export const template = tabPanelTemplate();
3 changes: 3 additions & 0 deletions packages/web-components/src/tab-panel/tab-panel.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { FASTTabPanel } from '@microsoft/fast-foundation';

export class TabPanel extends FASTTabPanel {}
4 changes: 4 additions & 0 deletions packages/web-components/src/tab/define.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { FluentDesignSystem } from '../fluent-design-system.js';
import { definition } from './tab.definition.js';

definition.define(FluentDesignSystem.registry);
4 changes: 4 additions & 0 deletions packages/web-components/src/tab/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export * from './tab.js';
export { template as TabTemplate } from './tab.template.js';
export { styles as TabStyles } from './tab.styles.js';
export { definition as TabDefinition } from './tab.definition.js';
10 changes: 10 additions & 0 deletions packages/web-components/src/tab/tab.definition.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { FluentDesignSystem } from '../fluent-design-system.js';
import { Tab } from './tab.js';
import { template } from './tab.template.js';
import { styles } from './tab.styles.js';

export const definition = Tab.compose({
name: `${FluentDesignSystem.prefix}-tab`,
template,
styles,
});
114 changes: 114 additions & 0 deletions packages/web-components/src/tab/tab.styles.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
import { css } from '@microsoft/fast-element';
import { display } from '@microsoft/fast-foundation';
import {
borderRadiusCircular,
borderRadiusMedium,
borderRadiusSmall,
colorCompoundBrandStroke,
colorNeutralForeground1,
colorNeutralForeground2,
colorNeutralForegroundDisabled,
colorNeutralStroke1Hover,
colorStrokeFocus1,
colorStrokeFocus2,
fontFamilyBase,
fontSizeBase300,
fontWeightSemibold,
lineHeightBase300,
spacingHorizontalM,
spacingHorizontalMNudge,
} from '../theme/design-tokens.js';

export const styles = css`
${display('inline-flex')}

:host {
position: relative;
flex-direction: column;
cursor: pointer;
box-sizing: border-box;
justify-content: center;
line-height: ${lineHeightBase300};
font-family: ${fontFamilyBase};
font-size: ${fontSizeBase300};
color: ${colorNeutralForeground2};
fill: currentcolor;
grid-row: 1;
padding: ${spacingHorizontalM} ${spacingHorizontalMNudge};
border-radius: ${borderRadiusMedium};
}
:host .tab-content {
display: inline-flex;
flex-direction: column;
padding: 0 2px;
}

:host([aria-selected='true']) {
color: ${colorNeutralForeground1};
}

:host([aria-selected='true']) {
bearcat-msft marked this conversation as resolved.
Show resolved Hide resolved
font-weight: ${fontWeightSemibold};
}

/* adds hidden textContent to prevent shifting ui on bold / unbolding of text */
:host .tab-content::after {
content: var(--textContent);
visibility: hidden;
height: 0;
line-height: ${lineHeightBase300};
font-weight: ${fontWeightSemibold};
}

:host([aria-selected='true'])::after {
background-color: ${colorCompoundBrandStroke};
bearcat-msft marked this conversation as resolved.
Show resolved Hide resolved
border-radius: ${borderRadiusCircular};
content: '';
inset: 0;
position: absolute;
z-index: 2;
}

:host([aria-selected='false']:hover)::after {
background-color: ${colorNeutralStroke1Hover};
border-radius: ${borderRadiusCircular};
content: '';
inset: 0;
position: absolute;
z-index: 1;
}

:host([aria-selected='true'][disabled])::after {
background-color: ${colorNeutralForegroundDisabled};
}

::slotted([slot='start']),
::slotted([slot='end']) {
display: flex;
}
::slotted([slot='start']) {
margin-inline-end: 11px;
}
::slotted([slot='end']) {
margin-inline-start: 11px;
}
:host([disabled]) {
cursor: not-allowed;
fill: ${colorNeutralForegroundDisabled};
color: ${colorNeutralForegroundDisabled};
}

:host([disabled]:hover)::after {
background-color: unset;
}

:host(:focus) {
outline: none;
}

:host(:focus-visible) {
bearcat-msft marked this conversation as resolved.
Show resolved Hide resolved
border-radius: ${borderRadiusSmall};
box-shadow: 0 0 0 2pt ${colorStrokeFocus2};
bearcat-msft marked this conversation as resolved.
Show resolved Hide resolved
outline: 1px solid ${colorStrokeFocus1};
}
`;
14 changes: 14 additions & 0 deletions packages/web-components/src/tab/tab.template.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { endSlotTemplate, FASTTab, startSlotTemplate, TabOptions } from '@microsoft/fast-foundation';
import { ElementViewTemplate, html } from '@microsoft/fast-element';

export function tabTemplate<T extends FASTTab>(options: TabOptions = {}): ElementViewTemplate<T> {
return html<T>`
<template slot="tab" role="tab" aria-disabled="${x => x.disabled}">
${startSlotTemplate(options)}
bearcat-msft marked this conversation as resolved.
Show resolved Hide resolved
<span class="tab-content"><slot></slot></span>
bearcat-msft marked this conversation as resolved.
Show resolved Hide resolved
${endSlotTemplate(options)}
</template>
`;
}

export const template = tabTemplate({});
25 changes: 25 additions & 0 deletions packages/web-components/src/tab/tab.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { css, ElementStyles } from '@microsoft/fast-element';
import { FASTTab } from '@microsoft/fast-foundation';

/**
* Tab extends the FASTTab and is a child of the TabList
*/
export class Tab extends FASTTab {
private styles: ElementStyles | undefined;

connectedCallback() {
super.connectedCallback();

if (this.styles !== undefined) {
this.$fastController.removeStyles(this.styles);
}

this.styles = css/**css*/ `
:host {
--textContent: '${this.textContent as any}';
}
`;

this.$fastController.addStyles(this.styles);
}
}
4 changes: 4 additions & 0 deletions packages/web-components/src/tabs/define.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { FluentDesignSystem } from '../fluent-design-system.js';
import { definition } from './tabs.definition.js';

definition.define(FluentDesignSystem.registry);
5 changes: 5 additions & 0 deletions packages/web-components/src/tabs/index.ts
bearcat-msft marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export * from './tabs.js';
export * from './tabs.options.js';
export { template as TabsTemplate } from './tabs.template.js';
export { styles as TabsStyles } from './tabs.styles.js';
export { definition as TabsDefinition } from './tabs.definition.js';
10 changes: 10 additions & 0 deletions packages/web-components/src/tabs/tabs.definition.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { FluentDesignSystem } from '../fluent-design-system.js';
import { Tabs } from './tabs.js';
import { template } from './tabs.template.js';
import { styles } from './tabs.styles.js';

export const definition = Tabs.compose({
name: `${FluentDesignSystem.prefix}-tabs`,
template,
styles,
});
19 changes: 19 additions & 0 deletions packages/web-components/src/tabs/tabs.options.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { ValuesOf } from '@microsoft/fast-foundation';
import { TabsOrientation } from '@microsoft/fast-foundation';

export const TabsAppearance = {
subtle: 'subtle',
transparent: 'transparent',
} as const;

export type TabsAppearance = ValuesOf<typeof TabsAppearance>;

export const TabsSize = {
small: 'small',
medium: 'medium',
large: 'large',
} as const;

export type TabsSize = ValuesOf<typeof TabsSize>;

export { TabsOrientation };
Loading