Mixins / foldkit-mixins-ui
RatingSlots
const · packages/mixins-ui/src/rating.ts:36
const RatingSlots: Slots.Contract<{
readonly root: Slot.UnnamedSlot<
Capability.Capability<
'Container',
readonly [
Capability.Capability<
'Interactive',
readonly [Capability.Capability<'Base', readonly []>]
>,
]
>,
readonly Slot.EventName[],
readonly [
Attr.AttrToken<'role'>,
Attr.AttrToken<'aria-label'>,
Attr.AttrToken<'aria-labelledby'>,
],
readonly Slot.RequirementName[],
boolean
>
readonly label: Slot.UnnamedSlot<
Capability.Capability<
'Container',
readonly [
Capability.Capability<
'Interactive',
readonly [Capability.Capability<'Base', readonly []>]
>,
]
>,
readonly Slot.EventName[],
readonly Slot.AttributeName[],
readonly Slot.RequirementName[],
boolean
>
readonly star: Slot.UnnamedSlot<
Capability.Capability<
'Interactive',
readonly [Capability.Capability<'Base', readonly []>]
>,
readonly [Event.EventToken<'change'>, Event.EventToken<'keydown'>],
readonly [
Attr.AttrToken<'aria-label'>,
Attr.AttrToken<'disabled'>,
Attr.AttrToken<'value'>,
],
readonly Slot.RequirementName[],
boolean
>
readonly value: Slot.UnnamedSlot<
Capability.Capability<
'Container',
readonly [
Capability.Capability<
'Interactive',
readonly [Capability.Capability<'Base', readonly []>]
>,
]
>,
readonly Slot.EventName[],
readonly Slot.AttributeName[],
readonly Slot.RequirementName[],
boolean
>
}>A star rating, the APG's radio group of native radios: a root with
role="radiogroup" named by its label, and a star per value, an
input type="radio" sharing one name, so the browser moves the focus and
the choice with the arrows and a form submits the value; Home and End,
which a native group lacks, go to the ends through a key route on each star. The
rating is the application's: the view draws value (none before anyone
rates) and sends onChange with the star chosen, and onClear when the
star already chosen is pressed again. With precision: 0.5 each star is
two radios, its halves. Each star carries data-filled; the recipe draws
the glyph in CSS.
Read-only, the root is one image whose name says the rating, the stars
are plain marks, and a fractional value (4.3) fills the last star as far
as it goes: each mark's share is --fk-rating-fill, 0 to 1.