1
0

style session rules

This commit is contained in:
Adrian Wannenmacher 2026-03-03 23:21:28 +01:00
parent d74c9ed798
commit f9d33b746f
Signed by: tfld
GPG Key ID: 19D986ECB1E492D5
3 changed files with 115 additions and 26 deletions

View File

@ -4,18 +4,26 @@ html {
--color-regular-text: white; --color-regular-text: white;
--color-regular-background: lch(from black calc(l + 10) c h); --color-regular-background: lch(from black calc(l + 10) c h);
--color-regular-field: black;
--color-alter-text: white; --color-alter-text: white;
--color-alter-background: black; --color-alter-background: black;
--color-alter-field: var(--color-regular-background);
--color-primary-text: black; --color-primary-text: black;
--color-primary-background: lch(from orange calc(l + 10) c h); --color-primary-background: lch(from orange calc(l + 10) c h);
--color-primary-field:
lch(from var(--color-primary-background) calc(l + 25) c h);
@media (prefers-color-scheme: light) { @media (prefers-color-scheme: light) {
--color-regular-text: black; --color-regular-text: black;
--color-regular-background: white; --color-regular-background: white;
--color-regular-field: var(--color-alter-background);
--color-alter-text: black; --color-alter-text: black;
--color-alter-background: lch(from white calc(l - 10) c h); --color-alter-background: lch(from white calc(l - 10) c h);
--color-alter-field: white;
--color-primary-text: black; --color-primary-text: black;
--color-primary-background: lch(from orange calc(l + 10) c h); --color-primary-background: lch(from orange calc(l + 10) c h);
--color-primary-field:
lch(from var(--color-primary-background) calc(l + 25) c h);
} }
color: var(--color-regular-text); color: var(--color-regular-text);
@ -23,6 +31,7 @@ html {
--color-active-text: var(--color-regular-text); --color-active-text: var(--color-regular-text);
--color-active-background: var(--color-regular-background); --color-active-background: var(--color-regular-background);
--color-active-field: var(--color-regular-field);
} }
.background { .background {
@ -32,28 +41,35 @@ html {
.regular, .regular,
.alter, .alter,
.primary { .primary {
color: var(--color-alter-text); color: var(--color-active-text);
} }
.regular { .regular {
--color-active-text: var(--color-regular-text); --color-active-text: var(--color-regular-text);
--color-active-background: var(--color-regular-background); --color-active-background: var(--color-regular-background);
--color-active-field: var(--color-regular-field);
} }
.alter { .alter {
--color-active-text: var(--color-alter-text); --color-active-text: var(--color-alter-text);
--color-active-background: var(--color-alter-background); --color-active-background: var(--color-alter-background);
--color-active-field: var(--color-alter-field);
} }
.primary { .primary {
--color-active-text: var(--color-primary-text); --color-active-text: var(--color-primary-text);
--color-active-background: var(--color-primary-background); --color-active-background: var(--color-primary-background);
--color-active-field: var(--color-primary-field);
} }
.positioned { .positioned {
margin: 0; margin: 0;
} }
.padded {
padding: 1em;
}
body { body {
min-height: 100%; min-height: 100%;
height: 1px; height: 1px;
@ -63,26 +79,38 @@ body {
h1 { h1 {
font-size: 2em; font-size: 2em;
margin-top: 0.75em;
margin-bottom: 0.5em;
} }
h2 { h2 {
font-size: 1.75em; font-size: 1.75em;
margin-top: 0.75em;
margin-bottom: 0.5em;
} }
h3 { h3 {
font-size: 1.5em; font-size: 1.5em;
margin-top: 0.75em;
margin-bottom: 0.5em;
} }
h4 { h4 {
font-size: 1.35em; font-size: 1.35em;
margin-top: 0.75em;
margin-bottom: 0.5em;
} }
h5 { h5 {
font-size: 1.25em; font-size: 1.25em;
margin-top: 0.75em;
margin-bottom: 0.5em;
} }
h6 { h6 {
font-size: 1.1em; font-size: 1.1em;
margin-top: 0.75em;
margin-bottom: 0.5em;
} }
button { button {
@ -162,7 +190,7 @@ main.layout {
align-items: center; align-items: center;
} }
>.spacer { :nth-last-child(2) {
flex-grow: 1; flex-grow: 1;
} }
@ -248,4 +276,53 @@ main.layout {
button { button {
width: 100%; width: 100%;
} }
}
.field {
display: grid;
grid-template-areas: "label" "field" "description";
grid-template-columns: 1fr;
grid-template-rows: repeat(3, min-content);
column-gap: 1ch;
row-gap: 0.5ch;
&:not(:last-child) {
margin-bottom: 1em;
}
&:has(input[type=radio]),
&:has(input[type=checkbox]) {
grid-template-areas: "field label" ". description";
grid-template-columns: min-content 1fr;
grid-template-rows: repeat(2, min-content);
}
.label {
grid-area: label;
font-weight: bold;
}
input {
grid-area: field;
padding: 0.5em;
border-radius: 5px;
background-color: var(--color-active-field);
border: solid 1px var(--color-active-text);
color: var(--color-active-text);
}
.description {
grid-area: description;
}
}
.session-head {
>:first-child {
margin-top: 0;
}
>:last-child {
margin-bottom: 0;
}
} }

View File

@ -14,20 +14,22 @@ export default class SessionView {
let res = model.result; let res = model.result;
return m("article.session-view", [ return m("article.session-view", [
m(".session-view-header", [
m("h2.positioned", "Satz"),
(model.games.length !== 0)
? m(
"button.positioned",
{ onclick: () => this.#headOpen = !this.#headOpen },
"Regln"
)
: null,
]),
( model.games.length === 0 && model.currentGame === null) ( model.games.length === 0 && model.currentGame === null)
? m(SessionHead, { model }) ? m(SessionHead, { model })
: m.fragment([ : m.fragment([
this.#headOpen ? m(SessionHead, { model }) : null, m(".session-view-header", [
m("h2.positioned", "Satz"),
m(
"button.positioned",
{ onclick: () => this.#headOpen = !this.#headOpen },
"Regln"
),
]),
this.#headOpen
? m(".alter.background.padded", m(SessionHead, { model }))
: null,
m("section.record", [ m("section.record", [
this.#headOpen ? m("h3", "Mitschrift") : null, this.#headOpen ? m("h3", "Mitschrift") : null,
m("table", [ m("table", [
@ -52,7 +54,7 @@ export default class SessionView {
]) ])
]), ]),
]), ]),
m(".spacer"),
model.currentGame !== null model.currentGame !== null
? model.currentGame.currentRound !== null ? model.currentGame.currentRound !== null
? m(RoundView, { model: model.currentGame.currentRound }) ? m(RoundView, { model: model.currentGame.currentRound })

View File

@ -6,20 +6,20 @@ import Session from "/models/session.js";
export default class SessionHead { export default class SessionHead {
/** @param {{ attrs: { model: Session } }} param The session model to use. */ /** @param {{ attrs: { model: Session } }} param The session model to use. */
view({ attrs: { model } }) { view({ attrs: { model } }) {
return m("section.session_head", [ return m("section.session-head", [
m("h3", "Satzeinstellungen"), m("h3", "Satzeinstellungen"),
m("section.session-head-names", [ m("section.session-head-names", [
m("h4", "Teamnamen"), m("h4", "Teamnamen"),
m("label", [ m("label.field", [
"Nam von eana", m("span.label", "Nam von eana"),
m("input", { m("input", {
placeholder: "Se", placeholder: "Se",
value: model.theirTeam, value: model.theirTeam,
oninput: (e) => model.theirTeam = e.target.value, oninput: (e) => model.theirTeam = e.target.value,
}), }),
]), ]),
m("label", [ m("label.field", [
"Nam von ins", m("span.label", "Nam von ins"),
m("input", { m("input", {
placeholder: "Mia", placeholder: "Mia",
value: model.ourTeam, value: model.ourTeam,
@ -29,13 +29,13 @@ export default class SessionHead {
]), ]),
m("section.session-head-base", [ m("section.session-head-base", [
m("h4", "Grundregln"), m("h4", "Grundregln"),
m("label", [ m("label.field", [
"Punkte zum gwinna", m("span.label", "Punkte zum gwinna"),
m("input", { m("input", {
placeholder: "mindestns 1", placeholder: "mindestns 1",
type: "number", type: "number",
value: model.rules.goal, value: model.rules.goal,
oninput: (e) => { onchange: (e) => {
let num = parseInt(e.target.value); let num = parseInt(e.target.value);
if (!isNaN(num) && num >= 1) if (!isNaN(num) && num >= 1)
model.rules.goal = num; model.rules.goal = num;
@ -47,21 +47,31 @@ export default class SessionHead {
]), ]),
m("section.session-head-raising", [ m("section.session-head-raising", [
m("h4", "Erhöhn"), m("h4", "Erhöhn"),
m("label", [ m("label.field", [
m("input", { m("input", {
type: "radio", type: "radio",
checked: model.rules.raising === RaisingRule.UnlessStricken, checked: model.rules.raising === RaisingRule.UnlessStricken,
oninput: () => model.rules.raising = RaisingRule.UnlessStricken, oninput: () => model.rules.raising = RaisingRule.UnlessStricken,
}), }),
"Außa wenn gstrichn", m("span.label", "Außa wenn gstrichn"),
m("span.description", [
"Di Spiela kennen di Punkte erhöhn, so viel wia's wolln, außa " +
"wenn's scho gstrichn sen.",
m("br"),
m("em", "So steht's in di Regln von da Tirola Wattagmeinschaft"),
]),
]), ]),
m("label", [ m("label.field", [
m("input", { m("input", {
type: "radio", type: "radio",
checked: model.rules.raising === RaisingRule.UntilEnough, checked: model.rules.raising === RaisingRule.UntilEnough,
oninput: () => model.rules.raising = RaisingRule.UntilEnough, oninput: () => model.rules.raising = RaisingRule.UntilEnough,
}), }),
"Bis es langt", m("span.label", "Bis es langt"),
m("span.description", [
"Di Spiela kennen so lang di Punkte erhöhn, bis se mit am Sieg " +
"in da Rundn es ganze Spiel gwonnen hättn.",
])
]), ]),
]), ]),
]) ])