Skip to content

Commit 5310f5b

Browse files
author
Edgar Guaman
committed
refactor: TT-331 Redesign of the sidebar
1 parent 0125ac6 commit 5310f5b

File tree

16 files changed

+133
-53
lines changed

16 files changed

+133
-53
lines changed
Lines changed: 44 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,54 @@
11
<div class="d-flex" id="wrapper">
2-
<div class="bg-light border-right" id="sidebar-wrapper">
3-
<div class="sidebar-heading" style="text-align: center">
4-
<img src="assets/img/ioet.png" width="90" height="auto" style="padding-top: 2rem; padding-bottom: 2rem;" alt="logo" />
5-
</div>
6-
<div class="list-group list-group-flush">
7-
<a
8-
*ngFor="let item of itemsSidebar"
9-
[routerLink]="item.route"
10-
routerLinkActive=""
11-
class="list-group-item list-group-item-action bg-light"
12-
[ngClass]="{active: item.active}"
13-
>
14-
<i class="{{ item.icon }}"></i> {{ item.text }}
15-
</a>
2+
<div class="table-row bg-white border-r border-grey-500" id="sidebar-wrapper">
3+
<div class="table-cell">
4+
<div class="relative flex items-center border-b border-grey-500 sidebar-heading">
5+
<img src="assets/img/ioet-logo-without-letters.png" width="40" height="auto" style="padding-top: 0.5rem; padding-left: 1rem;" alt="logo"/>
6+
<h1 class="pl-2 pt-2" style="font-family:spinnaker,sans-serif">ioet</h1>
7+
</div>
8+
<div class=" py-8 flex items-center pl-3">
9+
<img src="assets/icons/user.svg" width="40" height="40"/>
10+
<span class="pl-1">
11+
<h2 class="font-sans text-base font-semibold">{{userName}}</h2>
12+
<p class="font-sans mt-1 text-xs font-medium text-grey dark:text-gray-400">{{userEmail}}</p>
13+
</span>
14+
</div>
15+
<div class="list-group list-group-flush">
16+
<a
17+
*ngFor="let item of itemsSidebar"
18+
[routerLink]="item.route"
19+
routerLinkActive=""
20+
class="font-sans relative pl-4 py-3 bg-white"
21+
[ngClass]="{active: item.active}"
22+
>
23+
<img src="{{item.icon}}" width="22" height="22" class="absolute"/>
24+
<h3 class="font-sans text-base pl-5 text-left" >{{ item.text }}</h3>
25+
<!-- <i class="{{ item.icon }} pr-3"></i> {{ item.text }} -->
26+
</a>
27+
<div class="bg-white pt-2 pr-24 absolute bottom-0">
28+
<a class="flex pl-4 mb-4 text-black-dark hover:text-gray-800" href="#">
29+
<img src="assets/icons/signout.svg" width="25" height="25"/>
30+
<span class="font-sans pl-4 font-medium" (click)="logout()">Sign out</span>
31+
</a>
32+
</div>
33+
</div>
1634
</div>
35+
<div class="table-cell relative">
36+
<span class="absolute cursor-pointer inset-y-0 right-0 min-h-screen w-0.5 hover:z-0 hover:bg-blue-400" (click)="toggleSideBar()"></span>
37+
<span class="group cursor-pointer absolute w-5 top-20 -right-3">
38+
<img src="assets/icons/left-chevron.svg" id="hide-sidebar" (click)="toggleSideBar()" width="20" height="20" class="bg-black-light rounded-full hover:bg-opacity-50 hover:bg-info-light sm:hidden md:block lg:block"/>
39+
<div class="opacity-0 w-12 bg-black text-white text-center text-xs rounded-lg py-2 absolute z-10 group-hover:opacity-100 bottom-full left-1/4 ml-4 -mb-6 px-1 pointer-events-none">Hide</div>
40+
</span>
41+
<span class="group cursor-pointer absolute top-20 -right-5">
42+
<img src="assets/icons/right-chevron.svg" id="show-sidebar" (click)="toggleSideBar()" width="20" height="20" class="bg-black-light rounded-full hover:bg-opacity-50 hover:bg-info-light sm:block md:hidden lg:hidden"/>
43+
<div class="opacity-0 w-12 bg-black text-white text-center text-xs rounded-lg py-2 absolute z-10 group-hover:opacity-100 bottom-full left-1/4 ml-4 -mb-6 px-1 pointer-events-none">Show</div>
44+
</span>
1745
</div>
46+
</div>
1847
<div id="page-content-wrapper">
19-
<nav class="navbar navbar-expand-lg navbar-light border-bottom">
20-
<button class="btn btn-primary" id="menu-toggle">
21-
Toggle Menu
22-
</button>
23-
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
24-
<span class="navbar-toggler-icon"></span>
25-
</button>
26-
<div class="collapse navbar-collapse" id="navbarSupportedContent">
27-
<ul class="navbar-nav ml-auto mt-2 mt-lg-0">
28-
<app-user></app-user>
29-
</ul>
30-
</div>
31-
</nav>
3248
<div class="container-fluid px-0 full-height">
3349
<div class="content_app h-100">
3450
<router-outlet></router-outlet>
3551
</div>
3652
</div>
3753
</div>
38-
</div>
54+
</div>

