From adc159b829036b15256e54c0ba73d3056143e567 Mon Sep 17 00:00:00 2001 From: Oskar Rough Date: Thu, 25 Jan 2024 14:47:56 +0100 Subject: [PATCH] Improve stats page --- src/ui/pages/stats.astro | 30 ++++++++++++++++++++++-------- src/ui/styles/app.css | 15 +-------------- src/ui/styles/index.css | 2 +- src/ui/styles/typography.css | 18 ++++++++++++++++++ 4 files changed, 42 insertions(+), 23 deletions(-) create mode 100644 src/ui/styles/typography.css diff --git a/src/ui/pages/stats.astro b/src/ui/pages/stats.astro index 49d4f27f..cc722350 100644 --- a/src/ui/pages/stats.astro +++ b/src/ui/pages/stats.astro @@ -1,27 +1,25 @@ --- import Layout from '../layouts/Layout.astro' import {getRuns} from '../../game/backend.js' +import '../styles/typography.css' const runs = (await getRuns()).reverse() ---
-
-

Slay the Web

-

Highscores & Statistics

-
- +

Statistics & Highscores for Slay the Web

+

A chronological list of Slay the Web runs.
- There is quite a bit of statistics that could be gathered from the runs. For now, this is what we have: + There is quite a bit of statistics that could be gathered from the runs, and isn't yet shown here. Chat on #slaytheweb:matrix.org

@@ -45,7 +43,16 @@ const runs = (await getRuns()).reverse() // timeStyle: 'short', hour12: false, }).format(new Date(state.createdAt)) - const duration = state.endedAt ? (state.endedAt - state.createdAt) / 1000 + 's' : '' + + let duration = 0 + if (state.endedAt) { + const ms = state.endedAt - state.createdAt + const hours = Math.floor(ms / (1000 * 60 * 60)) + const minutes = Math.floor((ms % (1000 * 60 * 60)) / (1000 * 60)) + const seconds = Math.floor((ms / 1000) % 60) + duration = `${hours > 0 ? hours + 'h ' : ''}${minutes}m ${seconds}s` + } + return ( @@ -71,5 +78,12 @@ const runs = (await getRuns()).reverse() diff --git a/src/ui/styles/app.css b/src/ui/styles/app.css index 4fe9413c..0df1285c 100644 --- a/src/ui/styles/app.css +++ b/src/ui/styles/app.css @@ -5,8 +5,6 @@ } html { - font-size: max(16px, min(1.7vmin, 24px)); - line-height: 1.4; color: var(--text); cursor: url(/images/cursors/default.png), auto; min-height: 100%; @@ -15,18 +13,7 @@ html { background-position: 50%; background-size: cover; background-repeat: no-repeat; -} - -html, -button, -input, -#driver-popover-content, -.driver-popover .driver-popover-title, -.driver-popover .driver-popover-description, -.driver-popover .driver-popover-footer button { - font-family: 'heliotrope_4', serif; - font-feature-settings: 'kern' 1; - font-feature-settings: 'liga' on; + color: var(--text); } body { diff --git a/src/ui/styles/index.css b/src/ui/styles/index.css index 85c75912..7bec7438 100644 --- a/src/ui/styles/index.css +++ b/src/ui/styles/index.css @@ -1,5 +1,5 @@ +@import './typography.css'; @import './app.css'; -@import './fonts.css'; @import './overlay.css'; @import './card.css'; @import './targets.css'; diff --git a/src/ui/styles/typography.css b/src/ui/styles/typography.css new file mode 100644 index 00000000..4980d876 --- /dev/null +++ b/src/ui/styles/typography.css @@ -0,0 +1,18 @@ +@import './fonts.css'; + +html { + font-size: max(16px, min(1.7vmin, 24px)); + line-height: 1.4; +} + +html, +button, +input, +#driver-popover-content, +.driver-popover .driver-popover-title, +.driver-popover .driver-popover-description, +.driver-popover .driver-popover-footer button { + font-family: 'heliotrope_4', serif; + font-feature-settings: 'kern' 1; + font-feature-settings: 'liga' on; +}
{run.player}