Skip to content

Commit

Permalink
Merge branch 'feature/#116-mode-view' into feature/#115-AddPlayerPane…
Browse files Browse the repository at this point in the history
…l-styling
  • Loading branch information
SebastianBabinski1 committed Feb 13, 2021
2 parents 0cb717b + 389f85c commit 2069cfd
Show file tree
Hide file tree
Showing 14 changed files with 236 additions and 68 deletions.
11 changes: 11 additions & 0 deletions src/Interfaces/CallbackInterface.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
export interface CallbackNoParam<T = void> {
(): T;
}

export interface CallbackOneParam<T1, T2 = void> {
(param1: T1): T2;
}

export interface CallbackTwoParam<T1, T2, T3 = void> {
(param1: T1, param2: T2): T3;
}
3 changes: 0 additions & 3 deletions src/Interfaces/CallbackNoParam.ts

This file was deleted.

3 changes: 0 additions & 3 deletions src/Interfaces/CallbackOneParamInterface.ts

This file was deleted.

1 change: 1 addition & 0 deletions src/Interfaces/PlayerDTOInterface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ export interface PlayerDTO {
name: string;
path: string;
color: string;
isAI: boolean;
}
25 changes: 25 additions & 0 deletions src/app/EmptyView.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { Render } from './utils/Render';

export abstract class EmptyView {
protected view: HTMLElement;
protected viewContainer: HTMLElement;

constructor(isHidden = true) {
this.viewContainer = Render.elementFactory('div', {
className: 'view__container',
});
this.view = Render.elementFactory(
'div',
{ className: `view${isHidden ? ' hidden' : ''}` },
this.viewContainer,
);
}

hide(): void {
this.view.classList.add('hidden');
}

show(): void {
this.view.classList.remove('hidden');
}
}
31 changes: 19 additions & 12 deletions src/app/MenuView.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,30 @@
import { ModeModal } from './components/ModeModal';
import { PlayerDTO } from '~src/Interfaces/PlayerDTOInterface';
import { EmptyView } from './EmptyView';
import { ModeView } from './ModeView';
import { Render } from './utils/Render';
import { ViewController } from './ViewController';

export class MenuView {
private modeModal: ModeModal;
constructor(private view: ViewController) {
this.modeModal = new ModeModal((players) =>
this.view.launchGame(players),
);
this.modeModal.hideModal();
Render.render('body', this.modeModal.createModeModal());
export class MenuView extends EmptyView {
private modeModal: ModeView;
constructor(private viewController: ViewController) {
super(false);
const backCallback = () => this.show();
const submitCallback = (
isDynamic: boolean,
players: PlayerDTO[],
) => this.viewController.launchGame(players);
this.modeModal = new ModeView(backCallback, submitCallback);
Render.render('body', this.modeModal.theModeView);
}

displayMenu(): void {
Render.removeAllChildren('#sf-app');
Render.render(
'#sf-app',
Render.childrenInjector(
this.viewContainer,
this.createLandingPage(),
this.createFooter(),
);
Render.render('#sf-app', this.view);
}

private createLandingPage(): HTMLElement {
Expand Down Expand Up @@ -81,7 +87,8 @@ export class MenuView {
'NEW GAME',
);
startGameButton.addEventListener('click', () => {
this.modeModal.showModal();
this.hide();
this.modeModal.show();
});
const settingsButton = Render.elementFactory(
'button',
Expand Down
Loading

0 comments on commit 2069cfd

Please sign in to comment.