src/app/modules/shared/components/sidebar/sidebar.component.scss

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ body {
77
#sidebar-wrapper {
88
min-height: 100vh;
99
margin-left: -15rem;
10-
-webkit-transition: margin .25s ease-out;
11-
-moz-transition: margin .25s ease-out;
12-
-o-transition: margin .25s ease-out;
13-
transition: margin .25s ease-out;
10+
-webkit-transition: margin 0.25s ease-out;
11+
-moz-transition: margin 0.25s ease-out;
12+
-o-transition: margin 0.25s ease-out;
13+
transition: margin 0.25s ease-out;
1414
}
1515

1616
#sidebar-wrapper .sidebar-heading {
@@ -30,7 +30,7 @@ body {
3030
margin-left: 0;
3131
}
3232

33-
@media (min-width: 883px) {
33+
@media (min-width: 769px) {
3434
#sidebar-wrapper {
3535
margin-left: 0;
3636
}
@@ -41,6 +41,21 @@ body {
4141
#wrapper.toggled #sidebar-wrapper {
4242
margin-left: -15rem;
4343
}
44+
#hide-sidebar {
45+
display: block;
46+
}
47+
#show-sidebar {
48+
display: none;
49+
}
50+
}
51+
52+
@media (max-width: 768px) {
53+
#hide-sidebar {
54+
display: none;
55+
}
56+
#show-sidebar {
57+
display: block;
58+
}
4459
}
4560

