-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhomepage.js
34 lines (28 loc) · 836 Bytes
/
homepage.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import { Game } from "./game";
import { createHTMLElement } from "./helpers";
import { Slider } from "./slider";
export class Homepage {
constructor({ wrapSelector }) {
this.wrap = document.querySelector(wrapSelector);
this.wrapSelector = wrapSelector;
this.init();
}
createHomepageHTML() {
this.slider = new Slider({ wrapSelector: this.wrapSelector });
this.wrap.appendChild(
createHTMLElement("button", {
className: "button",
id: "newGameBtn",
textContent: "New Game",
})
);
this.newGameButton = document.querySelector("#newGameBtn");
}
init() {
this.createHomepageHTML();
this.newGameButton.addEventListener("click", () => {
this.wrap.innerHTML = "";
new Game({ wrapSelector: this.wrapSelector, slider: this.slider });
});
}
}