A stack of cards: hover or press one and the cards beneath fan out about their bottom-left corners, card n turning angle0 × falloff^n (42° × 0.7^n) and starting delay_ms × n (28 ms) later, each on its own spring.
The cards are a 3D element, so the look follows the material: flat, thick with visible edges, or drawn in marks (dots, ASCII). Fanning out and settling, each card leaves a short trail in the field map (El::stirr).
Installation
Components are distributed as source. Copy it and what it depends on into your project, then change it as you need:
cargo run --release --bin amenui -- add card_stack --to ../my-appFiles copied: src/widgets/card_stack.rs, src/gesture.rs, src/mesh.rs, src/widgets/mod.rs
Usage
use amenui::widgets::{card_stack};
fn view() -> El<Msg> {
card_stack("cs1", &Stack::default(), 260.0, 170.0, Msg::Stack)
}API
| Functions | card_stack |
|---|---|
| Props | key, stack (Stack: count, angle0, falloff, delay_ms, spring, look, card), msg. |
| Files | src/widgets/card_stack.rs, src/gesture.rs, src/mesh.rs |
| Depends on | base |
| Response to fronts | loosen (a 3D element is decoration, like a picture, even when it can be turned) |
| Recomposition | none (no text) |
Keyboard and accessibility
| States | closed, fanning (cards springing toward their angles, each after its delay), fanned under card k, held (pressed: stays fanned when the pointer leaves); arrow keys move the fan when focused, Enter or Space holds it. |
|---|---|
| Keys and messages | msg(StackMsg) for hover and presses on a card and for keys; the application calls Stack::update and Stack::step on every tick while Stack::moving(). |
On the web every control is mirrored into the page as an element with its role and name, so screen readers and the browser's own focus see it (DESIGN.md §1.14).
Recipes: A stack of cards that fans