Skip to content

Commit

Permalink
feat: make menu responsive
Browse files Browse the repository at this point in the history
  • Loading branch information
gion-andri committed Oct 9, 2023
1 parent 64c776a commit fb45297
Show file tree
Hide file tree
Showing 7 changed files with 304 additions and 278 deletions.
10 changes: 10 additions & 0 deletions src/app/components/footer/footer.component.scss
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
@import 'node_modules/bootstrap/scss/functions';
@import 'node_modules/bootstrap/scss/variables';
@import 'node_modules/bootstrap/scss/mixins';

:host {
display: flex;
flex-direction: column-reverse;
justify-content: space-between;
padding-bottom: 20px;
padding-top: 20px;
border-top: 1px solid #BBBFC2;
align-items: center;

@include media-breakpoint-up(md) {
flex-direction: row;

}
}

.links {
Expand Down
42 changes: 20 additions & 22 deletions src/app/components/header/header.component.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
<div class="overlay" (click)="toggleMenu()" [class.active]="isMenuOpen"></div>

<div class="name">
<a href="/">CHALENDER.CH</a>
</div>
Expand All @@ -12,7 +10,7 @@
</div>
<div class="menu">
<div>
<button id="menu-button" [class.opened]="isMenuOpen" (click)="toggleMenu()">
<button id="menu-button" [class.opened]="isMenuOpen" (click)="toggleMenu(menu)">
<svg width="60" height="60" viewBox="0 0 100 100">
<path class="line line1"
d="M 20,29.000046 H 80.000231 C 80.000231,29.000046 94.498839,28.817352 94.532987,66.711331 94.543142,77.980673 90.966081,81.670246 85.259173,81.668997 79.552261,81.667751 75.000211,74.999942 75.000211,74.999942 L 25.000021,25.000058"/>
Expand All @@ -24,56 +22,56 @@
</div>
</div>


<div id="main-menu" class="container" [class.active]="isMenuOpen">
<div class="content">
<ng-template #menu let-offcanvas>
<div class="menu">
<ul class="main-menu-top">
<li><a (click)="toggleMenu()" [routerLink]="'/'">{{ 'COMPONENTS.HEADER.MAIN_MENU.EVENTS' | translate }}</a>
<li><a (click)="toggleMenu(menu)"
[routerLink]="'/'">{{ 'COMPONENTS.HEADER.MAIN_MENU.EVENTS' | translate }}</a>
</li>
<li><a (click)="toggleMenu()"
<li><a (click)="toggleMenu(menu)"
[routerLink]="'/help'">{{ 'COMPONENTS.HEADER.MAIN_MENU.HELP' | translate }}</a></li>
<li><a (click)="toggleMenu()"
<li><a (click)="toggleMenu(menu)"
[routerLink]="'/contact'">{{ 'COMPONENTS.HEADER.MAIN_MENU.CONTACT' | translate }}</a></li>
<li><a (click)="toggleMenu()"
<li><a (click)="toggleMenu(menu)"
[routerLink]="'/organisation'">{{ 'COMPONENTS.HEADER.MAIN_MENU.ORGANISATION' | translate }}</a></li>
<li><a (click)="toggleMenu()"
<li><a (click)="toggleMenu(menu)"
[routerLink]="'/imprint'">{{ 'COMPONENTS.HEADER.MAIN_MENU.IMPRINT' | translate }}</a></li>
<li><a (click)="toggleMenu()"
<li><a (click)="toggleMenu(menu)"
[routerLink]="'/privacy'">{{ 'COMPONENTS.HEADER.MAIN_MENU.PRIVACY' | translate }}</a></li>
</ul>

<ul class="main-menu-bottom" *ngIf="authService.isLoggedIn()">
<li><a (click)="toggleMenu()"
<li><a (click)="toggleMenu(menu)"
[routerLink]="'/admin/events/new'">{{ 'COMPONENTS.HEADER.PROFILE_MENU.NEW_EVENT' | translate }}</a>
</li>
<li><a (click)="toggleMenu()"
<li><a (click)="toggleMenu(menu)"
[routerLink]="'/admin/events'">{{ 'COMPONENTS.HEADER.PROFILE_MENU.MY_EVENTS' | translate }}</a></li>
<li><a (click)="toggleMenu()"
<li><a (click)="toggleMenu(menu)"
[routerLink]="'/admin/subscriptions'">{{ 'COMPONENTS.HEADER.PROFILE_MENU.MY_ABOS' | translate }}</a>
</li>
<li><a (click)="toggleMenu()"
<li><a (click)="toggleMenu(menu)"
[routerLink]="'/admin/profile'">{{ 'COMPONENTS.HEADER.PROFILE_MENU.PROFILE' | translate }}</a></li>
<li><a (click)="toggleMenu()"
<li><a (click)="toggleMenu(menu)"
[routerLink]="'/u/logout'">{{ 'COMPONENTS.HEADER.PROFILE_MENU.LOGOUT' | translate }}</a></li>
<li *ngIf="authService.isModerator() || authService.isAdmin()" class="section-title">
<hr>
{{ 'COMPONENTS.HEADER.ADMIN.ADMIN' | translate }}
</li>
<li *ngIf="authService.isModerator()">
<a (click)="toggleMenu()"
<a (click)="toggleMenu(menu)"
href="/moderator/events">{{ 'COMPONENTS.HEADER.ADMIN.EVENTS' | translate }}</a>
</li>
<li *ngIf="authService.isAdmin()">
<a (click)="toggleMenu()"
<a (click)="toggleMenu(menu)"
href="/administrator/users">{{ 'COMPONENTS.HEADER.ADMIN.USERS' | translate }}</a>
</li>
</ul>

<ul class="main-menu-bottom" *ngIf="!authService.isLoggedIn()">
<li><a (click)="toggleMenu()"
<li><a (click)="toggleMenu(menu)"
[routerLink]="'/u/login'">{{ 'COMPONENTS.HEADER.SIGNUP.LOGIN' | translate }}</a></li>
<li><a (click)="toggleMenu()"
<li><a (click)="toggleMenu(menu)"
[routerLink]="'/u/events'">{{ 'COMPONENTS.HEADER.SIGNUP.NEW_EVENT' | translate }}</a></li>
</ul>
</div>
</div>
</ng-template>
180 changes: 49 additions & 131 deletions src/app/components/header/header.component.scss
Original file line number Diff line number Diff line change
@@ -1,149 +1,67 @@
@import 'node_modules/bootstrap/scss/functions';
@import 'node_modules/bootstrap/scss/variables';
@import 'node_modules/bootstrap/scss/mixins';

:host {
display: flex;
flex-direction: row;
align-items: center;
justify-content: space-between;
font-family: CadizBlack, sans-serif;
height: 124px;
border-bottom: 1px solid #BBBFC2;
display: flex;
flex-direction: row;
align-items: center;
justify-content: space-between;
font-family: CadizBlack, sans-serif;
height: 124px;
border-bottom: 1px solid #BBBFC2;

a {
color: black;
text-decoration: none;
}
a {
color: black;
text-decoration: none;
}
}

.name {
font-size: 38px;
margin-left: 1.5rem;
font-size: 19px;
margin-left: 1.5rem;
@include media-breakpoint-up(sm) {
font-size: 38px;
}
}

.short-menu {
flex: none;

ul {
list-style: none;
margin: 0;
padding: 0;
display: flex;
flex-direction: row;

li {
padding: 0.5rem;
display: none;
flex: none;

ul {
list-style: none;
margin: 0;
padding: 0;
display: flex;
flex-direction: row;

li {
padding: 0.5rem;
}
}
}
}

#menu-button {
margin-right: 1.5rem;
position: relative;
z-index: 90;
background-color: transparent;
border: none;
cursor: pointer;
display: flex;
padding: 0;
width: 60px;
height: 60px;
}

#main-menu {
padding: 0;
position: absolute;
margin: 0 auto;
height: 600px;
top: -600px;
transition: all 200ms ease-in-out;
z-index: 60;
width: 1280px;

ul {
list-style: none;
margin: 0;
padding: 2rem;
font-size: 1.875rem;
line-height: 2.25rem;

li {
padding-bottom: 0.5rem;
}
}

ul:nth-of-type(2) {
font-size: 1.5rem;
line-height: 2rem;
}

&.active {
top: 0;
}

.content {
background-color: var(--accent);
gap: 300px;
padding: 70px 150px;
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
}

a {
display: inline-block;
margin-right: 1.5rem;
position: relative;
color: white;
}

a:after {
content: '';
position: absolute;
width: 100%;
transform: scaleX(0);
height: 2px;
bottom: 0;
left: 0;
background-color: white;
transform-origin: bottom right;
transition: transform 0.25s ease-out;
}

a:hover:after {
transform: scaleX(1);
transform-origin: bottom left;
}

.main-menu-top {
font-family: CadizBlack, sans-serif;
}

.main-menu-bottom {
font-family: Cadiz, sans-serif;
}
}

