1
0

restructure basic UI for better semantics

This commit is contained in:
Adrian Wannenmacher 2026-02-18 19:01:10 +01:00
parent 979dfb9b08
commit 0cc3c991e5
Signed by: tfld
GPG Key ID: 19D986ECB1E492D5
3 changed files with 39 additions and 31 deletions

View File

@ -11,33 +11,19 @@ export default class GameView {
let markers = "•".repeat(points);
return m("section", [
m("table", [
m("thead", [
m("tr", [
m("th", "se"), m("th", "mia"),
]),
winner !== null
? m("tr", [
m("td", winner === Team.We ? markers : ""),
m("td", winner === Team.They ? markers : ""),
])
: null,
]),
return m("[", [
m("tbody", model.rounds.map(function(round) {
return m("tr", [
m("td", round.winner === Team.They ? round.points : ""),
m("td", round.winner === Team.We ? round.points : ""),
]);
})),
m("tfoot", [
(!model.decided)
? m("tfoot", [
m("tr", [
m("th", theirPoints), m("th", ourPoints),
]),
]),
]),
(model.currentRound !== null)
? m(RoundView, { model: model.currentRound })
])
: null,
]);
}

View File

@ -2,15 +2,37 @@
import Session from "../models/session.js";
import GameView from "./game.js";
import RoundView from "./round.js";
export default class SessionView {
/** @param {{ attrs: { model: Session } }} param The session model to use. */
view({ attrs: { model, onDeselect } }) {
return m("article", [
let res = model.result;
return m("article", {
class: ["session-view"],
}, [
m("button", { onclick: () => onDeselect() }, "Zruck"),
m("table", [
m("thead", [
m("tr", [
m("th", "se"), m("th", "mia"),
]),
m("tr", [
m("td", "•".repeat(res.theirPoints)),
m("td", "•".repeat(res.ourPoints)),
]),
]),
model.games.map((g) => m(GameView, { model: g })),
model.currentGame !== null
? m(GameView, { model: model.currentGame })
: null,
]),
model.currentGame !== null
? model.currentGame.currentRound !== null
? m(RoundView, { model: model.currentGame.currentRound })
: null
: m("button", { onclick: () => model.anotherGame() }, "no a spiel"),
]);
}

View File

@ -22,7 +22,7 @@ export default class Shell {
if (this.#currentSession !== null)
return m(SessionView, {
model: this.#currentSession,
onDeselect: () => this.#currentSession = null;
onDeselect: () => this.#currentSession = null,
});
if (this.#sessions !== null)