Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
54 changes: 54 additions & 0 deletions packages/fiori/src/SideNavigation.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import UI5Element from "@ui5/webcomponents-base/dist/UI5Element.js";
import type { Slot, DefaultSlot } from "@ui5/webcomponents-base/dist/UI5Element.js";

Check failure on line 2 in packages/fiori/src/SideNavigation.ts

View workflow job for this annotation

GitHub Actions / check

'@ui5/webcomponents-base/dist/UI5Element.js' imported multiple times
import type { ChangeInfo } from "@ui5/webcomponents-base/dist/UI5Element.js";

Check failure on line 3 in packages/fiori/src/SideNavigation.ts

View workflow job for this annotation

GitHub Actions / check

'@ui5/webcomponents-base/dist/UI5Element.js' imported multiple times
import { createMultiInstanceChecker } from "@ui5/webcomponents-base/dist/util/createMultiInstanceChecker.js";
import customElement from "@ui5/webcomponents-base/dist/decorators/customElement.js";
import i18n from "@ui5/webcomponents-base/dist/decorators/i18n.js";
Expand Down Expand Up @@ -237,6 +238,16 @@
}

_handleResizeBound: () => void;
_fnTransitionEnd?: (event: TransitionEvent) => void;
_bAnimating = false;

onInvalidation(changeInfo: ChangeInfo) {
if (changeInfo.type === "property" && changeInfo.name === "collapsed") {
if (this.getDomRef()) {
this._bAnimating = true;
}
}
}

onBeforeRendering() {
super.onBeforeRendering();
Expand All @@ -247,6 +258,7 @@
item.sideNavCollapsed = this.collapsed;
item.inPopover = this.inPopover;
item.sideNavigation = this;
item.sideNavAnimating = this._bAnimating;
});

this.initGroupsSettings(this.items);
Expand Down Expand Up @@ -497,6 +509,8 @@
if (this.collapsed) {
this.handleResize();
}

this._handleExpandCollapseAnimation();
}

onEnterDOM() {
Expand All @@ -505,6 +519,10 @@

onExitDOM() {
ResizeHandler.deregister(this, this._handleResizeBound);
if (this._fnTransitionEnd) {
this.removeEventListener("transitionend", this._fnTransitionEnd);
this._fnTransitionEnd = undefined;
}
}

handleResize() {
Expand Down Expand Up @@ -622,6 +640,42 @@
return isPhone() || window.innerWidth < SCREEN_WIDTH_BREAKPOINT;
}

_handleExpandCollapseAnimation() {
if (!this._bAnimating) {
return;
}

const oDomRef = this.getDomRef();
if (!oDomRef) {
return;
}

oDomRef.classList.add("ui5-sn-animating");

if (this._fnTransitionEnd) {
this.removeEventListener("transitionend", this._fnTransitionEnd);
}

this._fnTransitionEnd = (oEvent: TransitionEvent) => {
if (oEvent.propertyName !== "width" && oEvent.propertyName !== "min-width") {
return;
}

oDomRef.classList.remove("ui5-sn-animating");
this.removeEventListener("transitionend", this._fnTransitionEnd!);
this._fnTransitionEnd = undefined;
this._bAnimating = false;

this._getAllItems(this.items)
.concat(this._getAllItems(this.fixedItems))
.forEach(item => {
item.sideNavAnimating = false;
});
};

this.addEventListener("transitionend", this._fnTransitionEnd);
}

_handleItemClick(e: KeyboardEvent | MouseEvent, item: SideNavigationSelectableItemBase) {
this.fireDecoratorEvent("item-click", { item });

Expand Down
3 changes: 3 additions & 0 deletions packages/fiori/src/SideNavigationItemBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ class SideNavigationItemBase extends UI5Element implements ITabbable {
@property({ type: Boolean })
sideNavCollapsed = false;

@property({ type: Boolean })
sideNavAnimating = false;

@property({ type: Boolean })
inPopover = false;

Expand Down
10 changes: 10 additions & 0 deletions packages/fiori/src/themes/SideNavigation.css
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@
border-radius: inherit;
}

.ui5-sn-root.ui5-sn-animating {
overflow: hidden;
}

.ui5-sn-flexible {
display: flex;
flex-direction: column;
Expand All @@ -48,6 +52,12 @@
position: relative;
}

.ui5-sn-root.ui5-sn-animating .ui5-sn-list.ui5-sn-flexible,
.ui5-sn-root.ui5-sn-animating .ui5-sn-list.ui5-sn-fixed {
width: var(--_ui5_side_navigation_width);
overflow: hidden;
}

.ui5-sn-list {
margin: 0;
list-style: none;
Expand Down
4 changes: 4 additions & 0 deletions packages/fiori/src/themes/SideNavigationItemBase.css
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,10 @@ and there is an additional border that appears on hover. */
justify-content: center;
}

:host([side-nav-collapsed][side-nav-animating]) .ui5-sn-item {
justify-content: flex-start;
}

:host([slot="fixedItems"]:not(side-nav-collapsed)) .ui5-sn-item.ui5-sn-item-level1 {
margin-top: var(--_ui5_side_navigation_first_fixed_item_margin_top); /* space for the focus*/
}
Expand Down
Loading