Skip to main content

Crate day_piece_rating

Crate day_piece_rating 

Source
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 over padding / background / corner_radius.
Rating
A star rating bound to a Signal<usize>: .max stars, of which 1..=value are drawn FILLED and the rest OUTLINED. When editable (the default), tapping the i-th star sets the signal to i + 1. It is reactive by construction — each star is a [canvas] whose draw closure reads the signal, so changing value re-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]. Returns over unchanged when count <= 0, so a zero count shows no badge. Pure composition — the pill is a padded, rounded, colored [label].
rating
Build a Rating bound two-way to value (5 gold, editable, 28-pt stars by default).
Day API ↩ Guides· daybrite.dev