feat(web client): show version number

This commit is contained in:
Henri Bourcereau 2026-05-22 21:42:30 +02:00
parent 4003fc0ef2
commit 1686079ca9
3 changed files with 20 additions and 46 deletions

View file

@ -2076,3 +2076,19 @@ a:hover { text-decoration: underline; }
max-width: 200px;
margin: 0 auto;
}
/* Push the version wrapper to the bottom of the sidebar flex column */
.game-sidebar > div:has(.site-nav-version) {
margin-top: auto;
padding: 0.75rem 1rem;
border-top: 1px solid rgba(200,164,72,0.12);
}
.site-nav-version {
display: block;
text-align: center;
font-family: var(--font-ui);
font-size: 0.7rem;
letter-spacing: 0.06em;
color: rgba(200,164,72,0.4);
}

View file

@ -32,6 +32,7 @@ use std::collections::VecDeque;
const RELAY_URL: &str = "ws://localhost:8080/ws";
const GAME_ID: &str = "trictrac";
const STORAGE_KEY: &str = "trictrac_session";
const VERSION: &str = env!("CARGO_PKG_VERSION");
/// The state the UI needs to render the game screen.
#[derive(Clone, PartialEq)]
@ -621,6 +622,9 @@ fn SiteHamburger() -> impl IntoView {
sidebar_open.set(false);
}>{t!(i18n, replay_snapshot)}</button>
</div>
<div>
<span class="site-nav-version">"v" {VERSION}</span>
</div>
</div>
// ── Replay snapshot modal ─────────────────────────────────────────────

View file

@ -1,46 +0,0 @@
use leptos::prelude::*;
use leptos::task::spawn_local;
use leptos_router::components::A;
use crate::api;
use crate::i18n::*;
#[component]
pub fn SiteNav() -> impl IntoView {
let i18n = use_i18n();
let auth_username =
use_context::<RwSignal<Option<String>>>().expect("auth_username context not found");
let logout = move |_| {
spawn_local(async move {
let _ = api::post_logout().await;
auth_username.set(None);
});
};
view! {
<nav class="site-nav">
<A href="/" attr:class="site-nav-brand">"Trictrac"</A>
<div class="site-nav-spacer" />
<div class="lang-switcher">
<button
class:lang-active=move || i18n.get_locale() == Locale::en
on:click=move |_| i18n.set_locale(Locale::en)
>"EN"</button>
<button
class:lang-active=move || i18n.get_locale() == Locale::fr
on:click=move |_| i18n.set_locale(Locale::fr)
>"FR"</button>
</div>
{move || match auth_username.get() {
Some(u) => view! {
<A href=format!("/profile/{u}")>{ u.clone() }</A>
<button class="site-nav-btn" on:click=logout>{t!(i18n, sign_out)}</button>
}.into_any(),
None => view! {
<A href="/account">{t!(i18n, sign_in)}</A>
}.into_any(),
}}
</nav>
}
}