diff --git a/assets/snow.css b/assets/snow.css index a9dbc69..193d93b 100644 --- a/assets/snow.css +++ b/assets/snow.css @@ -1,7 +1,7 @@ /* https://pajasevi.github.io/CSSnowflakes/ */ .snowflake { color: #fff; - font-size: 1em; + font-size: 1.5em; font-family: Arial, sans-serif; text-shadow: 0 0 5px #000; } diff --git a/src/main.rs b/src/main.rs index 58fd091..1c02018 100644 --- a/src/main.rs +++ b/src/main.rs @@ -53,6 +53,7 @@ fn main() { fn App() -> Element { let mut rows = use_signal(State::default); let longest = use_memo(move || rows.read().longest()); + let row_finished = use_memo(move || rows.read().row_finished()); let snow = true; rsx! { document::Link { rel: "icon", href: FAVICON } @@ -82,7 +83,7 @@ fn App() -> Element { } tbody { tr { - th { colspan: 100, "Game 1" } + th { colspan: 100, "Why 5?" } } for row in &rows.read().rows { tr { @@ -91,12 +92,16 @@ fn App() -> Element { } td { class: "number", - colspan: (max(19, longest()).saturating_sub(row.len())).to_string() + colspan: (max(19, longest() + 1).saturating_sub(row.len())).to_string() } td { class: "number", b { - {row.iter().copied().sum::().to_string()} + if row.len() <= 1 { + {row.iter().sum::().to_string()} + } else { + {row.iter().take_while(|&&n| n != 5).sum::().to_string()} + } } } } @@ -105,21 +110,15 @@ fn App() -> Element { } div { class: "controls", - if rows.read().row_finished() { - div { - class: "number-buttons", - for n in 1..=6 { - button { disabled: true, "{n}" } - } + div { + class: "number-buttons", + for n in 1..=6 { + button { disabled: row_finished(), "{n}" } } + } + if row_finished() { button { onclick: move |_| rows.write().new_row(), "Start new row" } } else { - div { - class: "number-buttons", - for n in 1..=6 { - button { onclick: move |_| rows.write().push(n), "{n}" } - } - } button { onclick: move |_| rows.write().roll(), "Roll" } } }