Keep a whole row in "Autres champions" and tidy the cards code (#75)

- "Autres champions" grid is never shorter than one card row.
- A Format change keeps the home's statistics (#71); the home cards
  are built when "Defi" is shown again; hidden grids give back their
  decoded portraits; the card holds its portrait as Arc<Path>.
- Unavailability becomes Unpickable (glossary), "selection" becomes
  "champ select" in comments (#74); the statistics error is shown by
  the banner only during a champ select.
- Column breakpoints follow the mockup's max-width rules, the home
  tools row is search, filters, sort; stale comments fixed.
- Tests: whole row, hidden grids, stats scopes, error shown once, and
  the capture's reasons end to end in the open section.

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 2cd8b2c545
commit 4612d89a3d
8 files changed
+535 -159

No files matched your search

+38 -11
View File
@@ -31,12 +31,13 @@ pub fn init(cx: &mut App) {
/// The widest content column of the home, as in the mockup.
pub const MAX_WIDTH: f32 = 1264.;
/// How many cards fit a row of a window `width` wide, with the mockup's breakpoints.
/// How many cards fit a row of a window `width` wide, with the mockup's breakpoints: its
/// `max-width` rules apply up to and including 1000, 720 and 480 px.
fn columns(width: Pixels) -> usize {
match width.as_f32() {
w if w >= 1000. => 6,
w if w >= 720. => 4,
w if w >= 480. => 3,
w if w > 1000. => 6,
w if w > 720. => 4,
w if w > 480. => 3,
_ => 2,
}
}
@@ -70,6 +71,17 @@ impl Metrics {
card_height: (card_width / ASPECT).max(0.),
}
}
/// What one row of the list takes: a card and the gap under it.
fn row_height(&self) -> f32 {
self.card_height + self.gap
}
}
/// How tall a row of cards is in a window `window_width` wide: the least height that shows a
/// whole row, for a grid that shares its column with other sections.
pub fn row_height(window_width: Pixels) -> Pixels {
px(Metrics::of(window_width).row_height())
}
/// What makes one card reachable with the keyboard: its handle, and the subscriptions that draw
@@ -80,7 +92,8 @@ struct CardFocus {
}
pub struct CardGrid {
/// All the cards, A to Z; rebuilt only when the statistics change.
/// All the cards in the order the page gives (the chosen sort); replaced when the statistics
/// or the sort change.
cards: Rc<[Card]>,
/// Indices into `cards`, after the filter and the search.
shown: Vec<usize>,
@@ -211,6 +224,19 @@ impl CardGrid {
window.focus(&handle, cx);
}
/// The grid is not shown any more: its portraits are given back, in memory and in the
/// window's atlas, and load again when it is drawn.
pub fn release_images(&mut self, window: &mut Window, cx: &mut Context<Self>) {
let released = self
.images
.as_ref()
.is_some_and(|images| images.update(cx, |images, cx| images.release(window, cx)));
if released {
// A cached view replays its last paint unless it is drawn again.
cx.notify();
}
}
pub fn set_shown(&mut self, shown: Vec<usize>, cx: &mut Context<Self>) {
if self.shown != shown {
self.shown = shown;
@@ -349,6 +375,7 @@ impl Render for CardGrid {
.into_any_element();
}
self.wired(div().relative().size_full(), images, cx)
.debug_selector(|| "card-list".into())
.child(
uniform_list(
"cards",
@@ -387,12 +414,12 @@ mod tests {
for (width, expected) in [
(2560., 6),
(1280., 6),
(1000., 6),
(999., 4),
(720., 4),
(719., 3),
(480., 3),
(479., 2),
(1001., 6),
(1000., 4),
(721., 4),
(720., 3),
(481., 3),
(480., 2),
(300., 2),
] {
assert_eq!(columns(px(width)), expected, "{width} px");