Files
tavolo/web/src/components/card.rs
T
woggioni abc55479e4
CI / Build and push docker image (push) Successful in 1m10s
Rename the playing-card CSS class away from Bootstrap's .card-img
Bootstrap 5.3 ships .card-img{width:100%} for images inside cards, which
collided with the similarly named class emitted by the card helpers:
every card image stretched to its container width, so the table cards
wrapped one per flex line and pushed the player's hand below the
viewport. Emit 'playing-card' instead and rename the six selectors in
style.css; callers keep passing only the size modifiers.
2026-09-22 08:36:14 +08:00

22 lines
717 B
Rust

//! Card rendering helpers (plain functions returning views).
use sycamore::prelude::*;
use crate::model::{card_asset, card_label, CARD_BACK};
/// Render a card image at a given size class (`mini`, `move-card`,
/// `hand-card`, `table-card`).
pub fn card_img(code: String, class: &'static str) -> View {
let src = card_asset(&code);
let alt = card_label(&code);
view! {
img(src=src, class=format!("playing-card {class}"), alt=alt, draggable="false")
}
}
/// Render the back of a card (used for opponents' hidden hands).
pub fn card_back(class: &'static str) -> View {
view! {
img(src=CARD_BACK, class=format!("playing-card {class}"), alt="card back", draggable="false")
}
}