From 18320ddd11da7ae2b7ca3ab72716fbcc4d9e23d6 Mon Sep 17 00:00:00 2001 From: Igor Propisnov Date: Thu, 27 Jun 2024 23:34:29 +0200 Subject: [PATCH 1/7] sidebar for dashboard work in progress --- .../dashboard-root.component.html | 42 ++++++++++++++- .../dashboard-root.component.ts | 54 ++++++++++++++++++- 2 files changed, 93 insertions(+), 3 deletions(-) diff --git a/frontend/src/app/pages/dashboard-root/dashboard-root.component.html b/frontend/src/app/pages/dashboard-root/dashboard-root.component.html index f3e333e..f25241c 100644 --- a/frontend/src/app/pages/dashboard-root/dashboard-root.component.html +++ b/frontend/src/app/pages/dashboard-root/dashboard-root.component.html @@ -1 +1,41 @@ -

Hello World

+
+ +
+
Logo
+
    +
  • + + {{ item.icon }} + + + {{ item.name }} + +
      +
    • + {{ subItem }} +
    • +
    +
  • +
+
+ + + + +
Hauptinhalt hier
+
diff --git a/frontend/src/app/pages/dashboard-root/dashboard-root.component.ts b/frontend/src/app/pages/dashboard-root/dashboard-root.component.ts index 6a160af..abcc404 100644 --- a/frontend/src/app/pages/dashboard-root/dashboard-root.component.ts +++ b/frontend/src/app/pages/dashboard-root/dashboard-root.component.ts @@ -1,14 +1,64 @@ -import { ChangeDetectionStrategy, Component } from '@angular/core'; +import { CommonModule } from '@angular/common'; +import { + ChangeDetectionStrategy, + Component, + HostListener, +} from '@angular/core'; + +interface MenuItem { + name: string; + icon: string; + subItems: string[]; + open?: boolean; +} @Component({ selector: 'app-dashboard-root', standalone: true, - imports: [], + imports: [CommonModule], providers: [], templateUrl: './dashboard-root.component.html', styleUrl: './dashboard-root.component.scss', changeDetection: ChangeDetectionStrategy.OnPush, }) export class DashboardRootComponent { + public isCollapsed: boolean = false; + public showMobileMenu: boolean = false; + public userHasInteracted: boolean = false; + public menuItems: MenuItem[] = [ + { name: 'Home', icon: '🏠', subItems: [] }, + { name: 'About', icon: 'ℹī¸', subItems: [] }, + { + name: 'Services', + icon: '🛠ī¸', + subItems: ['Web Design', 'SEO', 'Development'], + open: false, + }, + { name: 'Contact', icon: '📞', subItems: [] }, + ]; + public constructor() {} + + @HostListener('window:resize', ['$event']) + public onResize(): void { + if (!this.userHasInteracted) { + this.isCollapsed = window.innerWidth < 768; + } else { + if (window.innerWidth > 768) { + this.isCollapsed = false; + this.userHasInteracted = false; + } + } + } + + public toggleSidebar(): void { + this.isCollapsed = !this.isCollapsed; + this.userHasInteracted = true; + } + + public toggleSubMenu(item: any): void { + if (item.subItems.length) { + item.open = !item.open; + } + } } -- 2.40.1 From 25481335587a86ca940108a674f40894f303c46e Mon Sep 17 00:00:00 2001 From: Igor Propisnov Date: Wed, 17 Jul 2024 13:54:15 +0200 Subject: [PATCH 2/7] added ui/ux logic for side menu --- .../dashboard-root.component.html | 134 +++++++++++++----- .../dashboard-root.component.ts | 24 ++-- 2 files changed, 110 insertions(+), 48 deletions(-) diff --git a/frontend/src/app/pages/dashboard-root/dashboard-root.component.html b/frontend/src/app/pages/dashboard-root/dashboard-root.component.html index f25241c..23eb2c3 100644 --- a/frontend/src/app/pages/dashboard-root/dashboard-root.component.html +++ b/frontend/src/app/pages/dashboard-root/dashboard-root.component.html @@ -1,41 +1,97 @@ -
- -
-
Logo
-
    -
  • - - {{ item.icon }} - - - {{ item.name }} - -
      -
    • - {{ subItem }} -
    • -
    -
  • -
