A star rating: read-only, with a fractional value and the count of reviews, or interactive, as
a group of native radios; and rating_distribution/1, the summary with the average and a bar
per grade.
<.rating value={4.5} />
<.rating value={4.2} show_value count={38} />
<.rating id="service" name="service" label="Como foi o atendimento?" value={@grade} on_change="rate" />
<.rating field={@form[:grade]} label="Nota" />
<.rating_distribution average={4.5} counts={[800, 310, 110, 40, 24]} />A fractional value is drawn in half stars (the nearest half). The read-only rating is one
role="img" with the text 4,5 de 5 estrelas (aria_label gives another).
Interactive ratings are a radiogroup of max native radios (Tab enters the group, the arrow
keys choose, the form submits name). on_change is an event name (pushed with
%{"id", "value"}, to target when given) or a %JS{}. The LedgerUI.Rating hook
(priv/static/ledger_ui/hooks/rating.js) previews the grade under the pointer.
Summary
Functions
Renders a rating.
The summary of a rating: the average, its stars, the total and a bar per grade.
Functions
Renders a rating.
Attributes
id(:string) - Defaults tonil.name(:string) - Defaults tonil.value(:any)field(Phoenix.HTML.FormField) - Defaults tonil.max(:integer) - Defaults to5.variant(:string) - Defaults to"solid". Must be one of"solid", or"outline".size(:string) - Defaults to"md". Must be one of"sm","md", or"lg".count(:integer) - Defaults tonil.show_value(:boolean) - Defaults tofalse.decimal(:string) - Defaults to",".interactive(:boolean) - Defaults tonil.label(:string) - Defaults tonil.aria_label(:string) - Defaults tonil.help(:string) - Defaults tonil.errors(:list) - Defaults to[].disabled(:boolean) - Defaults tofalse.loop(:boolean) - Animated demo: addsm-loopand a staggered--dldelay per star (read-only, no on/off state). Defaults tofalse.on_change(:any) - Defaults tonil.target(:any) - Defaults tonil.class(:any) - Defaults tonil.- Global attributes are accepted.
The summary of a rating: the average, its stars, the total and a bar per grade.
Attributes
counts(:any) (required) - A list, best grade first, or a map%{grade => count}.average(:any) - Defaults tonil.total(:integer) - Defaults tonil.unit(:string) - Defaults to"avaliações".decimal(:string) - Defaults to",".class(:any) - Defaults tonil.- Global attributes are accepted.