Skip to content

Commit c2980bd

Browse files
committed
style: change sidebar menu layout
1 parent 0341744 commit c2980bd

File tree

5 files changed

+33
-31
lines changed

5 files changed

+33
-31
lines changed

src/app/modules/layout/components/navbar/navbar-mobile/navbar-mobile-menu/navbar-mobile-menu.component.html

+1-3
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@
1212
(click)="toggleMenu(item)"
1313
class="text-muted-foreground hover:text-foreground group flex grow items-center gap-4">
1414
<!-- Icon -->
15-
<div
16-
[ngClass]="item.active && !menuService.showSideBar ? 'text-primary' : 'text-muted-foreground/50'"
17-
class="pointer-events-none">
15+
<div [ngClass]="item.active && !menuService.showSideBar ? 'text-primary' : 'text-muted-foreground/50'">
1816
<svg-icon src="{{ item.icon }}" [svgClass]="'h-5 w-5'"> </svg-icon>
1917
</div>
2018

src/app/modules/layout/components/navbar/profile-menu/profile-menu.component.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<img
66
clickOutside
77
(clickOutside)="isOpen = false"
8-
class="size-9 shrink-0 rounded-full border-2 border-green-500"
8+
class="size-9 shrink-0 rounded-md"
99
src="https://avatars.githubusercontent.com/u/12519008?v=4"
1010
alt="" />
1111
</button>

src/app/modules/layout/components/sidebar/sidebar-menu/sidebar-menu.component.html

+19-13
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
<div class="pt-4" *ngFor="let menu of menuService.pagesMenu">
2-
<div class="mx-1 mb-2 flex items-center justify-between">
1+
<div *ngFor="let menu of menuService.pagesMenu">
2+
<div *ngIf="menuService.showSideBar" class="mx-1 flex items-center justify-between py-3">
33
<small [ngClass]="{ hidden: !menuService.showSideBar }" class="text-muted-foreground/50 text-xs font-semibold">
44
{{ menu.group }}
55
</small>
@@ -8,11 +8,15 @@
88
<!-- List items -->
99
<li *ngFor="let item of menu.items">
1010
<!-- Menu List -->
11-
<div (click)="toggleMenu(item)" class="text-muted-foreground group relative">
11+
<div
12+
(click)="toggleMenu(item)"
13+
[ngClass]="{
14+
'hover:bg-primary/10': !menuService.showSideBar && item.active,
15+
'hover:bg-card/50': !menuService.showSideBar
16+
}"
17+
class="text-muted-foreground hover:text-foreground group relative flex grow items-center gap-4 rounded-lg px-2">
1218
<!-- Icon -->
13-
<div
14-
[ngClass]="item.active && !menuService.showSideBar ? 'text-primary' : 'text-muted-foreground/50'"
15-
class="pointer-events-none absolute m-2">
19+
<div [ngClass]="item.active && !menuService.showSideBar ? 'text-primary' : 'text-muted-foreground/50'">
1620
<svg-icon src="{{ item.icon }}" [svgClass]="'h-5 w-5'"> </svg-icon>
1721
</div>
1822

@@ -28,18 +32,20 @@
2832
routerLink="{{ item.route }}"
2933
class="text-muted-foreground hover:text-primary flex h-[36px] cursor-pointer items-center justify-start rounded-sm">
3034
<a
35+
[ngClass]="{ hidden: !menuService.showSideBar }"
3136
routerLinkActive="text-primary"
32-
class="ms-10 truncate text-xs font-semibold tracking-wide focus:outline-hidden">
37+
class="truncate text-xs font-semibold tracking-wide focus:outline-hidden">
3338
{{ item.label }}
3439
</a>
3540
</div>
3641
</ng-template>
3742