-
- - +
+ +
+
+ +
+
+
Logo
+
+ + +
- -
Hauptinhalt hier
+
+ +
+
    +
  • + + +
    +
    + + {{ item.name }} +
    + + â–ļ + +
    + +
      +
    • + {{ subItem }} +
    • +
    +
  • +
+
+ +
+ + +
Hauptinhalt hier
+
diff --git a/frontend/src/app/pages/dashboard-root/dashboard-root.component.ts b/frontend/src/app/pages/dashboard-root/dashboard-root.component.ts index abcc404..aec9cfb 100644 --- a/frontend/src/app/pages/dashboard-root/dashboard-root.component.ts +++ b/frontend/src/app/pages/dashboard-root/dashboard-root.component.ts @@ -4,10 +4,11 @@ import { Component, HostListener, } from '@angular/core'; +import { DomSanitizer, SafeHtml } from '@angular/platform-browser'; interface MenuItem { name: string; - icon: string; + icon: SafeHtml; subItems: string[]; open?: boolean; } @@ -23,21 +24,21 @@ interface MenuItem { }) export class DashboardRootComponent { public isCollapsed: boolean = false; + public isDesktopCollapsed: boolean = false; public showMobileMenu: boolean = false; public userHasInteracted: boolean = false; public menuItems: MenuItem[] = [ - { name: 'Home', icon: '🏠', subItems: [] }, - { name: 'About', icon: 'ℹī¸', subItems: [] }, { - name: 'Services', - icon: '🛠ī¸', - subItems: ['Web Design', 'SEO', 'Development'], - open: false, + name: 'Dashboard', + icon: this.sanitizer + .bypassSecurityTrustHtml(` + + `), + subItems: [], }, - { name: 'Contact', icon: '📞', subItems: [] }, ]; - public constructor() {} + public constructor(private sanitizer: DomSanitizer) {} @HostListener('window:resize', ['$event']) public onResize(): void { @@ -53,9 +54,14 @@ export class DashboardRootComponent { public toggleSidebar(): void { this.isCollapsed = !this.isCollapsed; + this.showMobileMenu = !this.isCollapsed; this.userHasInteracted = true; } + public toggleDesktopSidebar(): void { + this.isDesktopCollapsed = !this.isDesktopCollapsed; + } + public toggleSubMenu(item: any): void { if (item.subItems.length) { item.open = !item.open; -- 2.40.1 From 5246b374c4b55a7e91d65d1751abd53ecb6993f7 Mon Sep 17 00:00:00 2001 From: Igor Propisnov Date: Thu, 18 Jul 2024 15:23:58 +0200 Subject: [PATCH 3/7] Update Main Navigation --- .../dashboard-root.component.html | 207 ++++++++++-------- .../dashboard-root.component.ts | 36 +-- 2 files changed, 134 insertions(+), 109 deletions(-) diff --git a/frontend/src/app/pages/dashboard-root/dashboard-root.component.html b/frontend/src/app/pages/dashboard-root/dashboard-root.component.html index 23eb2c3..e7728ac 100644 --- a/frontend/src/app/pages/dashboard-root/dashboard-root.component.html +++ b/frontend/src/app/pages/dashboard-root/dashboard-root.component.html @@ -1,97 +1,120 @@ -
- -
-
- -
-
-
Logo
-
- - -
- -
- -
+ +
-
    -
  • - - -
    -
    - - {{ item.name }} -
    - - â–ļ - -
    - -
      -
    • - {{ subItem }} -
    • -
    -
  • -
-
- + ? 'bg-primary w-48 md:w-16 transition-all duration-300 ease-in-out' + : 'bg-primary w-48 md:w-48 transition-all duration-300 ease-in-out' + " + class="transform h-full z-20 overflow-y-auto fixed md:relative">
+ [ngClass]="showMobileMenu ? 'justify-center' : 'justify-between'" + class="p-1 w-full h-16 bg-base-100 flex items-center relative"> +
+
+ @if (!isCollapsed && !isDesktopCollapsed) { +
Logo
+ } - -
Hauptinhalt hier
+ @if (!isCollapsed && !showMobileMenu) { + + } +
+
+
+
    +
  • +
    + +
    + +
    +
    + + {{ item.name }} +
    +
    +
  • +
+ +
+
+
+ +
+
+ +
+

isCollapsed: {{ isCollapsed }}

+

showMobileMenu: {{ showMobileMenu }}

+

isDesktopCollapsed: {{ isDesktopCollapsed }}

+
+
+ +
diff --git a/frontend/src/app/pages/dashboard-root/dashboard-root.component.ts b/frontend/src/app/pages/dashboard-root/dashboard-root.component.ts index aec9cfb..2da5013 100644 --- a/frontend/src/app/pages/dashboard-root/dashboard-root.component.ts +++ b/frontend/src/app/pages/dashboard-root/dashboard-root.component.ts @@ -3,14 +3,15 @@ import { ChangeDetectionStrategy, Component, HostListener, + OnInit, } from '@angular/core'; import { DomSanitizer, SafeHtml } from '@angular/platform-browser'; interface MenuItem { name: string; icon: SafeHtml; - subItems: string[]; open?: boolean; + active?: boolean; } @Component({ @@ -22,7 +23,7 @@ interface MenuItem { styleUrl: './dashboard-root.component.scss', changeDetection: ChangeDetectionStrategy.OnPush, }) -export class DashboardRootComponent { +export class DashboardRootComponent implements OnInit { public isCollapsed: boolean = false; public isDesktopCollapsed: boolean = false; public showMobileMenu: boolean = false; @@ -34,37 +35,38 @@ export class DashboardRootComponent { .bypassSecurityTrustHtml(` `), - subItems: [], }, ]; public constructor(private sanitizer: DomSanitizer) {} + public ngOnInit(): void { + this.onResize(); + } + @HostListener('window:resize', ['$event']) public onResize(): void { - if (!this.userHasInteracted) { - this.isCollapsed = window.innerWidth < 768; + if (window.innerWidth >= 768) { + this.showMobileMenu = false; + this.isCollapsed = false; } else { - if (window.innerWidth > 768) { - this.isCollapsed = false; - this.userHasInteracted = false; - } + this.isDesktopCollapsed = false; + this.isCollapsed = true; + this.showMobileMenu = false; } } public toggleSidebar(): void { - this.isCollapsed = !this.isCollapsed; - this.showMobileMenu = !this.isCollapsed; + if (window.innerWidth < 768) { + this.showMobileMenu = !this.showMobileMenu; + this.isCollapsed = !this.showMobileMenu; + } else { + this.isDesktopCollapsed = !this.isDesktopCollapsed; + } this.userHasInteracted = true; } public toggleDesktopSidebar(): void { this.isDesktopCollapsed = !this.isDesktopCollapsed; } - - public toggleSubMenu(item: any): void { - if (item.subItems.length) { - item.open = !item.open; - } - } } -- 2.40.1 From 062344f65ddb420f30861f47162ee690f1857813 Mon Sep 17 00:00:00 2001 From: Igor Propisnov Date: Thu, 18 Jul 2024 16:22:33 +0200 Subject: [PATCH 4/7] set active state to nav --- .../dashboard-root.component.html | 11 +++++-- .../dashboard-root.component.ts | 31 +++++++++++++++++-- 2 files changed, 37 insertions(+), 5 deletions(-) diff --git a/frontend/src/app/pages/dashboard-root/dashboard-root.component.html b/frontend/src/app/pages/dashboard-root/dashboard-root.component.html index e7728ac..d337baf 100644 --- a/frontend/src/app/pages/dashboard-root/dashboard-root.component.html +++ b/frontend/src/app/pages/dashboard-root/dashboard-root.component.html @@ -56,7 +56,12 @@