Tell why the home has no cards yet and tidy the cards code after review (#72)

Without statistics the home said « Aucun champion trouvé » under a count of
0; it now shows the same notice as the champ select (loading, no Account),
from a small StatsNotice enum instead of compared strings.

Also from the review: a structural test that hovering or scrolling
« Autres champions » recomputes no statistics, as docs/performance.md says;
English comments; one card aspect (core's CARD_ASPECT) and one cards_dir;
one builder for the champ select cards, one count badge, one test temp dir;
clearer names (with_cards_behaviour, home_has_own_scope).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
nessarandClaude Opus 5.5 committed 2026-11-21 02:26:14 +01:00
1 parent 213d693ab8
commit 72f7a239c0
8 files changed
+303 -106

No files matched your search

+10 -4
View File
@@ -92,16 +92,22 @@ impl ChampionSource for DataDragon {
const CARD_PORTRAIT_WIDTH: u32 = 308;
/// Height of a stored card portrait: `CARD_PORTRAIT_WIDTH / CARD_ASPECT`, rounded.
const CARD_PORTRAIT_HEIGHT: u32 = 453;
/// A card's width / height (the mockup's `.card { aspect-ratio: .68 }`).
const CARD_ASPECT: f64 = 0.68;
/// A card's width over its height (the mockup's `.card { aspect-ratio: .68 }`): the ratio the
/// stored card portraits are cropped to, and the one the app draws its cards at.
pub const CARD_ASPECT: f64 = 0.68;
/// Where the crop window sits in the overflow (the mockup's `object-position: 50% 24%`).
const CARD_FOCUS_X: f64 = 0.5;
const CARD_FOCUS_Y: f64 = 0.24;
const CARD_JPEG_QUALITY: u8 = 85;
/// The folder of the card portraits, in the portraits folder.
pub(crate) fn cards_dir(portraits_dir: &Path) -> PathBuf {
portraits_dir.join("cards")
}
/// Where a champion's card portrait is kept.
pub(crate) fn card_portrait_path(portraits_dir: &Path, key: &str) -> PathBuf {
portraits_dir.join("cards").join(format!("{key}.jpg"))
cards_dir(portraits_dir).join(format!("{key}.jpg"))
}
/// The crop window (x, y, width, height) that `object-fit: cover` with the card's
@@ -252,7 +258,7 @@ impl Tracker {
let Some((source, portraits_dir)) = &self.champions else {
return Ok(());
};
let cards_dir = portraits_dir.join("cards");
let cards_dir = cards_dir(portraits_dir);
std::fs::create_dir_all(&cards_dir)
.map_err(|e| Error::Storage(format!("{} : {e}", cards_dir.display())))?;
for champion in self.cached_champions()? {