3843
<!-- Workaround:: Disable routerLink -->
3944
<ng-template #childMenu let-item="item">
40-
<div class="flex h-[36px] cursor-pointer items-center justify-start rounded-sm">
45+
<div class="flex h-9 grow cursor-pointer items-center justify-start rounded-sm">
4146
<a
42-
class="text-muted-foreground group-hover:text-primary ms-10 truncate text-xs font-semibold tracking-wide focus:outline-hidden">
47+
[ngClass]="{ hidden: !menuService.showSideBar }"
48+
class="text-muted-foreground group-hover:text-primary truncate text-xs font-semibold tracking-wide focus:outline-hidden">
4349
{{ item.label }}
4450
</a>
4551
</div>
@@ -49,7 +55,7 @@
4955
<button
5056
*ngIf="item.children"
5157
[ngClass]="{ hidden: !menuService.showSideBar }"
52-
class="text-foreground/50 pointer-events-none absolute top-1 mx-1 flex items-center p-1 transition-all duration-500 ltr:right-0 rtl:left-0">
58+
class="text-foreground/50 flex cursor-pointer items-center justify-end p-0 transition-all duration-500 ltr:right-0 rtl:left-0">
5359
@if(!item.expanded){
5460
<svg-icon src="assets/icons/heroicons/outline/plus.svg" svgClass="h-4 w-4"> </svg-icon>
5561
}@else {
@@ -58,9 +64,9 @@
5864
</button>
5965

6066
<!-- Tooltip -->
61-
<div class="fixed w-full" *ngIf="!menuService.showSideBar">
67+
<div class="z-1 fixed h-[36px]" *ngIf="!menuService.showSideBar">
6268
<span
63-
class="z-1 bg-foreground text-background absolute -top-[34px] w-auto min-w-max scale-0 rounded-md p-2 text-xs font-bold shadow-md transition-all duration-200 group-hover:scale-100 ltr:left-14 ltr:origin-left rtl:right-14 rtl:origin-right">
69+
class="z-1 bg-foreground text-background absolute w-auto min-w-max translate-y-[2px] scale-0 rounded-md p-2 text-xs font-bold shadow-md transition-all duration-200 group-hover:scale-100 ltr:origin-left ltr:translate-x-10 rtl:origin-right rtl:-translate-x-10">
6470
{{ item.label }}
6571
</span>
6672
</div>
@@ -71,7 +77,7 @@
7177
</li>
7278
</ul>
7379

74-
<div class="pt-3" *ngIf="menu.separator">
80+
<div class="py-3" *ngIf="menu.separator">
7581
<hr class="border-border border-dashed" />
7682
</div>
7783
</div>

src/app/modules/layout/components/sidebar/sidebar-submenu/sidebar-submenu.component.html

+7-10
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
11
<div
2-
class="ps-4 max-h-0 overflow-hidden pt-1 transition-all duration-500"
2+
class="max-h-0 overflow-hidden pt-1 transition-all duration-500 ltr:pl-4 rtl:pr-4"
33
[ngClass]="{ hidden: !menuService.showSideBar, 'max-h-screen': submenu.expanded }">
4-
<ul class="border-border text-muted-foreground relative flex flex-col border-dashed px-2 ltr:border-l rtl:border-r">
4+
<ul
5+
class="border-border text-muted-foreground flex flex-col border-dashed ltr:border-l ltr:pl-2 rtl:border-r rtl:pr-2">
56
<li *ngFor="let sub of submenu.children">
6-
<!-- <span
7-
class="-start-[3px] rtl:start-0 before:size-[6px] bg-primary absolute flex w-[6px] shrink-0 items-center before:absolute before:top-0 before:-translate-y-1/2 before:rounded-full rtl:before:translate-x-1/2">
8-
</span> -->
9-
10-
<div class="text-muted-foreground hover:text-primary flex rounded-sm" (click)="toggleMenu(sub)">
7+
<div class="text-muted-foreground hover:text-primary relative flex" (click)="toggleMenu(sub)">
118
<!-- Condition -->
129
<ng-container
1310
[ngTemplateOutlet]="sub.children ? childMenu : parentMenu"
@@ -20,12 +17,12 @@
2017
[routerLink]="sub.route"
2118
routerLinkActive="text-primary"
2219
[routerLinkActiveOptions]="{ exact: true }"
23-
class="hover:bg-card inline-block w-full px-4 py-2 text-xs">
20+
class="hover:bg-card inline-block w-full rounded-lg px-4 py-2 text-xs">
2421
{{ sub.label }}
2522
</a>
2623
@if(menuService.isActive(sub.route)){
2724
<span
28-
class="size-[6px] bg-primary absolute flex w-[6px] translate-y-[13px] items-center rounded-full ltr:-translate-x-[11px] rtl:translate-x-[11px]">
25+
class="size-1.5 bg-primary absolute flex translate-y-3.5 items-center rounded-full ltr:-translate-x-[11.5px] rtl:translate-x-[11.5px]">
2926
</span>
3027
}
3128
</ng-template>
@@ -37,7 +34,7 @@
3734
</a>
3835
<button
3936
[ngClass]="{ hidden: !menuService.showSideBar }"
40-
class="text-foreground/50 flex cursor-pointer items-center p-1 transition-all duration-500">
37+
class="text-foreground/50 flex cursor-pointer items-center justify-end px-2 transition-all duration-500">
4138
@if(!sub.expanded){
4239
<svg-icon src="assets/icons/heroicons/outline/plus.svg" svgClass="h-4 w-4"> </svg-icon>
4340
}@else {

src/app/modules/layout/components/sidebar/sidebar.component.html

+5-4
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,28 @@
33
class="bg-background hidden h-full flex-col justify-between pt-3 transition-all duration-300 lg:flex">
44
<div class="overflow-hidden">
55
<!-- Logo -->
6-
<div class="relative mx-4 h-9">
6+
<div
7+
[ngClass]="menuService.showSideBar ? 'justify-between' : 'justify-center'"
8+
class="mx-4 mb-2 flex h-9 items-center">
79
<div class="flex items-center" *ngIf="menuService.showSideBar">
810
<a
911
(click)="toggleSidebar()"
1012
class="bg-primary flex cursor-pointer items-center justify-center rounded-sm p-2 focus:outline-hidden focus:ring-1">
1113
<svg-icon src="assets/icons/logo.svg"> </svg-icon>
1214
</a>
13-
<b class="text-foreground ps-2 ml-1 text-sm font-bold">
15+
<b class="text-foreground ps-2 ml-1 grow text-sm font-bold">
1416
{{ appJson.displayName }}
1517
</b>
1618
</div>
1719
<button
1820
(click)="toggleSidebar()"
19-
class="text-muted-foreground/50 hover:text-muted-foreground absolute top-2 flex h-5 w-5 items-center justify-center rounded-sm transition-all duration-200 focus:outline-hidden ltr:right-2 rtl:left-2"
21+
class="text-muted-foreground/50 hover:text-muted-foreground flex items-center justify-center rounded-md p-2 transition-all duration-200 focus:outline-hidden"
2022
[ngClass]="{ 'rotate-180': !menuService.showSideBar }">
2123
<svg-icon src="assets/icons/heroicons/solid/chevron-double-left.svg"> </svg-icon>
2224
</button>
2325
</div>
2426

2527
<!-- Menu Items -->
26-
<!-- <app-sidebar-menu></app-sidebar-menu> -->
2728
<div
2829
class="scrollbar-thumb--sm scrollbar-track-rounded scrollbar-thin scrollbar-track-transparent scrollbar-thumb-card h-full overflow-auto px-4">
2930
<app-sidebar-menu></app-sidebar-menu>

0 commit comments

Comments
 (0)