Skip to content

Commit

Permalink
feat: add game disabled state (#489)
Browse files Browse the repository at this point in the history
* disabled most things

* feat: improve it a lot

* chore: derp
  • Loading branch information
RogierdeRuijter authored Sep 1, 2020
1 parent 9c18bfe commit f2af2eb
Show file tree
Hide file tree
Showing 9 changed files with 54 additions and 11 deletions.
1 change: 1 addition & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,7 @@ jobs:
# - SERVER_IMAGE_TAG
npm run docker:e2e:start-environment-build-server
- run:
name: Retag and push tested client image
command: |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {DialogDataComponent} from './components/dialog-data/dialog-data.componen
import {DialogOverviewComponent} from './components/dialog-overview/dialog-overview.component';
import {CustomTranslateModule} from '../translate/custom-translate.module';
import {ButtonModule} from '../button/button.module';
import {FormsModule} from '@angular/forms';
import {FormsModule, ReactiveFormsModule} from '@angular/forms';
import {GameResultComponent} from './components/dialog-data/game-result/game-result.component';
import {FormModule} from '../form/form.module';
import {GridModule} from '../grid/grid.module';
Expand Down Expand Up @@ -42,7 +42,8 @@ import { MatFormFieldModule } from '@angular/material/form-field';
GridModule,
TransitionModule,
MatChipsModule,
MatFormFieldModule
MatFormFieldModule,
ReactiveFormsModule
],
})
export class AddGameModule { }
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
[usersWhite]="users"
[winnerOptions]="winnerOptions"
[winnersDeselected]="winnersDeselected"
[blackDeselected]="blackDeselected"
[disabledWinnerOptions]="determineDisabledWinnerOptions()"
[blackDisabled]="!data.white"
[winnersDisabled]="areAllWinnerOptionsDisabled()"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ export class DialogDataComponent extends AsyncBaseComponent implements OnInit, O

public winnerOptions: string[] = [];

public winnersDeselected;
public winnersDeselected: boolean;
public blackDeselected: boolean;

public draw: string;

Expand Down Expand Up @@ -65,9 +66,15 @@ export class DialogDataComponent extends AsyncBaseComponent implements OnInit, O
private updateGame(event: {name: string, value: string}): void {
// Needed to have a pointer change for the input
this.winnersDeselected = undefined;

this.blackDeselected = undefined;

this.data[event.name] = event.value;

if (event.name === 'white' && event.value === undefined) {
this.data.black = undefined;
this.blackDeselected = false;
}

if (event.value === undefined) {
this.data.winner = undefined;
this.winnersDeselected = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,29 @@

@mixin game-result-component-theme($theme) {
$disabled-color: map-get($theme, form-field-underline-disabled);
$label-color: map-get($theme, label-color);

.form-field-with-disabled-underline {
.mat-form-field-underline {
background-color: $disabled-color;
}

mat-label {
color: $disabled-color;
}
}

.custom-input-field {
.mat-form-field-label {
color: $label-color !important;
}

.mat-form-field-ripple {
opacity: 0 !important;
}

.mat-standard-chip:focus::after {
opacity: 0 !important;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@ <h2 appTranslate="pages.home.games.pop-up.title" mat-dialog-title></h2>
<div mat-dialog-content>
<form #form="ngForm">
<div>
<mat-form-field color="accent">
<mat-form-field class="custom-input-field" color="accent" (click)="clicked()">
<mat-label [appTranslate]="'pages.home.games.labels.white'"></mat-label>
<mat-chip-list id='white-user'
selectable
(change)="onListChange($event, 'white')"
(change)="onListChange($event, 'white')"
name="white">
<mat-chip *ngFor="let user of usersWhite"
#matChip="matChip"
[id]="'white-' + user.name"
[disabled]="user.name === data.black"
[disableRipple]="true"
(click)="fieldUpdated(matChip);"
color="accent"
[value]="user.name">
Expand All @@ -21,14 +22,16 @@ <h2 appTranslate="pages.home.games.pop-up.title" mat-dialog-title></h2>
</mat-form-field>
</div>
<div [class.form-field-with-disabled-underline]="blackDisabled">
<mat-form-field color="accent">
<mat-form-field class="custom-input-field" color="accent">
<mat-label [appTranslate]="'pages.home.games.labels.black'"></mat-label>
<mat-chip-list id='black-user' selectable
(change)="onListChange($event, 'black')" name="black">
<mat-chip *ngFor="let user of usersBlack"
#matChip="matChip"
[id]="'black-' + user.name"
[selected]="blackDeselected"
[disabled]="!data.white || user.name === data.white"
[disableRipple]="true"
(click)="fieldUpdated(matChip);"
color="accent"
[value]="user.name">
Expand All @@ -38,14 +41,15 @@ <h2 appTranslate="pages.home.games.pop-up.title" mat-dialog-title></h2>
</mat-form-field>
</div>
<div [class.form-field-with-disabled-underline]="winnersDisabled">
<mat-form-field color="accent">
<mat-form-field class="custom-input-field" color="accent">
<mat-label [appTranslate]="'pages.home.games.labels.winner'"></mat-label>
<mat-chip-list id='winner-user' (change)="onListChange($event, 'winner')" name="winner">
<mat-chip *ngFor="let option of winnerOptions; let i = index"
#matChip="matChip"
[id]="'winner-' + option"
[selected]="winnersDeselected"
[disabled]="disabledWinnerOptions[i]"
[disableRipple]="true"
(click)="fieldUpdated(matChip);"
color="accent"
[value]="option">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ export class GameResultComponent {
@Input()
public winnersDeselected: boolean;

@Input()
public blackDeselected: boolean;

@Input()
public winnersDisabled: boolean;

Expand All @@ -64,7 +67,7 @@ export class GameResultComponent {
public GridSizes = GridSizes;
public Icons = Icons;
public timer = timer;

public cancel(): void {
this.cancelEvent.emit();
}
Expand All @@ -81,4 +84,9 @@ export class GameResultComponent {
value: event.value
});
}

public clicked(): void {
setTimeout(() => {
document.getElementById('formField123').blur();
}, 200); }
}
3 changes: 2 additions & 1 deletion apps/client/src/themes/black-theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ $custom-variables: (
action-bar-border-background: mat-color($anms-black-primary),
button-icon-active-color: white,
button-icon-inactive-color: gray,
form-field-underline-disabled: #616161
form-field-underline-disabled: #616161,
label-color: rgba(255, 255, 255, 0.7)
);

$anms-black-theme: map_merge($anms-black-theme, $custom-variables);
3 changes: 2 additions & 1 deletion apps/client/src/themes/light-theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ $custom-variables: (
action-bar-border-background: white,
button-icon-active-color: black,
button-icon-inactive-color: gray,
form-field-underline-disabled: #e0e0e0
form-field-underline-disabled: #e0e0e0,
label-color: rgba(0, 0, 0, 0.54)
);

$anms-light-theme: map_merge($anms-light-theme, $custom-variables);

0 comments on commit f2af2eb

Please sign in to comment.