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

feat(ui5-tabcontainer): enable nested tabs #4705

Merged
merged 57 commits into from
Mar 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
17399ff
Initial commit
kskondov Jan 10, 2022
20e1060
Merge branch 'master' of github.com:SAP/ui5-webcomponents into ui5-ta…
kskondov Jan 18, 2022
e7237f6
Merge branch 'master' of github.com:SAP/ui5-webcomponents into ui5-ta…
kskondov Jan 26, 2022
f03d385
feat(ui5-tabcontainer): Introduced nested-tabs
kskondov Feb 7, 2022
b53ec31
Merge branch 'master' of github.com:SAP/ui5-webcomponents into ui5-ta…
kskondov Feb 7, 2022
1a4e810
Fixing bugs
kskondov Feb 8, 2022
420924b
Sub items can be selected if in overflow
kskondov Feb 8, 2022
50a369c
Bugs and styles fixing
kskondov Feb 10, 2022
91b16cc
Better item selection based on ids
kskondov Feb 10, 2022
047f678
wip
georgimkv Feb 11, 2022
277803b
WiP
kskondov Feb 14, 2022
df9ba9e
refactoring
kskondov Feb 15, 2022
3b2d8d1
Bug fix
kskondov Feb 15, 2022
f69d60b
Recursive tabs content
kskondov Feb 16, 2022
54bf705
Merge branch 'master' of github.com:SAP/ui5-webcomponents into ui5-ta…
kskondov Feb 17, 2022
270fc91
Separator bug
kskondov Feb 17, 2022
1df7b56
Merge branch 'master' of github.com:SAP/ui5-webcomponents into ui5-ta…
kskondov Feb 17, 2022
a625851
Fix tests
kskondov Feb 17, 2022
58f7f9b
Test and sample
kskondov Feb 18, 2022
554e68c
Merge branch 'master' of github.com:SAP/ui5-webcomponents into ui5-ta…
kskondov Feb 18, 2022
c734d11
Merge branch 'master' into ui5-tabcontainer-nested-tabs
kskondov Feb 18, 2022
b359ba9
Merge branch 'master' of github.com:SAP/ui5-webcomponents into ui5-ta…
kskondov Feb 21, 2022
2825707
Address review comments
kskondov Feb 21, 2022
bcf5cf3
Review comments
kskondov Feb 21, 2022
9a9710c
Review comments
kskondov Feb 21, 2022
8bcc10d
Fix bugs
kskondov Feb 21, 2022
d9b90f1
Merge branch 'master' into ui5-tabcontainer-nested-tabs
kskondov Feb 22, 2022
84854a4
Fix indentation
kskondov Feb 22, 2022
e88d2dc
Merge branch 'ui5-tabcontainer-nested-tabs' of github.com:SAP/ui5-web…
kskondov Feb 22, 2022
8a2fff5
Added indentation for separators
kskondov Feb 22, 2022
19369ce
Style of selected tab with expand button
kskondov Feb 22, 2022
ffda161
Style of selected tab with expand button
kskondov Feb 22, 2022
4ba68fe
Merge branch 'ui5-tabcontainer-nested-tabs' of github.com:SAP/ui5-web…
kskondov Feb 22, 2022
e08fb3d
Prevent scroll
kskondov Feb 22, 2022
5f2a9d5
Fix separators issue
kskondov Feb 22, 2022
bdb4e95
Address comments from review
kskondov Feb 24, 2022
00a1616
Add tests
kskondov Feb 24, 2022
010b559
Merge branch 'master' into ui5-tabcontainer-nested-tabs
kskondov Feb 25, 2022
07e8d5f
Single click area tabs, improved tests
kskondov Feb 25, 2022
1068720
Merge branch 'ui5-tabcontainer-nested-tabs' of github.com:SAP/ui5-web…
kskondov Feb 25, 2022
4705c5f
Merge branch 'master' of github.com:SAP/ui5-webcomponents into ui5-ta…
kskondov Feb 25, 2022
31c41f6
Build error
kskondov Feb 25, 2022
5aec70f
Fix separators indentation
kskondov Feb 25, 2022
f63831c
Merge branch 'master' of github.com:SAP/ui5-webcomponents into ui5-ta…
kskondov Feb 25, 2022
7819dcf
Selected sub item styles
kskondov Feb 28, 2022
40f3d80
Merge branch 'master' of github.com:SAP/ui5-webcomponents into ui5-ta…
kskondov Feb 28, 2022
6c9cb26
Merge branch 'master' of github.com:SAP/ui5-webcomponents into ui5-ta…
kskondov Mar 2, 2022
0cc2bf3
Keyboard handling
kskondov Mar 2, 2022
29dcbcb
Merge branch 'master' of github.com:SAP/ui5-webcomponents into ui5-ta…
kskondov Mar 7, 2022
4f9e17b
Address comments from review
kskondov Mar 7, 2022
fa437da
Merge branch 'master' of github.com:SAP/ui5-webcomponents into ui5-ta…
kskondov Mar 7, 2022
4d70c7d
Fix bugs
kskondov Mar 9, 2022
a7b825c
Addressed review comments
kskondov Mar 14, 2022
f018708
Merge branch 'master' into ui5-tabcontainer-nested-tabs
kskondov Mar 16, 2022
4cb5982
Address comments from review
kskondov Mar 16, 2022
f09568d
Merge branch 'ui5-tabcontainer-nested-tabs' of github.com:SAP/ui5-web…
kskondov Mar 16, 2022
d1286bd
Set initial focus on tab strip click
kskondov Mar 17, 2022
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
6 changes: 5 additions & 1 deletion packages/main/src/Tab.hbs
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
<div id="{{_id}}" class="ui5-tab-root">
<slot></slot>
<slot name="{{this._defaultSlotName}}"></slot>