4661
.content_app {

src/app/modules/shared/components/sidebar/sidebar.component.spec.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ describe('SidebarComponent', () => {
3333
TestBed.configureTestingModule({
3434
declarations: [SidebarComponent],
3535
providers: [
36-
{ provide: AzureAdB2CService, useValue: azureAdB2CServiceStub },
36+
AzureAdB2CService,
3737
{ provide: UserInfoService, useValue: userInfoServiceStub },
3838
],
3939
imports: [RouterTestingModule.withRoutes(routes)],
@@ -83,4 +83,10 @@ describe('SidebarComponent', () => {
8383
});
8484
});
8585

86+
it('uses the Azure service on logout', () => {
87+
spyOn(azureAdB2CServiceStubInjected, 'logout');
88+
component.logout();
89+
expect(azureAdB2CServiceStubInjected.logout).toHaveBeenCalled();
90+
});
91+
8692
});

src/app/modules/shared/components/sidebar/sidebar.component.ts

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,70 +4,76 @@ import { NavigationStart, Router } from '@angular/router';
44
import { Observable, Subscription } from 'rxjs';
55
import { filter, map } from 'rxjs/operators';
66
import { UserInfoService } from 'src/app/modules/user/services/user-info.service';
7-
7+
import { AzureAdB2CService } from '../../../login/services/azure.ad.b2c.service';
88
@Component({
99
selector: 'app-sidebar',
1010
templateUrl: './sidebar.component.html',
1111
styleUrls: ['./sidebar.component.scss'],
1212
})
1313
export class SidebarComponent implements OnInit, OnDestroy {
14-
itemsSidebar: ItemSidebar[] = [];
14+
itemsSidebar: ItemSidebar[];
1515
navStart;
1616
sidebarItems$: Subscription;
17+
userName: string;
18+
userEmail: string;
1719

18-
constructor(
19-
private router: Router,
20-
private userInfoService: UserInfoService,
21-
) {
20+
constructor(private router: Router, private userInfoService: UserInfoService, private azureAdB2CService: AzureAdB2CService) {
2221
this.navStart = this.router.events.pipe(
2322
filter((evt) => evt instanceof NavigationStart)
2423
) as Observable<NavigationStart>;
2524
}
2625

2726
ngOnInit(): void {
28-
this.toggleSideBar();
2927
const currentRouting = this.router.routerState.snapshot.url;
3028
this.sidebarItems$ = this.getSidebarItems().subscribe(() => this.highlightMenuOption(currentRouting));
3129
this.navStart.subscribe((evt) => {
3230
this.highlightMenuOption(evt.url);
3331
});
32+
if (this.azureAdB2CService.isLogin()) {
33+
this.userName = this.azureAdB2CService.getName();
34+
this.userEmail = this.azureAdB2CService.getUserEmail();
35+
}
3436
}
3537

3638
ngOnDestroy(): void {
3739
this.sidebarItems$.unsubscribe();
3840
}
3941

4042
toggleSideBar() {
41-
$('#menu-toggle').on('click', (e) => {
42-
e.preventDefault();
43-
$('#wrapper').toggleClass('toggled');
44-
});
43+
$('#wrapper').toggleClass('toggled');
44+
$('#show-sidebar').toggle();
45+
$('#hide-sidebar').toggle();
4546
}
4647

4748
getSidebarItems(): Observable<void> {
4849
return this.userInfoService.isAdmin().pipe(
4950
map((isAdmin) => {
5051
if (isAdmin) {
5152
this.itemsSidebar = [
52-
{ route: '/time-clock', icon: 'fas fa-clock', text: 'Time Clock', active: false },
53-
{ route: '/time-entries', icon: 'fas fa-list-alt', text: 'Time Entries', active: false },
54-
{ route: '/reports', icon: 'fas fa-chart-pie', text: 'Reports', active: false },
55-
{ route: '/activities-management', icon: 'fas fa-file-alt', text: 'Activities', active: false },
56-
{ route: '/customers-management', icon: 'fas fa-user', text: 'Customers', active: false },
57-
{ route: '/users', icon: 'fas fa-user', text: 'Users', active: false },
53+
{ route: '/time-clock', icon: 'assets/icons/clock.svg', text: 'Time Clock', active: false },
54+
{ route: '/time-entries', icon: 'assets/icons/time-entries.svg', text: 'Time Entries', active: false },
55+
{ route: '/reports', icon: 'assets/icons/reports.svg', text: 'Reports', active: false },
56+
{ route: '/activities-management', icon: 'assets/icons/activities.svg', text: 'Activities', active: false },
57+
{ route: '/customers-management', icon: 'assets/icons/customers.svg', text: 'Customers', active: false },
58+
{ route: '/users', icon: 'assets/icons/users.svg', text: 'Users', active: false },
5859
];
5960
} else {
6061
this.itemsSidebar = [
61-
{ route: '/time-clock', icon: 'fas fa-clock', text: 'Time Clock', active: false },
62-
{ route: '/time-entries', icon: 'fas fa-list-alt', text: 'Time Entries', active: false },
62+
{ route: '/time-clock', icon: 'assets/icons/clock.svg', text: 'Time Clock', active: false },
63+
{ route: '/time-entries', icon: 'assets/icons/time-entries.svg', text: 'Time Entries', active: false },
6364
];
6465
}
6566
})
6667
);
6768
}
6869

70+
6971
highlightMenuOption(route) {
7072
this.itemsSidebar.map((item) => (item.active = false));
7173
this.itemsSidebar.filter((item) => item.route === route).map((item) => (item.active = true));
7274
}
75+
76+
logout() {
77+
this.azureAdB2CService.logout();
78+
}
7379
}

src/assets/icons/activities.svg

Lines changed: 3 additions & 0 deletions
Loading

src/assets/icons/clock.svg

Lines changed: 3 additions & 0 deletions
Loading

src/assets/icons/customers.svg

Lines changed: 3 additions & 0 deletions
Loading

src/assets/icons/left-chevron.svg

Lines changed: 5 additions & 0 deletions
Loading

src/assets/icons/reports.svg

Lines changed: 3 additions & 0 deletions
Loading

src/assets/icons/right-chevron.svg

Lines changed: 5 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)