Skip to content

Commit f40b5b1

Browse files
committed
some css
1 parent bdbe7e4 commit f40b5b1

File tree

11 files changed

+61
-29
lines changed

11 files changed

+61
-29
lines changed

src/app/core/store/lobby.store.ts

+5-4
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { Lobby } from '../../shared/models/lobby'
44
import { LobbyUser } from '../../shared/models/lobby-user'
55
import { AuthService } from '../services/auth.service'
66
import { Router } from '@angular/router'
7+
import { LobbyMusic } from '../../shared/models/lobby-music'
78

89
@Injectable({
910
providedIn: 'root',
@@ -13,14 +14,14 @@ export class LobbyStore {
1314
private meBehaviorSubject = new BehaviorSubject<LobbyUser>(null)
1415
private lobbyBehaviorSubject = new BehaviorSubject<Lobby | null>(null)
1516
private currentLobbyMusicIdBehaviorSubject = new BehaviorSubject<ArrayBuffer | null>(null)
16-
private currentLobbyMusicAnswerBehaviorSubject = new BehaviorSubject<string | null>(null)
17+
private currentLobbyMusicAnswerBehaviorSubject = new BehaviorSubject<LobbyMusic<number> | null>(null)
1718

1819
public readonly lobby: Observable<Lobby | null> = this.lobbyBehaviorSubject.asObservable()
1920
public readonly users: Observable<LobbyUser[] | null> = this.usersBehaviorSubject.asObservable()
2021
public readonly me: Observable<LobbyUser | null> = this.meBehaviorSubject.asObservable()
2122
public readonly currentLobbyMusicId: Observable<ArrayBuffer | null> =
2223
this.currentLobbyMusicIdBehaviorSubject.asObservable()
23-
public readonly currentLobbyMusicAnswer: Observable<string | null> =
24+
public readonly currentLobbyMusicAnswer: Observable<LobbyMusic<number> | null> =
2425
this.currentLobbyMusicAnswerBehaviorSubject.asObservable()
2526

2627
constructor(private authService: AuthService, private router: Router) {}
@@ -64,11 +65,11 @@ export class LobbyStore {
6465
this.currentLobbyMusicIdBehaviorSubject.next(lobbyMusicId)
6566
}
6667

67-
getCurrentLobbyMusicAnswer(): string | null {
68+
getCurrentLobbyMusicAnswer(): LobbyMusic<number> | null {
6869
return this.currentLobbyMusicAnswerBehaviorSubject.getValue()
6970
}
7071

71-
setCurrentLobbyMusicAnswer(lobbyMusicAnswer: string | null): void {
72+
setCurrentLobbyMusicAnswer(lobbyMusicAnswer: LobbyMusic<number> | null): void {
7273
this.currentLobbyMusicAnswerBehaviorSubject.next(lobbyMusicAnswer)
7374
}
7475

Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
<mat-slider
22
aria-label="unit(s)"
33
[value]="gainNode.gain.value"
4+
[vertical]="true"
45
(input)="updateVolume($event)"
56
[min]="0"
67
[max]="1"
78
[step]="0.001"
9+
color="primary"
810
></mat-slider>

src/app/modules/lobby/components/button-play/button-play.component.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<div class="row">
2-
<ng-container *ngIf="role === lobbyUsersRoles.Host">
2+
<ng-container *ngIf="showPlayButton()">
33
<button class="btn btn-primary col-md-6" type="button" (click)="play()">
44
Play
55
<ng-container *ngIf="lobby.status === lobbyStatus.Loading">(loading)</ng-container>
@@ -8,7 +8,7 @@
88
<button
99
type="button"
1010
class="btn btn-outline-primary"
11-
[ngClass]="{ 'col-md-6': role === lobbyUsersRoles.Host, 'col-md-12': role !== lobbyUsersRoles.Host }"
11+
[ngClass]="{ 'col-md-6': showPlayButton(), 'col-md-12': !showPlayButton() }"
1212
(click)="leave()"
1313
>
1414
Leave

src/app/modules/lobby/components/button-play/button-play.component.ts

+7
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,11 @@ export class ButtonPlayComponent implements OnInit, OnDestroy {
5050
void this.router.navigate(['/'])
5151
})
5252
}
53+
54+
showPlayButton(): boolean {
55+
return (
56+
this.role === this.lobbyUsersRoles.Host &&
57+
[LobbyStatuses.Waiting.toString(), LobbyStatuses.Loading.toString()].includes(this.lobby.status)
58+
)
59+
}
5360
}
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
music {{ lobby?.currentLobbyMusicPosition }}/{{ lobby?.lobbyMusics }}
2-
3-
{{ answer }}
4-
5-
<app-lobby-audio-player></app-lobby-audio-player>
6-
<app-lobby-countdown></app-lobby-countdown>
7-
<app-lobby-answer></app-lobby-answer>
1+
<div class="bg-dark p-4 h-100">
2+
<div class="d-flex flex-column justify-content-between">
3+
<app-lobby-audio-player class="row justify-content-end"></app-lobby-audio-player>
4+
<app-lobby-countdown></app-lobby-countdown>
5+
<app-lobby-answer></app-lobby-answer>
6+
</div>
7+
</div>

src/app/modules/lobby/components/center-container/center-container.component.ts

+2-12
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Component, OnDestroy, OnInit } from '@angular/core'
22
import { LobbyStore } from '../../../../core/store/lobby.store'
3-
import { Lobby, LobbyStatuses } from '../../../../shared/models/lobby'
3+
import { Lobby } from '../../../../shared/models/lobby'
44
import { Subscription } from 'rxjs'
55

66
@Component({
@@ -14,17 +14,7 @@ export class CenterContainerComponent implements OnInit, OnDestroy {
1414
constructor(private lobbyStore: LobbyStore) {}
1515

1616
ngOnInit(): void {
17-
this.subscriptions = [
18-
this.lobbyStore.currentLobbyMusicAnswer.subscribe((res) => {
19-
this.answer = res
20-
}),
21-
this.lobbyStore.lobby.subscribe((lobby) => {
22-
this.lobby = lobby
23-
if (lobby.status !== LobbyStatuses.AnswerReveal) {
24-
this.answer = null
25-
}
26-
}),
27-
]
17+
this.subscriptions = []
2818
}
2919

3020
ngOnDestroy(): void {

src/app/modules/lobby/lobby.component.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { AuthService } from '../../core/services/auth.service'
1111
import { LobbyStore } from '../../core/store/lobby.store'
1212
import { LobbyUser } from '../../shared/models/lobby-user'
1313
import { MatSnackBar } from '@angular/material/snack-bar'
14+
import { LobbyMusic } from '../../shared/models/lobby-music'
1415

1516
@Component({
1617
selector: 'app-lobby',
@@ -76,7 +77,7 @@ export class LobbyComponent implements OnInit, OnDestroy {
7677
this.socket.fromEvent('lobbyMusic').subscribe((lobbyMusicId: ArrayBuffer) => {
7778
this.lobbyStore.setCurrentLobbyMusicId(lobbyMusicId)
7879
}),
79-
this.socket.fromEvent('lobbyAnswer').subscribe((answer: string) => {
80+
this.socket.fromEvent('lobbyAnswer').subscribe((answer: LobbyMusic<number>) => {
8081
this.lobbyStore.setCurrentLobbyMusicAnswer(answer)
8182
}),
8283
this.socket.fromEvent('lobbyUserAnswer').subscribe((answer: LobbyUser) => {

src/app/modules/lobby/lobby.module.ts

+6
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ import { MatSnackBarModule } from '@angular/material/snack-bar'
2020
import { MatRadioModule } from '@angular/material/radio'
2121
import { MatTooltipModule } from '@angular/material/tooltip'
2222
import { AudioContextModule } from 'angular-audio-context'
23+
import { InformationComponent } from './components/information/information.component';
24+
import { AnswerRevealComponent } from './components/answer-reveal/answer-reveal.component'
25+
import {MatIconModule} from "@angular/material/icon";
2326

2427
const routes: Routes = [
2528
{ path: 'create', component: CreateComponent },
@@ -43,6 +46,8 @@ const routes: Routes = [
4346
AnswerSelectComponent,
4447
CountdownComponent,
4548
CenterContainerComponent,
49+
InformationComponent,
50+
AnswerRevealComponent,
4651
],
4752
imports: [
4853
CommonModule,
@@ -53,6 +58,7 @@ const routes: Routes = [
5358
MatRadioModule,
5459
MatTooltipModule,
5560
AudioContextModule.forRoot('balanced'),
61+
MatIconModule,
5662
],
5763
providers: [LobbyHttpService],
5864
})
Original file line numberDiff line numberDiff line change
@@ -1 +1,10 @@
1-
<app-lobby-center-container></app-lobby-center-container>
1+
<div class="row">
2+
<div class="col-md-3">
3+
<div><app-lobby-information></app-lobby-information></div>
4+
<div class="mt-2"><app-lobby-answer-reveal></app-lobby-answer-reveal></div>
5+
</div>
6+
<div class="col-md-6">
7+
<app-lobby-center-container></app-lobby-center-container>
8+
</div>
9+
<div class="col-md-3"><app-button-play></app-button-play></div>
10+
</div>

src/app/shared/models/lobby-music.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import { Music } from './music'
22
import { Game } from './game'
3+
import { GameToMusic } from './game-to-music'
34

4-
export interface LobbyMusic {
5+
export interface LobbyMusic<T = GameToMusic[]> {
56
id: string
67
music: Music
7-
expectedAnswer?: Game
8+
expectedAnswer?: Game<T>
89
startAt: number
910
}

src/assets/scss/components/_game.scss

+15
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,18 @@ app-game-item {
77
outline: black solid 2px;
88
}
99
}
10+
.mat-mini-fab.large {
11+
width: 30px;
12+
height: 30px;
13+
line-height: 30px;
14+
15+
.mat-button-wrapper {
16+
padding: 0;
17+
}
18+
.mat-icon {
19+
font-size: 20px;
20+
width: 20px;
21+
height: 20px;
22+
line-height: 20px;
23+
}
24+
}

0 commit comments

Comments
 (0)