Skip to content

Commit 10ef33a

Browse files
authored
Merge pull request #4 from Babali42/navigation
Amélioration navigation
2 parents 4eaa9a8 + 56e46ea commit 10ef33a

7 files changed

+92
-39
lines changed

src/app/app.component.html

+14-4
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,24 @@
11
<div class="main-container" [ngClass]="{'flex': !isMobileDisplay}">
22
<div class="flex column left-menu" *ngIf="!isMobileDisplay">
33
<div class="header"> DRUMS<br> PATTERN<br> LIBRARY</div>
4-
<div class="flex menu">
5-
<a class="button" [routerLink]="link.link" *ngFor="let link of links">{{ link.label }}</a>
6-
</div>
4+
<div class="flex menu genre">
5+
<h2>1 - Choisir un genre</h2>
6+
<div class="button pointer" *ngFor="let genre of musicGenres; let i = index;" (click)="selectGenre(i)" [ngClass]="{'selected':i==selectedGenreIndex}">{{ genre.label }}</div>
7+
</div>
8+
<div class="flex menu">
9+
<h2>2 - Choisir un sous-genre</h2>
10+
<div class="button pointer" [routerLink]="subgenre.link"
11+
*ngFor="let subgenre of musicGenres[selectedGenreIndex].subGenres; let i = index;" (click)="selectSubGenre(i)" [ngClass]="{'selected':i==selectedSubGenreIndex}">{{ subgenre.label }}</div>
12+
</div>
713
</div>
814
<div *ngIf="isMobileDisplay">
915
<div class="header-mobile">DRUMS PATTERN LIBRARY</div>
1016
<div class="flex mobile-menu">
11-
<a class="item" [routerLink]="link.link" *ngFor="let link of links">{{ link.label }}</a>
17+
<a class="item" *ngFor="let genre of musicGenres; let i = index" (click)="selectGenre(i)">{{ genre.label }}</a>
18+
</div>
19+
<div class="flex mobile-menu">
20+
<a class="item" [routerLink]="subGenre.link"
21+
*ngFor="let subGenre of musicGenres[selectedGenreIndex].subGenres">{{ subGenre.label }}</a>
1222
</div>
1323
</div>
1424
<div class="content">

src/app/app.component.scss

+30-15
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,48 @@
1-
.flex{
1+
.flex {
22
display: flex;
33
height: 100%;
44
}
55

6-
.menu{
6+
.menu {
77
flex-direction: column;
8-
justify-content: center;
9-
align-content: center;
10-
text-align: right;
8+
justify-content: flex-start;
9+
align-items: flex-start;
10+
11+
&.genre {
12+
justify-content: flex-end;
13+
}
14+
15+
.button{
16+
border-radius: 5px;
17+
width: 90%;
18+
padding: 5px;
19+
20+
&.selected{
21+
background-color: black;
22+
color: white;
23+
}
24+
}
1125
}
1226

13-
.content{
27+
.content {
1428
width: 100%;
1529
}
1630

1731
.header {
18-
width: 140px;
32+
width: 240px;
1933
font-size: 30px;
2034
}
2135

22-
.column{
36+
.column {
2337
flex-direction: column;
2438
}
2539

2640
.left-menu {
2741
border-right: solid 1px black;
42+
padding: 10px;
2843
}
2944

30-
.nowrap{
45+
.nowrap {
3146
white-space: nowrap;
3247
}
3348

@@ -36,11 +51,7 @@
3651
overflow-x: auto;
3752
gap: 5px;
3853

39-
a {
40-
all: unset;
41-
}
42-
43-
.item{
54+
.item {
4455
white-space: nowrap;
4556
background-color: darkgrey;
4657
color: white;
@@ -49,8 +60,12 @@
4960
}
5061
}
5162

52-
.header-mobile{
63+
.header-mobile {
5364
font-size: 30px;
5465
width: 100%;
5566
text-align: center;
5667
}
68+
69+
.pointer {
70+
cursor: pointer;
71+
}

src/app/app.component.ts

+33-11
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import {Component, OnInit} from '@angular/core';
22
import {BreakpointObserver, Breakpoints} from '@angular/cdk/layout';
3-
import {Link} from "./models/link";
3+
import {Subgenre} from "./models/subgenre";
4+
import {Genre} from "./models/genre";
45

56
@Component({
67
selector: 'app-root',
@@ -9,16 +10,29 @@ import {Link} from "./models/link";
910
})
1011
export class AppComponent implements OnInit {
1112
isMobileDisplay: boolean = true;
12-
links: Link[] = [
13-
new Link("Techno", "/techno"),
14-
new Link("Drum & Bass", "/drum-n-bass"),
15-
new Link("Garage - 2 step", "/garage"),
16-
new Link("Psytrance", "/psytrance"),
17-
new Link("Metal", "/metal"),
18-
new Link("Rock", "/rock"),
19-
new Link("Rock variation", "/rock-variation"),
20-
new Link("Half time groove", "/half-time-groove")
21-
]
13+
selectedGenreIndex: number = 0;
14+
selectedSubGenreIndex: number = 0;
15+
musicGenres: Genre[] = [
16+
new Genre("Metal",
17+
[
18+
new Subgenre("Metal", "/metal"),
19+
new Subgenre("Rock", "/rock"),
20+
new Subgenre("Rock variation", "/rock-variation"),
21+
new Subgenre("Half time groove", "/half-time-groove"),
22+
]),
23+
new Genre("Techno", [
24+
new Subgenre("Basique", "/techno"),
25+
]),
26+
new Genre("Garage", [
27+
new Subgenre("Drum & Bass", "/drum-n-bass"),
28+
new Subgenre("Garage - 2 step", "/garage"),
29+
]),
30+
new Genre("Trance", [
31+
new Subgenre("Psytrance", "/psytrance"),
32+
])
33+
];
34+
35+
2236

2337
constructor(private responsive: BreakpointObserver) {
2438
}
@@ -31,4 +45,12 @@ export class AppComponent implements OnInit {
3145
this.isMobileDisplay = !result.matches;
3246
});
3347
}
48+
49+
selectGenre(i: number) {
50+
this.selectedGenreIndex = i;
51+
}
52+
53+
selectSubGenre(i: number) {
54+
this.selectedSubGenreIndex = i;
55+
}
3456
}

src/app/models/genre.ts

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import {Subgenre} from "./subgenre";
2+
3+
export class Genre {
4+
constructor(public label: string, public subGenres: Subgenre[]) {
5+
}
6+
}

src/app/models/link.ts

-9
This file was deleted.

src/app/models/subgenre.ts

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export class Subgenre {
2+
constructor(public label: string, public link: string) {
3+
4+
}
5+
}

src/styles.scss

+4
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,7 @@ html, body {
66
div, p {
77
font-family: 'Kanit', sans-serif;
88
}
9+
10+
a {
11+
all: unset;
12+
}

0 commit comments

Comments
 (0)