From 8a9825c798c8e57c5841d0a313ed148eaf8cb465 Mon Sep 17 00:00:00 2001 From: Teodor Taushanov Date: Fri, 13 Dec 2024 10:23:19 +0200 Subject: [PATCH 01/15] fix(ui5-navigation-layout): change side-collapsed property --- packages/fiori/src/NavigationLayout.ts | 38 +++++++++++++++---- .../src/types/NavigationLayoutCollapsed.ts | 23 +++++++++++ 2 files changed, 54 insertions(+), 7 deletions(-) create mode 100644 packages/fiori/src/types/NavigationLayoutCollapsed.ts diff --git a/packages/fiori/src/NavigationLayout.ts b/packages/fiori/src/NavigationLayout.ts index b96502f4bd22..e056dc333c07 100644 --- a/packages/fiori/src/NavigationLayout.ts +++ b/packages/fiori/src/NavigationLayout.ts @@ -9,6 +9,7 @@ import { isTablet, isCombi, } from "@ui5/webcomponents-base/dist/Device.js"; +import NavigationLayoutCollapsed from "./types/NavigationLayoutCollapsed.js"; import type SideNavigation from "./SideNavigation.js"; // Template @@ -16,6 +17,7 @@ import NavigationLayoutTemplate from "./generated/templates/NavigationLayoutTemp // Styles import NavigationLayoutCss from "./generated/themes/NavigationLayout.css.js"; +import TableGrowingMode from "@ui5/webcomponents-compat/src/types/TableGrowingMode.js"; /** * @class @@ -54,7 +56,9 @@ import NavigationLayoutCss from "./generated/themes/NavigationLayout.css.js"; template: NavigationLayoutTemplate, }) class NavigationLayout extends UI5Element { - _sideCollapsed = isPhone() || (isTablet() && !isCombi()); + _defaultSideCollapsed = isPhone() || (isTablet() && !isCombi()); + + _sideCollapsed: `${NavigationLayoutCollapsed}` = "Auto"; /** * @private @@ -70,11 +74,11 @@ class NavigationLayout extends UI5Element { /** * Indicates whether the side navigation is collapsed. - * @default false + * @default NavigationLayoutCollapsed.Auto * @public */ - @property({ type: Boolean }) - set sideCollapsed(value: boolean) { + @property() + set sideCollapsed(value: `${NavigationLayoutCollapsed}`) { this._sideCollapsed = value; if (isPhone()) { @@ -84,11 +88,21 @@ class NavigationLayout extends UI5Element { const sideNavigation = this.sideContent[0]; if (sideNavigation) { - sideNavigation.collapsed = value; + switch (value) { + case NavigationLayoutCollapsed.Auto: + sideNavigation.collapsed = this._defaultSideCollapsed; + break; + case NavigationLayoutCollapsed.Collapsed: + sideNavigation.collapsed = true; + break; + case NavigationLayoutCollapsed.Expanded: + sideNavigation.collapsed = false; + break; + } } } - get sideCollapsed() : boolean { + get sideCollapsed() : `${NavigationLayoutCollapsed}` { return this._sideCollapsed; } @@ -121,7 +135,17 @@ class NavigationLayout extends UI5Element { const sideNavigation = this.sideContent[0]; if (sideNavigation) { - sideNavigation.collapsed = this.sideCollapsed; + switch (this.sideCollapsed) { + case NavigationLayoutCollapsed.Auto: + sideNavigation.collapsed = this._defaultSideCollapsed; + break; + case NavigationLayoutCollapsed.Collapsed: + sideNavigation.collapsed = true; + break; + case NavigationLayoutCollapsed.Expanded: + sideNavigation.collapsed = false; + break; + } } } } diff --git a/packages/fiori/src/types/NavigationLayoutCollapsed.ts b/packages/fiori/src/types/NavigationLayoutCollapsed.ts new file mode 100644 index 000000000000..f9705e987911 --- /dev/null +++ b/packages/fiori/src/types/NavigationLayoutCollapsed.ts @@ -0,0 +1,23 @@ +/** + * Specifies whether the navigation layout is in collapsed or expanded mode. + * @public + */ +enum NavigationLayoutCollapsed { + /** + * Auto + * @public + */ + Auto = "Auto", + /** + * Collapsed + * @public + */ + Collapsed = "Collapsed", + /** + * Expanded + * @public + */ + Expanded = "Expanded", +} + +export default NavigationLayoutCollapsed; From ee5cc4b8293cb7142eb14496487da26d3b8fc09b Mon Sep 17 00:00:00 2001 From: Teodor Taushanov Date: Fri, 13 Dec 2024 16:33:39 +0200 Subject: [PATCH 02/15] chore: add private actualSideCollapsed --- packages/fiori/src/NavigationLayout.ts | 42 +++++++++---------- .../fiori/src/themes/NavigationLayout.css | 4 +- .../fiori/test/pages/NavigationLayout.html | 2 +- .../fiori/NavigationLayout/Basic/main.js | 2 +- 4 files changed, 23 insertions(+), 27 deletions(-) diff --git a/packages/fiori/src/NavigationLayout.ts b/packages/fiori/src/NavigationLayout.ts index c5b419543dfe..27ba015f5d3d 100644 --- a/packages/fiori/src/NavigationLayout.ts +++ b/packages/fiori/src/NavigationLayout.ts @@ -17,7 +17,6 @@ import NavigationLayoutTemplate from "./NavigationLayoutTemplate.js"; // Styles import NavigationLayoutCss from "./generated/themes/NavigationLayout.css.js"; -import TableGrowingMode from "@ui5/webcomponents-compat/src/types/TableGrowingMode.js"; /** * @class @@ -60,6 +59,12 @@ class NavigationLayout extends UI5Element { _sideCollapsed: `${NavigationLayoutCollapsed}` = "Auto"; + /** + * @private + */ + @property({ type: Boolean }) + actualSideCollapsed : boolean = false; + /** * @private */ @@ -80,6 +85,7 @@ class NavigationLayout extends UI5Element { @property() set sideCollapsed(value: `${NavigationLayoutCollapsed}`) { this._sideCollapsed = value; + this.calcActualSideCollapsed(); if (isPhone()) { return; @@ -88,17 +94,7 @@ class NavigationLayout extends UI5Element { const sideNavigation = this.sideContent[0]; if (sideNavigation) { - switch (value) { - case NavigationLayoutCollapsed.Auto: - sideNavigation.collapsed = this._defaultSideCollapsed; - break; - case NavigationLayoutCollapsed.Collapsed: - sideNavigation.collapsed = true; - break; - case NavigationLayoutCollapsed.Expanded: - sideNavigation.collapsed = false; - break; - } + sideNavigation.collapsed = this.actualSideCollapsed; } } @@ -128,6 +124,8 @@ class NavigationLayout extends UI5Element { content!: Array; onBeforeRendering() { + this.calcActualSideCollapsed(); + if (isPhone()) { return; } @@ -135,17 +133,15 @@ class NavigationLayout extends UI5Element { const sideNavigation = this.sideContent[0]; if (sideNavigation) { - switch (this.sideCollapsed) { - case NavigationLayoutCollapsed.Auto: - sideNavigation.collapsed = this._defaultSideCollapsed; - break; - case NavigationLayoutCollapsed.Collapsed: - sideNavigation.collapsed = true; - break; - case NavigationLayoutCollapsed.Expanded: - sideNavigation.collapsed = false; - break; - } + sideNavigation.collapsed = this.actualSideCollapsed; + } + } + + calcActualSideCollapsed() { + if (this.sideCollapsed === NavigationLayoutCollapsed.Auto) { + this.actualSideCollapsed = this._defaultSideCollapsed; + } else { + this.actualSideCollapsed = this.sideCollapsed === NavigationLayoutCollapsed.Collapsed; } } } diff --git a/packages/fiori/src/themes/NavigationLayout.css b/packages/fiori/src/themes/NavigationLayout.css index 544ef6c4d39f..f662a3f92df9 100644 --- a/packages/fiori/src/themes/NavigationLayout.css +++ b/packages/fiori/src/themes/NavigationLayout.css @@ -52,11 +52,11 @@ overflow: auto; } -:host([side-collapsed][is-phone]) .ui5-nl-aside { +:host([actual-side-collapsed][is-phone]) .ui5-nl-aside { transform: translateX(-100%); } -:host([side-collapsed][is-phone]) :dir(rtl) .ui5-nl-aside { +:host([actual-side-collapsed][is-phone]) :dir(rtl) .ui5-nl-aside { transform: translateX(100%); } diff --git a/packages/fiori/test/pages/NavigationLayout.html b/packages/fiori/test/pages/NavigationLayout.html index eea92e3d6b14..8e9678f8b516 100644 --- a/packages/fiori/test/pages/NavigationLayout.html +++ b/packages/fiori/test/pages/NavigationLayout.html @@ -161,7 +161,7 @@

Sub Item 2