-sidebar mobile
All checks were successful
Build Docker Image / Build Docker Image (push) Successful in 6m15s
All checks were successful
Build Docker Image / Build Docker Image (push) Successful in 6m15s
This commit is contained in:
@@ -1,22 +1,27 @@
|
|||||||
/* .sidebar {
|
.sidebar-container {
|
||||||
width: 220px;
|
width: 250px;
|
||||||
background: #222;
|
transition: width 0.3s ease-in-out;
|
||||||
color: white;
|
flex-shrink: 0; /* Prevent the sidebar from shrinking in the flex container */
|
||||||
|
}
|
||||||
|
|
||||||
|
.sidebar-container.is-collapsed {
|
||||||
|
width: 70px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sidebar-container.is-mobile {
|
||||||
|
position: fixed;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
height: 100vh;
|
height: 100vh;
|
||||||
padding: 20px;
|
width: 250px; /* Width when shown on mobile */
|
||||||
} */
|
z-index: 40;
|
||||||
/* .sidebar ul {
|
transform: translateX(-100%);
|
||||||
list-style: none;
|
transition: transform 0.3s ease-in-out;
|
||||||
padding: 0;
|
|
||||||
}
|
}
|
||||||
.sidebar li {
|
|
||||||
margin: 10px 0;
|
.sidebar-container.is-mobile.is-open {
|
||||||
cursor: pointer;
|
transform: translateX(0);
|
||||||
transition: 0.2s;
|
|
||||||
}
|
}
|
||||||
.sidebar li:hover {
|
|
||||||
color: #00bcd4;
|
|
||||||
} */
|
|
||||||
|
|
||||||
@keyframes spin-slow {
|
@keyframes spin-slow {
|
||||||
0% { transform: rotate(0deg); }
|
0% { transform: rotate(0deg); }
|
||||||
@@ -25,15 +30,3 @@
|
|||||||
.animate-spin-slow {
|
.animate-spin-slow {
|
||||||
animation: spin-slow 8s linear infinite;
|
animation: spin-slow 8s linear infinite;
|
||||||
}
|
}
|
||||||
|
|
||||||
@media (max-width: 768px) {
|
|
||||||
.sidebar {
|
|
||||||
position: absolute;
|
|
||||||
z-index: 50;
|
|
||||||
transform: translateX(-100%);
|
|
||||||
}
|
|
||||||
|
|
||||||
.sidebar.expanded {
|
|
||||||
transform: translateX(0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,22 +1,28 @@
|
|||||||
<div
|
<div
|
||||||
class="h-screen bg-linear-to-b from-amber-950 to-amber-900 text-gray-100 shadow-2xl flex flex-col relative transition-all duration-300 ease-in-out"
|
[class.is-mobile]="isMobile"
|
||||||
[@sidebarState]="isOpen ? 'expanded' : 'collapsed'">
|
[class.is-open]="isOpen"
|
||||||
|
[class.is-collapsed]="!isOpen && !isMobile"
|
||||||
|
class="sidebar-container h-full bg-linear-to-b from-amber-950 to-amber-900 text-gray-100 shadow-2xl flex flex-col relative">
|
||||||
|
|
||||||
<button
|
<button
|
||||||
(click)="toggleSidebar()"
|
(click)="toggleSidebar()"
|
||||||
|
[class.hidden]="isMobile"
|
||||||
class="absolute -right-3 top-6 bg-amber-700 hover:bg-amber-600 text-white rounded-full p-2 shadow-md transition-all duration-300">
|
class="absolute -right-3 top-6 bg-amber-700 hover:bg-amber-600 text-white rounded-full p-2 shadow-md transition-all duration-300">
|
||||||
<i class="fas" [ngClass]="isOpen ? 'fa-angle-left' : 'fa-angle-right'"></i>
|
<i class="fas" [ngClass]="isOpen ? 'fa-angle-left' : 'fa-angle-right'"></i>
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
|
|
||||||
<div class="flex items-center gap-3 p-5">
|
<div class="flex items-center gap-3 p-5">
|
||||||
<h3 *ngIf="isOpen" class="text-2xl font-bold transition-all duration-300">
|
<h3 *ngIf="isOpen" class="text-2xl font-bold transition-all duration-300">
|
||||||
|
@if(!isMobile){
|
||||||
<img src="logo.png" alt="">
|
<img src="logo.png" alt="">
|
||||||
|
}
|
||||||
</h3>
|
</h3>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<hr class="border-t border-amber-700 mx-4 my-4 opacity-70">
|
<hr class="border-t border-amber-700 mx-4 my-4 opacity-70">
|
||||||
|
|
||||||
<ul class="flex flex-col gap-2 px-2 grow">
|
<ul class="flex flex-col gap-2 px-2 flex-1 overflow-y-auto">
|
||||||
|
|
||||||
<li class="group flex items-center gap-3 p-3 rounded-lg cursor-pointer
|
<li class="group flex items-center gap-3 p-3 rounded-lg cursor-pointer
|
||||||
hover:bg-amber-800 hover:shadow-lg transition-all duration-300 ease-in-out"
|
hover:bg-amber-800 hover:shadow-lg transition-all duration-300 ease-in-out"
|
||||||
@@ -45,21 +51,7 @@
|
|||||||
hover:bg-red-700 hover:shadow-lg transition-all duration-300 ease-in-out"
|
hover:bg-red-700 hover:shadow-lg transition-all duration-300 ease-in-out"
|
||||||
(click)="logout()">
|
(click)="logout()">
|
||||||
<i class="fas fa-sign-out-alt text-xl group-hover:scale-110 transition-transform"></i>
|
<i class="fas fa-sign-out-alt text-xl group-hover:scale-110 transition-transform"></i>
|
||||||
<span *ngIf="isOpen" class="text-lg font-medium text-red-200">Logout</span>
|
<span *ngIf="isOpen" class="text-lg font--medium text-red-200">Logout</span>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div
|
|
||||||
*ngIf="isMobile && showOverlay"
|
|
||||||
class="fixed inset-0 bg-black bg-opacity-50 z-40 transition-opacity duration-300"
|
|
||||||
(click)="toggleSidebar()">
|
|
||||||
</div>
|
|
||||||
<!--
|
|
||||||
|
|
||||||
<div class="flex-1 bg-gray-100 text-gray-900 overflow-y-auto">
|
|
||||||
<router-outlet></router-outlet>
|
|
||||||
</div> -->
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,32 +1,15 @@
|
|||||||
import { Component, HostListener, OnInit } from '@angular/core';
|
import { Component, HostListener, OnInit } from '@angular/core';
|
||||||
import { Router } from '@angular/router';
|
import { Router } from '@angular/router';
|
||||||
import { trigger, state, style, transition, animate } from '@angular/animations';
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-sidebar',
|
selector: 'app-sidebar',
|
||||||
standalone: false,
|
standalone: false,
|
||||||
templateUrl: './sidebar.component.html',
|
templateUrl: './sidebar.component.html',
|
||||||
styleUrls: ['./sidebar.component.css'],
|
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')
|
|
||||||
])
|
|
||||||
])
|
|
||||||
]
|
|
||||||
})
|
})
|
||||||
export class SidebarComponent implements OnInit {
|
export class SidebarComponent implements OnInit {
|
||||||
isOpen = true; // ขยายไหม
|
isOpen = true;
|
||||||
isMobile = false; // ตรวจอุปกรณ์
|
isMobile = false;
|
||||||
showOverlay = false; // สำหรับ mobile overlay
|
|
||||||
|
|
||||||
constructor(private router: Router) {}
|
constructor(private router: Router) {}
|
||||||
|
|
||||||
@@ -39,24 +22,21 @@ export class SidebarComponent implements OnInit {
|
|||||||
checkDevice() {
|
checkDevice() {
|
||||||
this.isMobile = window.innerWidth <= 768;
|
this.isMobile = window.innerWidth <= 768;
|
||||||
if (this.isMobile) {
|
if (this.isMobile) {
|
||||||
this.isOpen = false; // ซ่อน sidebar ตอนเข้า mobile
|
this.isOpen = false;
|
||||||
} else {
|
} else {
|
||||||
this.isOpen = true; // เปิดไว้ตลอดใน desktop
|
this.isOpen = true;
|
||||||
this.showOverlay = false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
toggleSidebar() {
|
toggleSidebar() {
|
||||||
if (this.isMobile) {
|
this.isOpen = !this.isOpen;
|
||||||
this.showOverlay = !this.showOverlay;
|
|
||||||
this.isOpen = this.showOverlay;
|
|
||||||
} else {
|
|
||||||
this.isOpen = !this.isOpen;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
navigate(path: string) {
|
navigate(path: string) {
|
||||||
this.router.navigate([path]);
|
this.router.navigate([path]);
|
||||||
|
if (this.isMobile) {
|
||||||
|
this.isOpen = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
logout() {
|
logout() {
|
||||||
|
|||||||
@@ -1,9 +1,19 @@
|
|||||||
<div class="flex h-screen overflow-hidden">
|
<!-- Mobile Header -->
|
||||||
<!-- Sidebar (เฉพาะ main) -->
|
<div class="md:hidden flex items-center justify-between bg-white text-gray-800 p-4 shadow-md relative z-50">
|
||||||
<app-sidebar></app-sidebar>
|
<button (click)="sidebar.toggleSidebar()">
|
||||||
|
<svg class="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 6h16M4 12h16m-4 6h10"></path>
|
||||||
|
</svg>
|
||||||
|
</button>
|
||||||
|
<div></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="flex h-screen bg-gray-50">
|
||||||
|
<!-- Sidebar -->
|
||||||
|
<app-sidebar #sidebar></app-sidebar>
|
||||||
|
|
||||||
<!-- Content -->
|
<!-- Content -->
|
||||||
<div class="flex-1 overflow-y-auto bg-gray-50 text-gray-900">
|
<div class="flex-1 overflow-y-auto overflow-x-hidden text-gray-900">
|
||||||
<router-outlet></router-outlet>
|
<router-outlet></router-outlet>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
export const environment = {
|
export const environment = {
|
||||||
production: false,
|
production: false,
|
||||||
apiBaseUrl: 'https://bread-leader-move-created.trycloudflare.com'
|
// apiBaseUrl: 'https://bread-leader-move-created.trycloudflare.com'
|
||||||
|
|
||||||
|
|
||||||
// apiBaseUrl: 'http://localhost:8000'
|
apiBaseUrl: 'http://localhost:8000'
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user