Skip to content

Commit 1c3ecc6

Browse files
committed
sidebar done
1 parent cfa1159 commit 1c3ecc6

14 files changed

+179
-5
lines changed

angular/src/app/app.component.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
<div class="wrapper">
22
<app-header></app-header>
3+
<sidebar></sidebar>
34
<div class="content-wrapper">
45
<router-outlet></router-outlet>
56
</div>
67
<app-footer></app-footer>
8+
<div id="sidebar-overlay" (click)="toggleSidebar()"></div>
79
</div>

angular/src/app/app.component.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
11
import { Component, Injector, OnInit, Renderer2 } from '@angular/core';
22
import { AppComponentBase } from '@shared/app-component-base';
33
import { SignalRAspNetCoreHelper } from '@shared/helpers/SignalRAspNetCoreHelper';
4+
import { LayoutStoreService } from '@shared/layout/layout-store.service';
45

56
@Component({
67
templateUrl: './app.component.html'
78
})
89
export class AppComponent extends AppComponentBase implements OnInit {
910
sidebarExpanded: boolean;
1011

11-
constructor(injector: Injector, private renderer: Renderer2) {
12+
constructor(
13+
injector: Injector,
14+
private renderer: Renderer2,
15+
private _layoutStore: LayoutStoreService
16+
) {
1217
super(injector);
1318
}
1419

@@ -31,5 +36,13 @@ export class AppComponent extends AppComponentBase implements OnInit {
3136
}
3237
});
3338
});
39+
40+
this._layoutStore.sidebarExpanded.subscribe((value) => {
41+
this.sidebarExpanded = value;
42+
});
43+
}
44+
45+
toggleSidebar(): void {
46+
this._layoutStore.setSidebarExpanded(!this.sidebarExpanded);
3447
}
3548
}

angular/src/app/app.module.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ import { HeaderLeftNavbarComponent } from './layout/header-left-navbar.component
4141
import { HeaderLanguageMenuComponent } from './layout/header-language-menu.component';
4242
import { HeaderUserMenuComponent } from './layout/header-user-menu.component';
4343
import { FooterComponent } from './layout/footer.component';
44+
import { SidebarComponent } from './layout/sidebar.component';
45+
import { SidebarLogoComponent } from './layout/sidebar-logo.component';
46+
import { SidebarUserPanelComponent } from './layout/sidebar-user-panel.component';
4447

4548
@NgModule({
4649
declarations: [
@@ -70,6 +73,9 @@ import { FooterComponent } from './layout/footer.component';
7073
HeaderLanguageMenuComponent,
7174
HeaderUserMenuComponent,
7275
FooterComponent,
76+
SidebarComponent,
77+
SidebarLogoComponent,
78+
SidebarUserPanelComponent
7379
],
7480
imports: [
7581
CommonModule,

angular/src/app/layout/header-left-navbar.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<ul class="navbar-nav">
22
<li class="nav-item">
3-
<a class="nav-link" href="javascript:;">
3+
<a class="nav-link" href="javascript:;" (click)="toggleSidebar()">
44
<i class="fas fa-bars"></i>
55
</a>
66
</li>
Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,23 @@
1-
import { Component, ChangeDetectionStrategy } from '@angular/core';
1+
import { Component, ChangeDetectionStrategy, OnInit } from '@angular/core';
2+
import { LayoutStoreService } from '@shared/layout/layout-store.service';
23

34
@Component({
45
selector: 'header-left-navbar',
56
templateUrl: './header-left-navbar.component.html',
67
changeDetection: ChangeDetectionStrategy.OnPush
78
})
8-
export class HeaderLeftNavbarComponent {}
9+
export class HeaderLeftNavbarComponent implements OnInit {
10+
sidebarExpanded: boolean;
11+
12+
constructor(private _layoutStore: LayoutStoreService) {}
13+
14+
ngOnInit(): void {
15+
this._layoutStore.sidebarExpanded.subscribe((value) => {
16+
this.sidebarExpanded = value;
17+
});
18+
}
19+
20+
toggleSidebar(): void {
21+
this._layoutStore.setSidebarExpanded(!this.sidebarExpanded);
22+
}
23+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<a class="brand-link" [routerLink]="['home']">
2+
<img
3+
src="assets/img/logo.png"
4+
alt="Logo"
5+
class="brand-image img-circle elevation-3"
6+
style="opacity: 0.8;"
7+
/>
8+
<span class="brand-text font-weight-light">AbpProjectName</span>
9+
</a>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { Component, ChangeDetectionStrategy } from '@angular/core';
2+
3+
@Component({
4+
selector: 'sidebar-logo',
5+
templateUrl: './sidebar-logo.component.html',
6+
changeDetection: ChangeDetectionStrategy.OnPush
7+
})
8+
export class SidebarLogoComponent {}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<div class="user-panel mt-3 pb-3 mb-3 d-flex">
2+
<div class="image">
3+
<img
4+
src="assets/img/user.png"
5+
class="img-circle elevation-2"
6+
alt="User Image"
7+
/>
8+
</div>
9+
<div class="info">
10+
<a class="d-block" href="javascript:;">{{ shownLoginName }}</a>
11+
</div>
12+
</div>
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import {
2+
Component,
3+
ChangeDetectionStrategy,
4+
Injector,
5+
OnInit
6+
} from '@angular/core';
7+
import { AppComponentBase } from '@shared/app-component-base';
8+
9+
@Component({
10+
selector: 'sidebar-user-panel',
11+
templateUrl: './sidebar-user-panel.component.html',
12+
changeDetection: ChangeDetectionStrategy.OnPush
13+
})
14+
export class SidebarUserPanelComponent extends AppComponentBase
15+
implements OnInit {
16+
shownLoginName = '';
17+
18+
constructor(injector: Injector) {
19+
super(injector);
20+
}
21+
22+
ngOnInit() {
23+
this.shownLoginName = this.appSession.getShownLoginName();
24+
}
25+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<aside class="main-sidebar sidebar-dark-primary elevation-4">
2+
<sidebar-logo></sidebar-logo>
3+
<div class="sidebar">
4+
<sidebar-user-panel></sidebar-user-panel>
5+
</div>
6+
</aside>

0 commit comments

Comments
 (0)