Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add theming to underline #487

Merged
merged 1 commit into from
Aug 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,7 @@
[winnerOptions]="winnerOptions"
[winnersDeselected]="winnersDeselected"
[disabledWinnerOptions]="determineDisabledWinnerOptions()"
[blackDisabled]="!data.white"
[winnersDisabled]="areAllWinnerOptionsDisabled()"
[winners]="winners">
</ui-game-result>
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ export class DialogDataComponent extends AsyncBaseComponent implements OnInit, O
return this.dialogDataService.determineDisabledWinnerOptions(this.winnerOptions, this.data, this.draw);
}

public areAllWinnerOptionsDisabled(): boolean {
return this.dialogDataService.areAllWinnerOptionsDisabled(this.winnerOptions, this.data, this.draw);
}

private determineWinnerOptions(users: User[]): void {
this.winnerOptions = [];

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
@import '~@angular/material/theming';

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

.form-field-with-disabled-underline {
.mat-form-field-underline {
background-color: $disabled-color;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<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-label [appTranslate]="'pages.home.games.labels.white'"></mat-label>
<mat-chip-list id='white-user'
Expand All @@ -16,9 +17,10 @@ <h2 appTranslate="pages.home.games.pop-up.title" mat-dialog-title></h2>
[value]="user.name">
{{user.name}}
</mat-chip>
</mat-chip-list>
</mat-form-field>
<div>
</mat-chip-list>
</mat-form-field>
</div>
<div [class.form-field-with-disabled-underline]="blackDisabled">
<mat-form-field color="accent">
<mat-label [appTranslate]="'pages.home.games.labels.black'"></mat-label>
<mat-chip-list id='black-user' selectable
Expand All @@ -35,7 +37,7 @@ <h2 appTranslate="pages.home.games.pop-up.title" mat-dialog-title></h2>
</mat-chip-list>
</mat-form-field>
</div>
<div>
<div [class.form-field-with-disabled-underline]="winnersDisabled">
<mat-form-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">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

.mat-form-field {
display: block;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,14 @@ export class GameResultComponent {
@Input()
public winnersDeselected: boolean;

@Input()
public winnersDisabled: boolean;

@Input()
public blackDisabled: boolean;

@Output()
public fieldUpdateEvent: EventEmitter<{name: string, value: string}> = new EventEmitter(); // TODO: interface
public fieldUpdateEvent: EventEmitter<{name: string, value: string}> = new EventEmitter();

@Output()
public cancelEvent: EventEmitter<void> = new EventEmitter();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,4 +129,65 @@ describe('DialogDataService', () => {

});
});

describe('areAllWinnerOptionsDisabled', () => {
it('should return true if the white and black players are not defined in the game', () => {
const service: DialogDataService = TestBed.inject(DialogDataService);

const winnerOptions = ['user', 'user1', 'user2', 'Draw'];
const game: Game = new GameFactory().create();
const draw = 'Draw';

const result = service.areAllWinnerOptionsDisabled(winnerOptions, game, draw);

const expectedResult = true;

expect(result).toEqual(expectedResult);

});
it('should return true if the white is not defined in the game', () => {
const service: DialogDataService = TestBed.inject(DialogDataService);

const winnerOptions = ['user', 'user1', 'user2', 'Draw'];
const game: Game = new GameFactory().create({white: 'user'});
const draw = 'Draw';

const result = service.areAllWinnerOptionsDisabled(winnerOptions, game, draw);

const expectedResult = true;

expect(result).toEqual(expectedResult);

});

it('should return false if the white and black user are defined in the game', () => {
const service: DialogDataService = TestBed.inject(DialogDataService);

const winnerOptions = ['user', 'user1', 'user2', 'Draw'];
const game: Game = new GameFactory().create({white: 'user', black: 'user1'});
const draw = 'Draw';

const result = service.areAllWinnerOptionsDisabled(winnerOptions, game, draw);

const expectedResult = false;

expect(result).toEqual(expectedResult);

});

it('should return false if the white, black, and winner user are defined in the game', () => {
const service: DialogDataService = TestBed.inject(DialogDataService);

const winnerOptions = ['user', 'user1', 'user2', 'Draw'];
const game: Game = new GameFactory().create({white: 'user', black: 'user1', winner: 'user'});
const draw = 'Draw';

const result = service.areAllWinnerOptionsDisabled(winnerOptions, game, draw);

const expectedResult = false;

expect(result).toEqual(expectedResult);

});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,13 @@ export class DialogDataService {
return winnerOptions.map(() => true);
}
}

public areAllWinnerOptionsDisabled(winnerOptions: string[], game: Game, draw: string): boolean {
const disabledWinnerOptions: boolean[] = this.determineDisabledWinnerOptions(winnerOptions, game, draw);

const found = disabledWinnerOptions
.find((disabledWinnerOption: boolean) => disabledWinnerOption === false);

return found === undefined ? true : false;
}
}
2 changes: 2 additions & 0 deletions apps/client/src/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@
@import './app/main/modules/main-content/modules/larger-screen-content/components/footer/footer.component-theme.scss';
@import './app/main/modules/main-content/modules/mobile-content/components/action-bar-footer/action-bar-footer.component-theme.scss';
@import './app/shared/modules/button/components/button-icon-active-state/button-icon-active-state.component-theme.scss';
@import './app/shared/modules/add-game/components/dialog-data/game-result/game-result.component-theme.scss';

@mixin custom-components-theme($theme) {
@include main-content-component-theme($theme);
@include footer-component-theme($theme);
@include action-bar-footer-component-theme($theme);
@include button-icon-active-state-component-theme($theme);
@include game-result-component-theme($theme);
}

.light-theme {
Expand Down
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 @@ -14,7 +14,8 @@ $custom-variables: (
action-bar-top-border: black,
action-bar-border-background: mat-color($anms-black-primary),
button-icon-active-color: white,
button-icon-inactive-color: gray
button-icon-inactive-color: gray,
form-field-underline-disabled: #616161
);

$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 @@ -14,7 +14,8 @@ $custom-variables: (
action-bar-top-border: lightgray,
action-bar-border-background: white,
button-icon-active-color: black,
button-icon-inactive-color: gray
button-icon-inactive-color: gray,
form-field-underline-disabled: #e0e0e0
);

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