From 701d0dc3fc79d2107bab55b29dd98324df60c18b Mon Sep 17 00:00:00 2001
From: ellenyuX
Date: Wed, 25 Sep 2024 11:16:43 +0200
Subject: [PATCH 01/13] refactor and change simple design
---
.../dialog-template.component.html | 15 ----
.../dialog-template.component.scss | 23 -----
src/app/admin/dialog/dialog.component.html | 11 +++
src/app/admin/dialog/dialog.component.scss | 29 +++++++
.../dialog.component.ts} | 6 +-
.../info-dialog/info-dialog.component.ts | 16 ++--
.../admin/info-page/info-page.component.html | 16 ++++
.../info-page.component.scss} | 2 +-
.../info-page.component.ts} | 83 ++-----------------
src/app/admin/info/info.component.html | 29 -------
src/app/routes.ts | 4 +-
11 files changed, 76 insertions(+), 158 deletions(-)
delete mode 100644 src/app/admin/dialog-template/dialog-template.component.html
delete mode 100644 src/app/admin/dialog-template/dialog-template.component.scss
create mode 100644 src/app/admin/dialog/dialog.component.html
create mode 100644 src/app/admin/dialog/dialog.component.scss
rename src/app/admin/{dialog-template/dialog-template.component.ts => dialog/dialog.component.ts} (74%)
create mode 100644 src/app/admin/info-page/info-page.component.html
rename src/app/admin/{info/info.component.scss => info-page/info-page.component.scss} (92%)
rename src/app/admin/{info/info.component.ts => info-page/info-page.component.ts} (62%)
delete mode 100644 src/app/admin/info/info.component.html
diff --git a/src/app/admin/dialog-template/dialog-template.component.html b/src/app/admin/dialog-template/dialog-template.component.html
deleted file mode 100644
index 0b050c59..00000000
--- a/src/app/admin/dialog-template/dialog-template.component.html
+++ /dev/null
@@ -1,15 +0,0 @@
-
-
Informasjon:
-
-
-
Navn på iterasjon: {{ data.iterationName }}
-
-
-
Tidspunktet iterasjonen ble lagd: {{ data.timeCreated }}
-
-
-
Antall (nye) bilder i treningssettet: {{ data.imageCount }}
-
-
-
(Trykk utenfor boksen for å lukke)
-
diff --git a/src/app/admin/dialog-template/dialog-template.component.scss b/src/app/admin/dialog-template/dialog-template.component.scss
deleted file mode 100644
index 7bba162e..00000000
--- a/src/app/admin/dialog-template/dialog-template.component.scss
+++ /dev/null
@@ -1,23 +0,0 @@
-.dialog-title {
- font-weight: bold;
- font-size: 35px;
- text-align: center;
-}
-
-.content {
- display: flex;
- justify-content: center;
- width: 625px;
- height: 50px;
- font-size: 20px;
-}
-
-.mat-dialog-container {
- border-radius: 56px;
- width: 698px;
- height: 246px;
-
- display: flex;
- align-items: center;
- justify-content: center;
-}
diff --git a/src/app/admin/dialog/dialog.component.html b/src/app/admin/dialog/dialog.component.html
new file mode 100644
index 00000000..0e63ba59
--- /dev/null
+++ b/src/app/admin/dialog/dialog.component.html
@@ -0,0 +1,11 @@
+
+
Informasjon
+
+
+
Navn på iterasjon: {{ data.iterationName }}
+
Tidspunktet iterasjonen ble lagd: {{ data.timeCreated }}
+
Antall (nye) bilder i treningssettet: {{ data.imageCount }}
+
+
+
+
diff --git a/src/app/admin/dialog/dialog.component.scss b/src/app/admin/dialog/dialog.component.scss
new file mode 100644
index 00000000..80010334
--- /dev/null
+++ b/src/app/admin/dialog/dialog.component.scss
@@ -0,0 +1,29 @@
+.dialog-content {
+ text-align: center;
+ padding: 20px;
+ max-width: 400px;
+ margin: auto;
+}
+
+.dialog-title {
+ font-size: 24px;
+ font-weight: bold;
+ margin-bottom: 20px;
+}
+
+.dialog-body p {
+ font-size: 16px;
+ margin: 10px 0;
+ font-weight: 500;
+}
+
+.dialog-body b {
+ font-weight: 900;
+}
+
+.dialog-footer {
+ font-size: 14px;
+ color: grey;
+ margin-top: 20px;
+ font-style: italic;
+}
diff --git a/src/app/admin/dialog-template/dialog-template.component.ts b/src/app/admin/dialog/dialog.component.ts
similarity index 74%
rename from src/app/admin/dialog-template/dialog-template.component.ts
rename to src/app/admin/dialog/dialog.component.ts
index ba36c64c..f124f130 100644
--- a/src/app/admin/dialog-template/dialog-template.component.ts
+++ b/src/app/admin/dialog/dialog.component.ts
@@ -5,11 +5,11 @@ import { DialogData } from '@/app/shared/models/interfaces';
@Component({
selector: 'app-dialog-template',
- templateUrl: './dialog-template.component.html',
- styleUrls: ['./dialog-template.component.scss'],
+ templateUrl: './dialog.component.html',
+ styleUrls: ['./dialog.component.scss'],
standalone: true,
imports: [CdkScrollable, MatDialogContent, MatDialogTitle],
})
-export class DialogTemplateComponent {
+export class DialogComponent {
constructor(@Inject(MAT_DIALOG_DATA) public data: DialogData) {}
}
diff --git a/src/app/admin/info-dialog/info-dialog.component.ts b/src/app/admin/info-dialog/info-dialog.component.ts
index fd320b67..fb67ffc2 100644
--- a/src/app/admin/info-dialog/info-dialog.component.ts
+++ b/src/app/admin/info-dialog/info-dialog.component.ts
@@ -1,6 +1,6 @@
import { Component } from '@angular/core';
import { MatDialog } from '@angular/material/dialog';
-import { DialogTemplateComponent } from './../dialog-template/dialog-template.component';
+import { DialogComponent } from '../dialog/dialog.component';
import { ErrorLogDialogComponent } from '../error-dialog/error-dialog.component';
import { LogData } from '@/app/shared/models/backend-interfaces';
@@ -14,7 +14,7 @@ export class InfoDialogComponent {
constructor(public dialog: MatDialog) {}
openDialog(iterName: string, time: string, imgCount: string) {
- this.dialog.open(DialogTemplateComponent, {
+ this.dialog.open(DialogComponent, {
data: {
iterationName: iterName,
timeCreated: time,
@@ -23,10 +23,12 @@ export class InfoDialogComponent {
});
}
- openErrorLog(logDataArray: LogData[]) {
+openErrorLog(logDataArray: LogData[]) {
- this.dialog.open(ErrorLogDialogComponent, {
- data: logDataArray,
- });
- }
+ this.dialog.open(ErrorLogDialogComponent, {
+ data: logDataArray,
+ });
}
+
+}
+
diff --git a/src/app/admin/info-page/info-page.component.html b/src/app/admin/info-page/info-page.component.html
new file mode 100644
index 00000000..c293ba8d
--- /dev/null
+++ b/src/app/admin/info-page/info-page.component.html
@@ -0,0 +1,16 @@
+Administrative handlinger
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/app/admin/info/info.component.scss b/src/app/admin/info-page/info-page.component.scss
similarity index 92%
rename from src/app/admin/info/info.component.scss
rename to src/app/admin/info-page/info-page.component.scss
index 053fd3f9..c928b4db 100644
--- a/src/app/admin/info/info.component.scss
+++ b/src/app/admin/info-page/info-page.component.scss
@@ -39,7 +39,7 @@ p {
}
.btn-group button:first-child {
- background-color: #c78bde;
+ background-color: #734f81;
margin-top: 2vh;
border: 1px solid #96a7b1;
}
diff --git a/src/app/admin/info/info.component.ts b/src/app/admin/info-page/info-page.component.ts
similarity index 62%
rename from src/app/admin/info/info.component.ts
rename to src/app/admin/info-page/info-page.component.ts
index 6fcb496c..4ddbdca8 100644
--- a/src/app/admin/info/info.component.ts
+++ b/src/app/admin/info-page/info-page.component.ts
@@ -2,7 +2,7 @@ import { Component } from '@angular/core';
import { Router } from '@angular/router';
import { LoginService } from '../login.service';
import { MatSnackBar } from '@angular/material/snack-bar';
-import { InfoDialogComponent } from './../info-dialog/info-dialog.component';
+import { InfoDialogComponent } from '../info-dialog/info-dialog.component';
import { PairingService } from '../../game/services/pairing.service';
import { MatButton } from '@angular/material/button';
import { LogData, StatusData } from '@/app/shared/models/backend-interfaces';
@@ -10,12 +10,12 @@ import { LoggingService } from '../../game/services/logging.service';
@Component({
selector: 'app-info',
- templateUrl: './info.component.html',
- styleUrls: ['./info.component.scss'],
+ templateUrl: './info-page.component.html',
+ styleUrls: ['./info-page.component.scss'],
standalone: true,
imports: [MatButton],
})
-export class InfoComponent {
+export class InfoPageComponent {
datasetString = 'Nullstill treningssett til originalen';
datasetBool = false;
retrainString = 'Tren maskinlæringsmodellen';
@@ -34,49 +34,7 @@ export class InfoComponent {
private pairing: PairingService,
private loggingService: LoggingService
) {}
-
- revertDataset() {
- let msg = '';
- if (this.datasetBool) {
- this.resetDatasetValues();
- this.loginService.revertDataset().subscribe(
- () => {
- this.openSnackBar('Suksess! Treningssett tilbakestilles (dette kan ta noen minutter)');
- },
- () => {
- msg = this.errorMsg;
- this.openSnackBar(msg);
- }
- );
- this.resetDatasetValues();
- } else {
- this.resetHighScoreValues();
- this.resetRetrainValues();
- this.setDatasetValues();
- }
- }
-
- retrain() {
- let msg = '';
- if (this.retrainBool) {
- this.resetDatasetValues();
- this.loginService.retrain().subscribe(
- () => {
- this.openSnackBar('Suksess! Modellen blir trent (dette kan ta noen minutter)');
- },
- () => {
- msg = this.errorMsg;
- this.openSnackBar(msg);
- }
- );
- this.resetRetrainValues();
- } else {
- this.resetDatasetValues();
- this.resetHighScoreValues();
- this.setRetrainValues();
- }
- }
-
+
clearHighScore() {
let msg = '';
if (this.highScoreBool) {
@@ -93,7 +51,6 @@ export class InfoComponent {
this.resetHighScoreValues();
} else {
this.resetDatasetValues();
- this.resetRetrainValues();
this.setHighScoreValues();
}
}
@@ -103,37 +60,16 @@ export class InfoComponent {
this.highScoreBool = false;
}
- resetRetrainValues() {
- this.retrainString = 'Tren maskinlæringsmodellen';
- this.retrainBool = false;
- }
-
resetDatasetValues() {
this.datasetString = 'Nullstill treningssett til originalen';
this.datasetBool = false;
}
- resetAll() {
- this.resetHighScoreValues();
- this.resetRetrainValues();
- this.resetDatasetValues();
- }
-
setHighScoreValues() {
this.highScoreString = this.secondMsg;
this.highScoreBool = true;
}
- setRetrainValues() {
- this.retrainString = this.secondMsg;
- this.retrainBool = true;
- }
-
- setDatasetValues() {
- this.datasetString = this.secondMsg;
- this.datasetBool = true;
- }
-
signOut() {
this.loginService.signOut().subscribe(
() => {
@@ -148,7 +84,6 @@ export class InfoComponent {
}
getInformation() {
- this.resetAll();
this.loginService.getStatus().subscribe(
(res: StatusData) => {
const name = res.CV_iteration_name;
@@ -192,12 +127,4 @@ export class InfoComponent {
duration: 6000,
});
}
-
- pair(id: string) {
- this.pairing.setPairID(id);
- }
-
- getPairID() {
- return this.pairing.getPairID();
- }
}
diff --git a/src/app/admin/info/info.component.html b/src/app/admin/info/info.component.html
deleted file mode 100644
index 9efd216f..00000000
--- a/src/app/admin/info/info.component.html
+++ /dev/null
@@ -1,29 +0,0 @@
-Administrative handlinger
-Advarsel!
-Før du utfører en administrativ handling, vær helt sikker på at du vil gjøre den.
-Hvis en handling først gjennomføres, vil du IKKE være i stand til å gjøre om på den.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/app/routes.ts b/src/app/routes.ts
index eb8285d2..c61030da 100644
--- a/src/app/routes.ts
+++ b/src/app/routes.ts
@@ -6,7 +6,7 @@ import { routes as r } from './shared/models/routes';
import { GameResultComponent } from './game/game-result/game-result.component';
import { GameDrawComponent } from './game/game-draw/game-draw.component';
import { AdminComponent } from './admin/admin.component';
-import { InfoComponent } from './admin/info/info.component';
+import { InfoPageComponent } from './admin/info-page/info-page.component';
import { authGuard } from './admin/auth-guard';
import { MultiplayerComponent } from './game/game-multiplayer/multiplayer.component';
@@ -48,7 +48,7 @@ export const routes: Routes = [
},
{
path: 'admin/info',
- component: InfoComponent,
+ component: InfoPageComponent,
canActivate: [authGuard],
},
];
From af94c4a7c6f2b8024e5508810d3bcf32c97ff25c Mon Sep 17 00:00:00 2001
From: filvanh
Date: Wed, 25 Sep 2024 13:56:18 +0200
Subject: [PATCH 02/13] Animasjon av knapper feedback-effect, for custom
buttons, og idlecomponent, og confirmextcomponent
---
.../game-pick-difficulty.component.html | 6 +--
.../game-pick-difficulty.component.ts | 9 +++-
.../game-word-to-draw.component.html | 2 +-
.../idle-timeout/idle-timeout.component.html | 4 +-
.../idle-timeout/idle-timeout.component.ts | 32 +++++++++++--
.../confirm-exit-dialog.component.html | 4 +-
.../confirm-exit-dialog.component.ts | 44 ++++++++++++-----
.../custom-button.component.html | 9 ++--
.../custom-button/custom-button.component.ts | 47 ++++++++++++++-----
src/app/welcome/welcome.component.html | 8 +---
src/app/welcome/welcome.component.ts | 9 +++-
11 files changed, 127 insertions(+), 47 deletions(-)
diff --git a/src/app/game/game-pick-difficulty/game-pick-difficulty.component.html b/src/app/game/game-pick-difficulty/game-pick-difficulty.component.html
index 5e5afbc0..3cb5eeaf 100644
--- a/src/app/game/game-pick-difficulty/game-pick-difficulty.component.html
+++ b/src/app/game/game-pick-difficulty/game-pick-difficulty.component.html
@@ -38,7 +38,7 @@
[disabled]="buttonsAreDisabled"
[buttonStyle]="buttonStyleClass"
[buttonText]="'EASY_BUTTON' | translate"
- (click)="startDrawing('easy')"
+ (buttonClicked)="startDrawing('easy')"
alt=""
aria-label=""
>
@@ -54,7 +54,7 @@
[disabled]="buttonsAreDisabled"
[buttonStyle]="buttonStyleClass"
[buttonText]="'MEDIUM_BUTTON' | translate"
- (click)="startDrawing('medium')"
+ (buttonClicked)="startDrawing('medium')"
alt=""
aria-label=""
>
@@ -70,7 +70,7 @@
[disabled]="buttonsAreDisabled"
[buttonStyle]="buttonStyleClass"
[buttonText]="'HARD_BUTTON' | translate"
- (click)="startDrawing('hard')"
+ (buttonClicked)="startDrawing('hard')"
alt=""
aria-label=""
>
diff --git a/src/app/game/game-pick-difficulty/game-pick-difficulty.component.ts b/src/app/game/game-pick-difficulty/game-pick-difficulty.component.ts
index 657f0979..29a514a1 100644
--- a/src/app/game/game-pick-difficulty/game-pick-difficulty.component.ts
+++ b/src/app/game/game-pick-difficulty/game-pick-difficulty.component.ts
@@ -99,11 +99,16 @@ export class GamePickDifficultyComponent implements OnInit {
{
delay: 350,
action: () => {
- this.stateButtons = 'visible';
- this.buttonsAreDisabled = false;
this.stateFirstBubbleI = 'visible';
},
},
+ {
+ delay: 450,
+ action: () => {
+ this.stateButtons = 'visible';
+ this.buttonsAreDisabled = false;
+ }
+ }
];
let totalDelay = 0;
steps.forEach((step) => {
diff --git a/src/app/game/game-word-to-draw/game-word-to-draw.component.html b/src/app/game/game-word-to-draw/game-word-to-draw.component.html
index 070ba1fc..67d30026 100644
--- a/src/app/game/game-word-to-draw/game-word-to-draw.component.html
+++ b/src/app/game/game-word-to-draw/game-word-to-draw.component.html
@@ -64,7 +64,7 @@ {{ label | uppercase }}
[buttonStyle]="forwardButtonStyleClass"
[buttonText]="'DRAW_BUTTON' | translate"
(keydown)="toDrawingBoard()"
- (click)="toDrawingBoard()"
+ (buttonClicked)="toDrawingBoard()"
id="draw-btn"
>
-
diff --git a/src/app/game/idle-timeout/idle-timeout.component.ts b/src/app/game/idle-timeout/idle-timeout.component.ts
index 38c8cd60..94cf1cf7 100644
--- a/src/app/game/idle-timeout/idle-timeout.component.ts
+++ b/src/app/game/idle-timeout/idle-timeout.component.ts
@@ -8,6 +8,7 @@ import { MatButton } from '@angular/material/button';
import { CdkScrollable } from '@angular/cdk/scrolling';
import { TranslationService } from '@/app/core/translation.service';
import { TranslatePipe } from '@/app/core/translation.pipe';
+import { animate, state, style, transition, trigger } from '@angular/animations';
@Component({
selector: 'app-idle-timeout',
templateUrl: './idle-timeout.component.html',
@@ -15,6 +16,14 @@ import { TranslatePipe } from '@/app/core/translation.pipe';
encapsulation: ViewEncapsulation.None,
standalone: true,
imports: [CdkScrollable, MatDialogContent, MatDialogActions, MatButton, MatIcon, TranslatePipe],
+ animations: [
+ trigger('buttonClickEffect', [
+ state('normal', style({transform: 'scale(1)',})),
+ state('clicked', style({transform: 'scale(1.1)',})),
+ transition('normal => clicked', [animate('0.1s ease-out')]),
+ transition('clicked => normal', [animate('0.1s ease-in')]),
+ ])
+ ]
})
export class IdleTimeoutComponent implements OnInit, OnDestroy {
constructor(
@@ -26,6 +35,8 @@ export class IdleTimeoutComponent implements OnInit, OnDestroy {
startTime = 15;
timer = 0;
countdown = 0;
+ buttonStateHome = 'normal';
+ buttonStateCancel = "normal";
ngOnInit(): void {
this.timer = this.startTime;
@@ -40,13 +51,26 @@ export class IdleTimeoutComponent implements OnInit, OnDestroy {
}
goHome() {
- this.closeDialog();
- this.router.navigate([routes.LANDING]);
+ this.buttonStateHome = "clicked";
+ setTimeout(() => {
+ this.buttonStateHome = "normal";
+ setTimeout(() => {
+ clearInterval(this.countdown);
+ this.dialogRef.close();
+ this.router.navigate([routes.LANDING]);
+ }, 100)
+ }, 100);
}
closeDialog() {
- clearInterval(this.countdown);
- this.dialogRef.close();
+ this.buttonStateCancel = "clicked";
+ setTimeout(() => {
+ this.buttonStateCancel = "normal";
+ setTimeout(() => {
+ clearInterval(this.countdown);
+ this.dialogRef.close();
+ }, 100)
+ }, 100);
}
resetTimer() {
diff --git a/src/app/game/shared-components/confirm-exit-dialog/confirm-exit-dialog.component.html b/src/app/game/shared-components/confirm-exit-dialog/confirm-exit-dialog.component.html
index f815dc9b..2ed67c10 100644
--- a/src/app/game/shared-components/confirm-exit-dialog/confirm-exit-dialog.component.html
+++ b/src/app/game/shared-components/confirm-exit-dialog/confirm-exit-dialog.component.html
@@ -4,12 +4,12 @@
-
+
home{{ 'END_NOW_BUTTON' | translate }}
-
+
{{ 'RESUME_BUTTON' | translate }}
diff --git a/src/app/game/shared-components/confirm-exit-dialog/confirm-exit-dialog.component.ts b/src/app/game/shared-components/confirm-exit-dialog/confirm-exit-dialog.component.ts
index 91cf9f67..46815b25 100644
--- a/src/app/game/shared-components/confirm-exit-dialog/confirm-exit-dialog.component.ts
+++ b/src/app/game/shared-components/confirm-exit-dialog/confirm-exit-dialog.component.ts
@@ -8,6 +8,7 @@ import { MatButton } from '@angular/material/button';
import { MatDialogActions, MatDialogContent, MatDialogRef } from '@angular/material/dialog';
import { MatIcon } from '@angular/material/icon';
import { DrawingService } from '@/app/game/services/drawing.service';
+import { animate, state, style, transition, trigger } from '@angular/animations';
@Component({
selector: 'app-confirm-exit-dialog',
templateUrl: './confirm-exit-dialog.component.html',
@@ -15,6 +16,14 @@ import { DrawingService } from '@/app/game/services/drawing.service';
encapsulation: ViewEncapsulation.None,
standalone: true,
imports: [MatDialogActions, MatDialogContent, MatButton, MatIcon, TranslatePipe],
+ animations: [
+ trigger('buttonClickEffect', [
+ state('normal', style({transform: 'scale(1)',})),
+ state('clicked', style({transform: 'scale(1.1)',})),
+ transition('normal => clicked', [animate('0.1s ease-out')]),
+ transition('clicked => normal', [animate('0.1s ease-in')]),
+ ])
+ ]
})
export class ConfirmExitDialogComponent implements OnInit, OnDestroy{
readonly dialogRef = inject(MatDialogRef);
@@ -22,6 +31,8 @@ export class ConfirmExitDialogComponent implements OnInit, OnDestroy{
timer = 0;
startTime = 10;
countdownInterval = 0;
+ buttonStateHome = 'normal';
+ buttonStateCancel = "normal";
constructor(
private router: Router,
@@ -61,21 +72,30 @@ export class ConfirmExitDialogComponent implements OnInit, OnDestroy{
}
closeDialog() {
- this.dialogRef.close();
+ this.buttonStateCancel = "clicked";
+
+ setTimeout(() => {
+ this.buttonStateCancel = "normal";
+ setTimeout(() => {
+ this.dialogRef.close();
+ }, 100)
+ }, 100);
}
goToWelcomePage() {
- this.clearCountdown();
- this.dialogRef.close();
- this.gameStateService.clearState();
- this.drawingService.clearState();
-
- if (this.gameStateService.isMultiplayer()) {
- this.multiplayerService.clearState();
- }
-
+ this.buttonStateHome = "clicked";
+ setTimeout(() => {
+ this.buttonStateHome = "normal";
+ setTimeout(() => {
+ this.clearCountdown();
+ this.dialogRef.close();
+ this.gameStateService.clearState();
+ this.drawingService.clearState();
+ if (this.gameStateService.isMultiplayer()) {
+ this.multiplayerService.clearState();
+ }
this.router.navigate([routes.WELCOME]);
+ }, 100)
+ }, 100);
}
-
-
}
diff --git a/src/app/game/shared-components/custom-button/custom-button.component.html b/src/app/game/shared-components/custom-button/custom-button.component.html
index 7d11340c..0f093b6f 100644
--- a/src/app/game/shared-components/custom-button/custom-button.component.html
+++ b/src/app/game/shared-components/custom-button/custom-button.component.html
@@ -3,7 +3,9 @@
@if (buttonStyle === 'select-mode-button' || buttonStyle === 'select-mode-button-large' || buttonStyle === 'forward-button' || buttonStyle === 'play-again-button') {
+ [class]="buttonStyle"
+ [@buttonClickEffect]="buttonState"
+ (click)="onButtonClick()">
@if (buttonStyle === 'forward-button') {
@@ -27,9 +29,10 @@
@else {
+ [class]="buttonStyle"
+ [@buttonClickEffect]="buttonState"
+ (click)="onButtonClick()">
@switch (buttonStyle) {
@case ('back-button') {
diff --git a/src/app/game/shared-components/custom-button/custom-button.component.ts b/src/app/game/shared-components/custom-button/custom-button.component.ts
index fe6f99e5..ab9c326d 100644
--- a/src/app/game/shared-components/custom-button/custom-button.component.ts
+++ b/src/app/game/shared-components/custom-button/custom-button.component.ts
@@ -1,17 +1,27 @@
-import { Component, inject, Input } from '@angular/core';
+import { Component, EventEmitter, inject, Input, Output } from '@angular/core';
import { ButtonStyleClass } from '@/app/shared/buttonStyles';
-import { Router, RouterLink, RouterLinkActive } from '@angular/router';
+import { Router } from '@angular/router';
import { MatIcon } from '@angular/material/icon';
import { MatDialog } from '@angular/material/dialog';
import { ConfirmExitDialogComponent } from '../confirm-exit-dialog/confirm-exit-dialog.component';
+import { trigger, state, style, transition, animate } from '@angular/animations';
@Component({
selector: 'app-custom-button',
templateUrl: './custom-button.component.html',
styleUrls: ['./custom-button.component.scss'],
standalone: true,
- imports: [RouterLink, RouterLinkActive, MatIcon],
+ imports: [MatIcon, ConfirmExitDialogComponent],
+ animations: [
+ trigger('buttonClickEffect', [
+ state('normal', style({transform: 'scale(1)',})),
+ state('clicked', style({transform: 'scale(1.1)',})),
+ transition('normal => clicked', [animate('0.1s ease-out')]),
+ transition('clicked => normal', [animate('0.1s ease-in')]),
+ ])
+ ]
})
+
export class CustomButtonComponent {
@Input() buttonStyle: ButtonStyleClass = ButtonStyleClass.default;
@Input() buttonText = 'Button';
@@ -20,6 +30,8 @@ export class CustomButtonComponent {
@Input() alt = '';
@Input() innerBackgroundStyle: 'full-gradient-inner' | 'non-gradient-inner' = 'non-gradient-inner';
+ // Event emitter for the parent to listen to
+ @Output() buttonClicked: EventEmitter
= new EventEmitter();
readonly dialog = inject(MatDialog);
readonly router = inject(Router);
@@ -27,16 +39,29 @@ export class CustomButtonComponent {
openDialog(): void {
this.dialog.open(ConfirmExitDialogComponent);
}
- clickHandler(): void {
+
+ buttonState = 'normal';
+
+ onButtonClick() {
if (this.disabled) {
return;
}
- if (this.buttonStyle === 'back-button') {
- this.router.navigate(['/welcome']);
- }
- else if (this.buttonStyle === 'home-button') {
- this.openDialog();
- }
- }
+ this.buttonState = 'clicked';
+
+ setTimeout(() => {
+ this.buttonState = 'normal';
+ setTimeout(() => {
+ if (this.buttonStyle === 'back-button') {
+ this.router.navigate(['/welcome']);
+ }
+ else if (this.buttonStyle === 'home-button') {
+ this.dialog.open(ConfirmExitDialogComponent);
+ }
+ else {
+ this.buttonClicked.emit();
+ }
+ }, 100);
+ }, 100);
+ }
}
diff --git a/src/app/welcome/welcome.component.html b/src/app/welcome/welcome.component.html
index 24237cd9..46a7f482 100644
--- a/src/app/welcome/welcome.component.html
+++ b/src/app/welcome/welcome.component.html
@@ -107,9 +107,7 @@
[buttonStyle]="buttonStyleClass"
[buttonText]="'PLAYER_MODE_SINGLE' | translate"
[disabled]="!buttonIsVisible"
- routerLink="/playgame/singleplayer"
- routerLinkActive="active"
- (click)="setSingleplayer()"
+ (buttonClicked)="setSingleplayer()"
>
person
@@ -117,9 +115,7 @@
[buttonStyle]="buttonStyleClass"
[buttonText]="'PLAYER_MODE_MULTI' | translate"
[disabled]="!buttonIsVisible"
- routerLink="/playgame/multiplayer"
- routerLinkActive="active"
- (click)="setMultiplayer()"
+ (buttonClicked)="setMultiplayer()"
>
group
diff --git a/src/app/welcome/welcome.component.ts b/src/app/welcome/welcome.component.ts
index 8f09e075..f097d8b2 100644
--- a/src/app/welcome/welcome.component.ts
+++ b/src/app/welcome/welcome.component.ts
@@ -1,4 +1,4 @@
-import { Component, OnInit, OnDestroy } from '@angular/core';
+import { Component, OnInit, OnDestroy, inject } from '@angular/core';
import { MultiplayerService } from '../game/services/multiplayer.service';
import { DrawingService } from '../game/services/drawing.service';
import { Router, RouterLink, RouterLinkActive } from '@angular/router';
@@ -194,13 +194,20 @@ export class WelcomeComponent implements OnInit, OnDestroy {
this.destroy$.complete();
}
+
+ readonly singleplayerRouter = inject(Router);
+ readonly multiplayerRouter = inject(Router);
+
setSingleplayer() {
this.gameStateService.setSingleplayer();
this.gameStateService.goToPage(GAMESTATE.difficultyPicker);
+ this.singleplayerRouter.navigate(["/playgame/singleplayer"])
+
}
setMultiplayer() {
this.gameStateService.setMultiplayer();
this.gameStateService.goToPage(GAMESTATE.lobby);
+ this.multiplayerRouter.navigate(["/playgame/multiplayer"]);
}
}
From be8282f5f3448159a8764c2ba4d2b4deea77966d Mon Sep 17 00:00:00 2001
From: filvanh
Date: Wed, 25 Sep 2024 16:25:36 +0200
Subject: [PATCH 03/13] Legg til knappanimsjon til result page
---
.../game-intermediate-result-footer.component.html | 3 +--
.../game-multiplayer/lobby/lobby.component.html | 5 +----
src/app/game/game-result/game-result.component.html | 5 ++---
src/app/game/game-result/game-result.component.ts | 2 +-
.../custom-button/custom-button.component.html | 13 ++++++-------
.../custom-button/custom-button.component.scss | 3 ++-
.../custom-button/custom-button.component.ts | 2 +-
src/app/shared/buttonStyles.ts | 1 +
8 files changed, 15 insertions(+), 19 deletions(-)
diff --git a/src/app/game/game-intermediate-result/game-intermediate-result-footer/game-intermediate-result-footer.component.html b/src/app/game/game-intermediate-result/game-intermediate-result-footer/game-intermediate-result-footer.component.html
index ebcb6175..a176debd 100644
--- a/src/app/game/game-intermediate-result/game-intermediate-result-footer/game-intermediate-result-footer.component.html
+++ b/src/app/game/game-intermediate-result/game-intermediate-result-footer/game-intermediate-result-footer.component.html
@@ -4,8 +4,7 @@
[buttonStyle]="buttonStyleClass"
[buttonText]="buttonTextKey | translate"
(keydown)="nextPage()"
- (click)="nextPage()"
+ (buttonClicked)="nextPage()"
>
- arrow_forward_ios
diff --git a/src/app/game/game-multiplayer/lobby/lobby.component.html b/src/app/game/game-multiplayer/lobby/lobby.component.html
index b2f3d15a..6b5e2def 100644
--- a/src/app/game/game-multiplayer/lobby/lobby.component.html
+++ b/src/app/game/game-multiplayer/lobby/lobby.component.html
@@ -7,13 +7,10 @@
- group
+
diff --git a/src/app/game/game-result/game-result.component.html b/src/app/game/game-result/game-result.component.html
index 01faf516..b2136222 100644
--- a/src/app/game/game-result/game-result.component.html
+++ b/src/app/game/game-result/game-result.component.html
@@ -111,15 +111,14 @@
class="end-game-button"
[buttonStyle]="homeButtonStyleClass"
[buttonText]="'HOME' | translate"
- iconSrc="../../../assets/house.svg"
- (click)="endGame()"
+ (buttonClicked)="endGame()"
alt="Go home button"
aria-label="Home button"
/>
diff --git a/src/app/game/game-result/game-result.component.ts b/src/app/game/game-result/game-result.component.ts
index 407be41b..e18ea067 100644
--- a/src/app/game/game-result/game-result.component.ts
+++ b/src/app/game/game-result/game-result.component.ts
@@ -77,7 +77,7 @@ export class GameResultComponent implements OnInit, OnDestroy {
PointerSide = PointerSide;
ArrowAlignment = ArrowAlignment;
- homeButtonStyleClass = ButtonStyleClass.home;
+ homeButtonStyleClass = ButtonStyleClass.end;
playAgainButtonStyleClass = ButtonStyleClass.playAgain;
constructor(
diff --git a/src/app/game/shared-components/custom-button/custom-button.component.html b/src/app/game/shared-components/custom-button/custom-button.component.html
index 0f093b6f..db395423 100644
--- a/src/app/game/shared-components/custom-button/custom-button.component.html
+++ b/src/app/game/shared-components/custom-button/custom-button.component.html
@@ -34,13 +34,12 @@
[@buttonClickEffect]="buttonState"
(click)="onButtonClick()">
- @switch (buttonStyle) {
- @case ('back-button') {
-
- }
- @case ('home-button') {
-
- }
+ @if (buttonStyle === 'home-button' || buttonStyle === 'end-button') {
+
+ }
+
+ @else if (buttonStyle === 'back-button') {
+
}
{{buttonText}}
diff --git a/src/app/game/shared-components/custom-button/custom-button.component.scss b/src/app/game/shared-components/custom-button/custom-button.component.scss
index 382a6af3..27b1b1fa 100644
--- a/src/app/game/shared-components/custom-button/custom-button.component.scss
+++ b/src/app/game/shared-components/custom-button/custom-button.component.scss
@@ -59,7 +59,8 @@
}
.back-button,
-.home-button {
+.home-button,
+.end-button {
@include button(false, false, true);
}
diff --git a/src/app/game/shared-components/custom-button/custom-button.component.ts b/src/app/game/shared-components/custom-button/custom-button.component.ts
index ab9c326d..caf7ee6a 100644
--- a/src/app/game/shared-components/custom-button/custom-button.component.ts
+++ b/src/app/game/shared-components/custom-button/custom-button.component.ts
@@ -5,7 +5,6 @@ import { MatIcon } from '@angular/material/icon';
import { MatDialog } from '@angular/material/dialog';
import { ConfirmExitDialogComponent } from '../confirm-exit-dialog/confirm-exit-dialog.component';
import { trigger, state, style, transition, animate } from '@angular/animations';
-
@Component({
selector: 'app-custom-button',
templateUrl: './custom-button.component.html',
@@ -36,6 +35,7 @@ export class CustomButtonComponent {
readonly dialog = inject(MatDialog);
readonly router = inject(Router);
+
openDialog(): void {
this.dialog.open(ConfirmExitDialogComponent);
}
diff --git a/src/app/shared/buttonStyles.ts b/src/app/shared/buttonStyles.ts
index fe9b38fa..6a397390 100644
--- a/src/app/shared/buttonStyles.ts
+++ b/src/app/shared/buttonStyles.ts
@@ -3,6 +3,7 @@ export enum ButtonStyleClass {
idle = 'idle-button',
back = 'back-button',
home = 'home-button',
+ end = 'end-button',
forward = 'forward-button',
select = 'select-mode-button',
selectLarge = 'select-mode-button-large',
From 8d1246abe1a91ae4a19ab69ef51bf8a07c00aba8 Mon Sep 17 00:00:00 2001
From: filvanh
Date: Thu, 26 Sep 2024 11:03:58 +0200
Subject: [PATCH 04/13] =?UTF-8?q?legg=20til=20delay=20p=C3=A5=20knappen=20?=
=?UTF-8?q?i=20intermediate=20result=20for=20bedre=20spillflyt?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
...-intermediate-result-footer.component.html | 19 ++++++++++--------
...me-intermediate-result-footer.component.ts | 20 ++++++++++++++++---
.../game-word-to-draw.component.scss | 5 ++---
3 files changed, 30 insertions(+), 14 deletions(-)
diff --git a/src/app/game/game-intermediate-result/game-intermediate-result-footer/game-intermediate-result-footer.component.html b/src/app/game/game-intermediate-result/game-intermediate-result-footer/game-intermediate-result-footer.component.html
index a176debd..69b73b6b 100644
--- a/src/app/game/game-intermediate-result/game-intermediate-result-footer/game-intermediate-result-footer.component.html
+++ b/src/app/game/game-intermediate-result/game-intermediate-result-footer/game-intermediate-result-footer.component.html
@@ -1,10 +1,13 @@
diff --git a/src/app/game/game-intermediate-result/game-intermediate-result-footer/game-intermediate-result-footer.component.ts b/src/app/game/game-intermediate-result/game-intermediate-result-footer/game-intermediate-result-footer.component.ts
index ebd63799..0dc0fcd5 100644
--- a/src/app/game/game-intermediate-result/game-intermediate-result-footer/game-intermediate-result-footer.component.ts
+++ b/src/app/game/game-intermediate-result/game-intermediate-result-footer/game-intermediate-result-footer.component.ts
@@ -6,18 +6,27 @@ import { MultiplayerService } from '../../services/multiplayer.service';
import { GameStateService } from '../../services/game-state-service';
import { CustomButtonComponent } from '../../shared-components/custom-button/custom-button.component';
import { ButtonStyleClass } from '@/app/shared/buttonStyles';
+import { animate, state, style, transition, trigger } from '@angular/animations';
@Component({
selector: 'app-game-intermediate-result-footer',
standalone: true,
imports: [TranslatePipe, MatIcon, CustomButtonComponent],
templateUrl: './game-intermediate-result-footer.component.html',
styleUrl: './game-intermediate-result-footer.component.scss',
+ animations: [
+ trigger('makeVisible', [
+ state('hidden', style({ opacity: 0 })),
+ state('visible', style({ opacity: 1 })),
+ transition('hidden => visible', animate('1s 0.8s')),
+ ]),
+ ]
})
export class GameIntermediateResultFooterComponent implements OnInit {
buttonTextKey = '';
waitingForPlayerState = 'WAITING';
isWaitingForPlayer = false;
-
+ progressionButton = 'hidden';
+ buttonsAreDisabled = true;
buttonStyleClass = ButtonStyleClass.forward;
constructor(private gameStateService: GameStateService, private multiplayerService: MultiplayerService) {}
@@ -25,8 +34,13 @@ export class GameIntermediateResultFooterComponent implements OnInit {
ngOnInit(): void {
this.buttonTextKey = this.getButtonTextKey();
- if (this.gameStateService.isSingleplayer()) return;
-
+ if (this.gameStateService.isSingleplayer()) {
+ setTimeout(() => {
+ this.progressionButton = 'visible';
+ this.buttonsAreDisabled = false;
+ }, 0);
+ return;
+ }
this.isWaitingForPlayer = true; // default in multiplayer set to true
this.multiplayerService.stateInfo$.subscribe((res) => {
if (res.ready) {
diff --git a/src/app/game/game-word-to-draw/game-word-to-draw.component.scss b/src/app/game/game-word-to-draw/game-word-to-draw.component.scss
index 57a92018..c141a155 100644
--- a/src/app/game/game-word-to-draw/game-word-to-draw.component.scss
+++ b/src/app/game/game-word-to-draw/game-word-to-draw.component.scss
@@ -109,8 +109,7 @@ footer {
.footer-content {
display: flex;
align-items: flex-end;
- justify-content: flex-end;
- gap: 17rem;
+ justify-content: space-between;
width: 100%;
height: 100%;
}
@@ -150,7 +149,7 @@ footer {
#difficulty {
margin-bottom: 1.2rem;
- transform: translate(-50%);
+ margin-left: 35rem;
text-align: center;
font-family: AeonikRegular;
font-size: var(--fontSizeSmall);
From d44f443a53c02b66fec9dce4179125925ed3f89c Mon Sep 17 00:00:00 2001
From: filvanh
Date: Thu, 26 Sep 2024 12:24:39 +0200
Subject: [PATCH 05/13] =?UTF-8?q?Legg=20til=20delay=20og=20disabled=20i=20?=
=?UTF-8?q?knappen=20p=C3=A5=20intermediatge=20comp?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../game-intermediate-result-footer.component.ts | 16 +++++++++++-----
.../game/game-result/game-result.component.html | 4 +++-
.../game/game-result/game-result.component.ts | 6 ++++++
3 files changed, 20 insertions(+), 6 deletions(-)
diff --git a/src/app/game/game-intermediate-result/game-intermediate-result-footer/game-intermediate-result-footer.component.ts b/src/app/game/game-intermediate-result/game-intermediate-result-footer/game-intermediate-result-footer.component.ts
index 0dc0fcd5..32fa1880 100644
--- a/src/app/game/game-intermediate-result/game-intermediate-result-footer/game-intermediate-result-footer.component.ts
+++ b/src/app/game/game-intermediate-result/game-intermediate-result-footer/game-intermediate-result-footer.component.ts
@@ -17,7 +17,7 @@ import { animate, state, style, transition, trigger } from '@angular/animations'
trigger('makeVisible', [
state('hidden', style({ opacity: 0 })),
state('visible', style({ opacity: 1 })),
- transition('hidden => visible', animate('1s 0.8s')),
+ transition('hidden => visible', animate('1s')),
]),
]
})
@@ -34,11 +34,10 @@ export class GameIntermediateResultFooterComponent implements OnInit {
ngOnInit(): void {
this.buttonTextKey = this.getButtonTextKey();
+ this.startAnimation();
+
+
if (this.gameStateService.isSingleplayer()) {
- setTimeout(() => {
- this.progressionButton = 'visible';
- this.buttonsAreDisabled = false;
- }, 0);
return;
}
this.isWaitingForPlayer = true; // default in multiplayer set to true
@@ -86,4 +85,11 @@ export class GameIntermediateResultFooterComponent implements OnInit {
}
return 'button-container';
}
+
+ startAnimation() {
+ setTimeout(() => {
+ this.progressionButton = 'visible';
+ this.buttonsAreDisabled = false;
+ }, 800);
+ };
}
diff --git a/src/app/game/game-result/game-result.component.html b/src/app/game/game-result/game-result.component.html
index b2136222..8196252b 100644
--- a/src/app/game/game-result/game-result.component.html
+++ b/src/app/game/game-result/game-result.component.html
@@ -106,8 +106,9 @@
-