Skip to content

Commit 3e98107

Browse files
committed
feat: #528 introducing responsive menu
1 parent 4cc9013 commit 3e98107

File tree

5 files changed

+87
-89
lines changed

5 files changed

+87
-89
lines changed

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

Lines changed: 31 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,38 @@
11
<div class="d-flex" id="wrapper">
2-
<!-- Sidebar -->
3-
<div id="sidebar-wrapper" *ngIf="itemsSidebar?.length > 0">
4-
<div class="text-center my-5">
5-
<img src="assets/img/ioet.png" width="70" height="auto" class="img-fluid" alt="ioet logo" />
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" />
65
</div>
7-
<div class="container">
8-
<a
9-
*ngFor="let item of itemsSidebar"
10-
[routerLink]="item.route"
11-
routerLinkActive=""
12-
class="item-hover item"
13-
[ngClass]="{active: item.active}"
14-
>
15-
<i class="{{ item.icon }}"></i> {{ item.text }}
16-
</a>
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>
1716
</div>
1817
</div>
19-
<!-- /#sidebar-wrapper -->
20-
<div class="main_app">
21-
<div class="header_app">
22-
<app-navbar></app-navbar>
23-
</div>
24-
<div class="content_app">
25-
<!-- Page Content -->
26-
<router-outlet></router-outlet>
18+
<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>
32+
<div class="container-fluid">
33+
<div class="content_app">
34+
<router-outlet></router-outlet>
35+
</div>
2736
</div>
2837
</div>
2938
</div>
30-
<!-- /#wrapper -->
Lines changed: 41 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,56 @@
11
@import '../../../../../styles/colors.scss';
22

3-
#wrapper {
4-
height: 100vh;
3+
body {
4+
overflow-x: hidden;
5+
}
56

6-
#sidebar-wrapper {
7-
flex: 0 0 14.5rem;
8-
background-color: #f4f5f7;
9-
z-index: 1;
10-
margin-left: -15rem;
11-
-webkit-transition: margin 0.25s ease-out;
12-
-moz-transition: margin 0.25s ease-out;
13-
-o-transition: margin 0.25s ease-out;
14-
transition: margin 0.25s ease-out;
15-
}
7+
#sidebar-wrapper {
8+
min-height: 100vh;
9+
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;
14+
}
1615

17-
.main_app {
18-
flex: 1;
19-
}
16+
#sidebar-wrapper .sidebar-heading {
17+
padding: 0.875rem 1.25rem;
18+
font-size: 1.2rem;
19+
}
2020

21-
.header_app {
22-
height: 8%;
23-
}
21+
#sidebar-wrapper .list-group {
22+
width: 15rem;
23+
}
2424

25-
.content_app {
26-
height: 92%;
27-
padding: 1rem 3rem;
28-
overflow-y: auto;
29-
}
25+
#page-content-wrapper {
26+
min-width: 100vw;
27+
}
3028

29+
#wrapper.toggled #sidebar-wrapper {
30+
margin-left: 0;
31+
}
3132

32-
.item-hover:hover {
33-
color: #16BAC5;
33+
@media (min-width: 768px) {
34+
#sidebar-wrapper {
35+
margin-left: 0;
3436
}
35-
36-
.active {
37-
color: #16BAC5;
38-
font-weight: bold;
39-
text-decoration: underline;
37+
#page-content-wrapper {
38+
min-width: 0;
39+
width: 100%;
40+
}
41+
#wrapper.toggled #sidebar-wrapper {
42+
margin-left: -15rem;
4043
}
4144
}
4245

43-
.container {
44-
display: grid;
45-
grid-gap: 20px;
46-
justify-content: center;
47-
align-self: center;
48-
49-
.item {
50-
font-size: medium;
51-
color: #555164;
52-
display: grid;
53-
grid-template-columns: 30px 100px;
54-
align-items: center;
55-
}
46+
.content_app {
47+
padding: 5rem 3rem;
48+
overflow-y: auto;
5649
}
5750

58-
@media (min-width: 768px) {
59-
#wrapper {
60-
#sidebar-wrapper {
61-
margin-left: 0;
62-
}
63-
}
51+
.active {
52+
color: $primary;
53+
font-weight: bold;
54+
text-decoration: underline;
55+
border-color: $primary;
6456
}

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {filter} from 'rxjs/operators';
1111
styleUrls: ['./sidebar.component.scss'],
1212
})
1313
export class SidebarComponent implements OnInit {
14+
1415
itemsSidebar: ItemSidebar[] = [];
1516
navStart;
1617

@@ -21,13 +22,21 @@ export class SidebarComponent implements OnInit {
2122
}
2223

2324
ngOnInit(): void {
25+
this.toggleSideBar();
2426
this.getSidebarItems();
2527
this.highlightMenuOption(this.router.routerState.snapshot.url);
2628
this.navStart.subscribe(evt => {
2729
this.highlightMenuOption(evt.url);
2830
});
2931
}
3032

33+
toggleSideBar() {
34+
$('#menu-toggle').on('click', (e) => {
35+
e.preventDefault();
36+
$('#wrapper').toggleClass('toggled');
37+
});
38+
}
39+
3140
getSidebarItems() {
3241
if (this.azureAdB2CService.isAdmin()) {
3342
this.itemsSidebar = [
Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,10 @@
1-
<div>
2-
<a
3-
class="nav-link dropdown-toggle user-profile justify-content-center text-center"
4-
id="navbarDropdown"
5-
role="button"
6-
data-toggle="dropdown"
7-
aria-haspopup="true"
8-
aria-expanded="false"
9-
>
1+
<li class="nav-item active dropdown">
2+
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown"
3+
aria-haspopup="true" aria-expanded="false">
104
<i class="far fa-user-circle"></i>
115
{{name}}
126
</a>
13-
<div class="dropdown-menu style-click" aria-labelledby="navbarDropdown">
14-
<a class="dropdown-item style-click" (click)="logout()">Sign Out</a>
7+
<div class="dropdown-menu dropdown-menu-right" aria-labelledby="navbarDropdown">
8+
<a class="dropdown-item" href="#" (click)="logout()">Sign Out</a>
159
</div>
16-
</div>
10+
</li>

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,6 @@
55
cursor: pointer;
66
}
77

8-
.dropdown-menu {
9-
margin-left: 50%;
10-
transform: translateX(-50%);
11-
}
12-
138
.style-click:active {
149
background-color: $primary;
1510
color: white;

0 commit comments

Comments
 (0)