.overlay {
width: 100%;
height: 100%;
position: absolute;
left: 0;
top: 0;
background-color: rgba(0, 0, 0, .3);
z-index: 50;
opacity: 0;
visibility: hidden;
transition: all 200ms ease-in;

&.active {
opacity: 1;
visibility: visible;
}
z-index: 1046;
background-color: transparent;
border: none;
cursor: pointer;
display: flex;
padding: 0;
width: 60px;
height: 60px;
}

.section-title {
font-size: 14px;
color: white;
font-size: 14px;
color: white;

hr {
border-top: 1px solid white;
opacity: 1;
margin-bottom: 0;
}
hr {
border-top: 1px solid white;
opacity: 1;
margin-bottom: 0;
}
}
38 changes: 27 additions & 11 deletions src/app/components/header/header.component.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,34 @@
import {Component} from '@angular/core';
import {AuthenticationService} from "../../services/authentication.service";
import { Component, TemplateRef } from '@angular/core';
import { AuthenticationService } from "../../services/authentication.service";
import { NgbOffcanvas } from '@ng-bootstrap/ng-bootstrap';

@Component({
selector: 'app-header',
templateUrl: './header.component.html',
styleUrls: ['./header.component.scss']
selector: 'app-header',
templateUrl: './header.component.html',
styleUrls: ['./header.component.scss']
})
export class HeaderComponent {
public isMenuOpen = false;
public isMenuOpen = false;

constructor(public authService: AuthenticationService) {
}
constructor(
private offcanvasService: NgbOffcanvas,
public authService: AuthenticationService,
) {
}

toggleMenu(): void {
this.isMenuOpen = !this.isMenuOpen;
}
toggleMenu(content: TemplateRef<any>): void {
this.isMenuOpen = !this.isMenuOpen;

if (this.isMenuOpen) {
const offCanvas = this.offcanvasService.open(content, {
position: 'top',
panelClass: 'menu-panel',
});
offCanvas.dismissed.subscribe(() => {
this.isMenuOpen = false;
});
} else {
this.offcanvasService.dismiss();
}
}
}
2 changes: 2 additions & 0 deletions src/app/pages/events/events-list/events-list.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,6 @@ <h2>{{cat.formattedDate}}</h2>
</button>
</div>

<!--
<app-new-event-button/>
-->
Loading

0 comments on commit fb45297

Please sign in to comment.