Expand description
day-piece-rating — flagship COMPOSE pieces (DESIGN §8, the composition-first tier).
Everything here is built PURELY from Day’s core primitives ([row], [canvas], the
[Decorate] modifiers, [with_environment], …). There is no per-backend/native code and
no cargo features: these widgets work on every backend for free — the flagship demonstration
that native pieces are the exception, not the rule. Drop the crate in as a plain dependency and
call rating, badge, or the Card modifier from use day::prelude::* code.
Structs§
- Card
- A reusable card surface, applied via [
Decorate::modifier]: pads its content, paints a subtle translucent background, and rounds the corners. Pure composition overpadding/background/corner_radius. - Rating
- A star rating bound to a
Signal<usize>:.maxstars, of which1..=valueare drawn FILLED and the rest OUTLINED. Wheneditable(the default), tapping the i-th star sets the signal toi + 1. It is reactive by construction — each star is a [canvas] whose draw closure reads the signal, so changingvaluere-records exactly the stars whose fill flips.
Functions§
- badge
- Overlay a small numbered blue pill on the TOP-TRAILING corner of
over(a notification badge), via [Decorate::overlay_aligned]. Returnsoverunchanged whencount <= 0, so a zero count shows no badge. Pure composition — the pill is a padded, rounded, colored [label]. - rating
- Build a
Ratingbound two-way tovalue(5 gold, editable, 28-pt stars by default).