-sidebar mobile
All checks were successful
Build Docker Image / Build Docker Image (push) Successful in 6m15s

This commit is contained in:
x2Skyz
2025-11-23 20:12:01 +07:00
parent 6669399b7e
commit 149b6128a7
5 changed files with 56 additions and 81 deletions

View File

@@ -1,32 +1,15 @@
import { Component, HostListener, OnInit } from '@angular/core';
import { Router } from '@angular/router';
import { trigger, state, style, transition, animate } from '@angular/animations';
@Component({
selector: 'app-sidebar',
standalone: false,
templateUrl: './sidebar.component.html',
styleUrls: ['./sidebar.component.css'],
animations: [
trigger('sidebarState', [
state('expanded', style({
width: '220px',
opacity: 1
})),
state('collapsed', style({
width: '70px',
opacity: 0.95
})),
transition('expanded <=> collapsed', [
animate('300ms ease-in-out')
])
])
]
styleUrls: ['./sidebar.component.css']
})
export class SidebarComponent implements OnInit {
isOpen = true; // ขยายไหม
isMobile = false; // ตรวจอุปกรณ์
showOverlay = false; // สำหรับ mobile overlay
isOpen = true;
isMobile = false;
constructor(private router: Router) {}
@@ -39,24 +22,21 @@ export class SidebarComponent implements OnInit {
checkDevice() {
this.isMobile = window.innerWidth <= 768;
if (this.isMobile) {
this.isOpen = false; // ซ่อน sidebar ตอนเข้า mobile
this.isOpen = false;
} else {
this.isOpen = true; // เปิดไว้ตลอดใน desktop
this.showOverlay = false;
this.isOpen = true;
}
}
toggleSidebar() {
if (this.isMobile) {
this.showOverlay = !this.showOverlay;
this.isOpen = this.showOverlay;
} else {
this.isOpen = !this.isOpen;
}
this.isOpen = !this.isOpen;
}
navigate(path: string) {
this.router.navigate([path]);
if (this.isMobile) {
this.isOpen = false;
}
}
logout() {