Skip to content

Commit

Permalink
Merge pull request #3 from Babali42/responsive
Browse files Browse the repository at this point in the history
Responsive et factorisation des liens dans le menu
  • Loading branch information
Babali42 authored Jan 28, 2024
2 parents 1c23634 + 0ea0105 commit 4eaa9a8
Show file tree
Hide file tree
Showing 6 changed files with 97 additions and 33 deletions.
42 changes: 23 additions & 19 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"private": true,
"dependencies": {
"@angular/animations": "^14.0.0",
"@angular/cdk": "^14.2.7",
"@angular/common": "^14.0.0",
"@angular/compiler": "^14.0.0",
"@angular/core": "^14.0.0",
Expand Down
20 changes: 9 additions & 11 deletions src/app/app.component.html
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
<div class="flex main-container">
<div class="flex column left-menu">
<div class="main-container" [ngClass]="{'flex': !isMobileDisplay}">
<div class="flex column left-menu" *ngIf="!isMobileDisplay">
<div class="header"> DRUMS<br> PATTERN<br> LIBRARY</div>
<div class="flex menu">
<a class="button" routerLink="/techno">Techno</a>
<a class="button" routerLink="/drum-n-bass">Drum & Bass</a>
<a class="button" routerLink="/garage">Garage - 2 step</a>
<a class="button" routerLink="/psytrance">Psytrance</a>
<a class="button" routerLink="/metal">Metal</a>
<a class="button" routerLink="/rock">Rock</a>
<a class="button" routerLink="/rock-variation">Rock variation</a>
<a class="button" routerLink="/half-time-groove">Half time groove</a>
<a class="button" [routerLink]="link.link" *ngFor="let link of links">{{ link.label }}</a>
</div>
</div>
<div *ngIf="isMobileDisplay">
<div class="header-mobile">DRUMS PATTERN LIBRARY</div>
<div class="flex mobile-menu">
<a class="item" [routerLink]="link.link" *ngFor="let link of links">{{ link.label }}</a>
</div>
</div>

<div class="content">
<router-outlet></router-outlet>
</div>
Expand Down
28 changes: 28 additions & 0 deletions src/app/app.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,31 @@
.left-menu {
border-right: solid 1px black;
}

.nowrap{
white-space: nowrap;
}

.mobile-menu {
width: 100%;
overflow-x: auto;
gap: 5px;

a {
all: unset;
}

.item{
white-space: nowrap;
background-color: darkgrey;
color: white;
border-radius: 15px;
padding: 10px;
}
}

.header-mobile{
font-size: 30px;
width: 100%;
text-align: center;
}
30 changes: 27 additions & 3 deletions src/app/app.component.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,34 @@
import { Component } from '@angular/core';
import {Component, OnInit} from '@angular/core';
import {BreakpointObserver, Breakpoints} from '@angular/cdk/layout';
import {Link} from "./models/link";

@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss']
})
export class AppComponent {
title = 'DrumsPatternLibrary';
export class AppComponent implements OnInit {
isMobileDisplay: boolean = true;
links: Link[] = [
new Link("Techno", "/techno"),
new Link("Drum & Bass", "/drum-n-bass"),
new Link("Garage - 2 step", "/garage"),
new Link("Psytrance", "/psytrance"),
new Link("Metal", "/metal"),
new Link("Rock", "/rock"),
new Link("Rock variation", "/rock-variation"),
new Link("Half time groove", "/half-time-groove")
]

constructor(private responsive: BreakpointObserver) {
}

ngOnInit(): void {
this.responsive.observe([
Breakpoints.Web,
])
.subscribe(result => {
this.isMobileDisplay = !result.matches;
});
}
}
9 changes: 9 additions & 0 deletions src/app/models/link.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export class Link {
label: string;
link: string;

constructor(label: string, link: string) {
this.label = label;
this.link = link;
}
}

0 comments on commit 4eaa9a8

Please sign in to comment.