From cc96c3c9d957963e1ef4f4cf8693442698c9e172 Mon Sep 17 00:00:00 2001
From: Daniel Dickison
Date: Sun, 31 Dec 2023 21:21:25 -0800
Subject: [PATCH] Only show numerical rank and win totals on hover
---
public/scss/index.scss | 54 +++++++++++++++++++++++-------------------
src/handlers/index.rs | 7 ++++--
templates/index.html | 17 +++++--------
3 files changed, 41 insertions(+), 37 deletions(-)
diff --git a/public/scss/index.scss b/public/scss/index.scss
index bf1a81d..e076e91 100644
--- a/public/scss/index.scss
+++ b/public/scss/index.scss
@@ -145,10 +145,23 @@
}
&.rank-name-y {
- font-size: larger;
+ font-size: x-large;
+ }
+ &.rank-name-o,
+ &.rank-name-s,
+ &.rank-name-k, {
+ font-size: large;
}
&.rank-name-j {
- font-size: smaller;
+ font-size: small;
+ }
+ &.rank-name-ms {
+ font-size: x-small;
+ }
+ &.rank-name-sd,
+ &.rank-name-jd,
+ &.rank-name-jk {
+ font-size: xx-small;
}
a {
@@ -156,13 +169,27 @@
}
h3 {
- text-align: center;
+ text-align: left;
margin: 1.5em 0 0.25em;
+
+ > .hover {
+ font-size: x-small;
+ color: var(--color-fg-sub);
+ opacity: 0;
+ }
+ }
+ &:hover h3 > .hover {
+ opacity: 1;
}
.players {
margin: 0;
padding: 0;
+ display: flex;
+ flex-flow: row wrap;
+ align-items: baseline;
+ column-gap: 1em;
+
> li {
list-style: none;
@@ -172,27 +199,6 @@
}
}
}
-
- .wins {
- font-size: smaller;
-
- &::before {
- content: '(';
- }
- &::after {
- content: ')';
- }
- }
-
- .ord {
- font-size: smaller;
- display: inline-block;
- min-width: 3ex;
-
- &::before {
- content: '#';
- }
- }
}
}
diff --git a/src/handlers/index.rs b/src/handlers/index.rs
index 1509af2..e22600b 100644
--- a/src/handlers/index.rs
+++ b/src/handlers/index.rs
@@ -21,10 +21,13 @@ pub struct IndexTemplate {
}
impl IndexTemplate {
- fn leaders_by_rank(&self) -> Vec<(Rank, &[PlayerRanking])> {
+ fn leaders_by_rank(&self) -> Vec<(Rank, usize, u32, &[PlayerRanking])> {
self.leaders
.group_runs(|a, b| a.rank == b.rank)
- .map(|group| (group.first().unwrap().rank, group))
+ .map(|group| {
+ let first = group.first().unwrap();
+ (first.rank, first.ord, first.wins, group)
+ })
.collect()
}
diff --git a/templates/index.html b/templates/index.html
index dd43480..0be2ce1 100644
--- a/templates/index.html
+++ b/templates/index.html
@@ -75,23 +75,18 @@
{% endif %}
- {% for (rank, players) in self.leaders_by_rank() %}
+ {% for (rank, ord, wins, players) in self.leaders_by_rank() %}
-
{{"{:#}"|format(rank)}}
+
+ {{"{:#}"|format(rank)}}
+ #{{ord}} ({{wins}} wins)
+
{% for player in players %}
-
-
- {{-player.ord-}}
-
-
- {{player.player.render().unwrap()|safe}}
-
-
- {{-player.wins-}}
-
+ {{player.player.render().unwrap()|safe}}
{% endfor %}