{{#each tabs}}
<slot name="{{this._effectiveSlotName}}"></slot>
{{/each}}
</div>
80 changes: 76 additions & 4 deletions packages/main/src/Tab.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,42 @@ import overflowCss from "./generated/themes/TabInOverflow.css.js";
*/
const metadata = {
tag: "ui5-tab",
managedSlots: true,
languageAware: true,
slots: /** @lends sap.ui.webcomponents.main.Tab.prototype */ {

/**
* Defines the tab content.
* Holds the content associated with this tab.
*
kskondov marked this conversation as resolved.
Show resolved Hide resolved
* @type {Node[]}
* @slot
* @public
* @slot
*/
"default": {
type: Node,
propertyName: "content",
invalidateOnChildChange: {
properties: true,
slots: false,
},
},

/**
* Defines hierarchies with nested sub tabs.
* <br><br>
* <b>Note:</b> Use <code>ui5-tab</code> and <code>ui5-tab-separator</code> for the intended design.
*
* @type {sap.ui.webcomponents.main.ITab[]}
* @public
* @slot subTabs
*/
subTabs: {
type: HTMLElement,
individualSlots: true,
invalidateOnChildChange: {
properties: true,
slots: false,
},
},
},
properties: /** @lends sap.ui.webcomponents.main.Tab.prototype */ {
Expand Down Expand Up @@ -122,6 +148,14 @@ const metadata = {
_selected: {
type: Boolean,
},

_realTab: {
type: Object,
},

_isTopLevelTab: {
type: Boolean,
},
},
events: /** @lends sap.ui.webcomponents.main.Tab.prototype */ {
},
Expand Down Expand Up @@ -199,6 +233,31 @@ class Tab extends UI5Element {
return this.getAttribute("stable-dom-ref") || `${this._id}-stable-dom-ref`;
}

get requiresExpandButton() {
return this.subTabs.length > 0 && this._isTopLevelTab && this._hasOwnContent;
}

get isSingleClickArea() {
return this.subTabs.length > 0 && this._isTopLevelTab && !this._hasOwnContent;
}

get isOnSelectedTabPath() {
return this._realTab === this || this.tabs.some(subTab => subTab.isOnSelectedTabPath);
}

get _effectiveSlotName() {
return this.isOnSelectedTabPath ? this._individualSlot : "disabled-slot";
}

get _defaultSlotName() {
return this._realTab === this ? "" : "disabled-slot";
}

get _hasOwnContent() {
return this.content.some(node => (node.nodeType !== Node.COMMENT_NODE
&& (node.nodeType !== Node.TEXT_NODE || node.nodeValue.trim().length !== 0)));
}

/**
* Returns the DOM reference of the tab that is placed in the header.
* <b>Note:</b> If you need a DOM ref to the tab content please use the <code>getDomRef</code> method.
Expand Down Expand Up @@ -238,13 +297,18 @@ class Tab extends UI5Element {
}

get effectiveSelected() {
return this.selected || this._selected;
const subItemSelected = this.tabs.some(elem => elem.effectiveSelected);
return this.selected || this._selected || subItemSelected;
}

get effectiveHidden() {
return !this.effectiveSelected;
}

get tabs() {
return this.subTabs.filter(tab => !tab.isSeparator);
}

get ariaLabelledBy() {
const labels = [];

Expand Down Expand Up @@ -298,6 +362,10 @@ class Tab extends UI5Element {
classes.push(`ui5-tab-strip-item--${this.design.toLowerCase()}`);
}

if (this.isSingleClickArea) {
classes.push(`ui5-tab-strip-item--singleClickArea`);
}

return classes.join(" ");
}

Expand All @@ -322,11 +390,15 @@ class Tab extends UI5Element {
classes.push("ui5-tab-overflow-item--disabled");
}

if (this.selected) {
classes.push("ui5-tab-overflow-item--selectedSubTab");
}

return classes.join(" ");
}

get overflowState() {
return this.disabled ? "Inactive" : "Active";
return (this.disabled || this.isSingleClickArea) ? "Inactive" : "Active";
}
}

Expand Down
24 changes: 11 additions & 13 deletions packages/main/src/TabContainer.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -66,18 +66,16 @@

{{#*inline "contentArea"}}
<div class="{{classes.content}}" part="content">
{{#each items}}
{{#unless this.isSeparator}}
<div
class="ui5-tc__contentItem"
id="ui5-tc-contentItem-{{this._posinset}}"
?hidden="{{this.effectiveHidden}}"
role="tabpanel"
aria-labelledby="{{this._id}}"
>
<slot name="{{this._individualSlot}}"></slot>
</div>
{{/unless}}
{{/each}}
<div
class="ui5-tc__contentItem"
id="ui5-tc-content"
?hidden="{{this._selectedTab.effectiveHidden}}"
role="tabpanel"
aria-labelledby="{{this._selectedTab._id}}"
>
{{#each items}}
<slot name="{{this._effectiveSlotName}}"></slot>
{{/each}}
</div>
</div>
{{/inline}}
Loading