Skip to content

Commit 36959f8

Browse files
committed
Show menu on first visit, and remember last state
1 parent 0751cf4 commit 36959f8

File tree

3 files changed

+44
-9
lines changed

3 files changed

+44
-9
lines changed

src/app/app.component.css

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,34 @@
22
.main-container {
33
width: 100%;
44
height: 100%;
5-
/*border: 10px solid yellow;*/
65
}
76

87
.sidenav-content {
98
display: flex;
109
padding: 10px;
11-
align-items: left;
12-
justify-content: left;
13-
/*background-color: red;*/
10+
justify-content: space-between;
1411
}
1512

16-
.example-sidenav {
13+
.sidenav-menu {
1714
padding: 20px;
1815
}
1916

17+
.menu-close {
18+
position: absolute;
19+
right: 0;
20+
top: 2px;
21+
background: transparent;
22+
border: 0;
23+
color: #ddd;
24+
}
25+
2026
.github-fork-ribbon:before {
2127
background-color: #333;
2228
}
29+
30+
@media only screen and (max-width: 750px) {
31+
.github-fork-ribbon {
32+
display: none;
33+
}
34+
35+
}

src/app/app.component.html

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,18 @@
11
<mat-drawer-container class="main-container" autosize>
2-
<mat-drawer #drawer class="example-sidenav" mode="side">
2+
<mat-drawer
3+
#drawer
4+
class="sidenav-menu"
5+
mode="side"
6+
opened="{{ menuIsOpen }}">
7+
<button class="menu-close" (click)="toggleMenu()">
8+
<mat-icon class="white-icon">close</mat-icon>
9+
</button>
310
<a routerLink="/"><app-logo></app-logo></a>
411
<app-sidenav-buttons></app-sidenav-buttons>
512
</mat-drawer>
613

714
<div class="sidenav-content">
8-
<button type="button" mat-button (click)="drawer.toggle()" color="primary">
15+
<button type="button" mat-button (click)="toggleMenu()" color="primary">
916
<mat-icon>menu</mat-icon>
1017
</button>
1118
<a

src/app/app.component.ts

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,25 @@
1-
import { Component } from '@angular/core';
1+
import { Component, OnInit } from '@angular/core';
22

33
@Component({
44
selector: 'app-root',
55
templateUrl: './app.component.html',
66
styleUrls: ['./app.component.css'],
77
})
8-
export class AppComponent {
8+
export class AppComponent implements OnInit {
99
title = 'DSOMM';
10+
menuIsOpen: boolean = true;
11+
12+
ngOnInit(): void {
13+
let menuState: string | null = localStorage.getItem('state.menuIsOpen');
14+
if (menuState === 'false') {
15+
setTimeout(() => {
16+
this.menuIsOpen = false;
17+
}, 600);
18+
}
19+
}
20+
21+
toggleMenu(): void {
22+
this.menuIsOpen = !this.menuIsOpen;
23+
localStorage.setItem('state.menuIsOpen', this.menuIsOpen.toString());
24+
}
1025
}

0 commit comments

Comments
 (0)