Switched to more generic wording

This commit is contained in:
patben8 committed 2026-09-17 22:24:56 +02:00
1 parent c9e85bbdb5
commit 6e24f5ef1d
29 files changed
+796 -319

No files matched your search

+13 -10
View File
@@ -2,22 +2,25 @@ import { useState } from 'react'
interface Props {
value: number
/** When provided, the stars become clickable to set the rating (0–5). */
/** Scale length, from capabilities.tracks.rating_max. */
max?: number
/** When provided, the stars become clickable to set the rating. */
onChange?: (value: number) => void
}
// Compact 5-star rating. Read-only by default (shows a dash when unrated). When
// `onChange` is given it's interactive: always shows five stars — hollow (☆) up
// to the rating, solid gold (★) below it — with hover preview. Clicking a star
// sets that rating; clicking the current top star again clears it to 0.
export function RatingStars({ value, onChange }: Props) {
// Compact star rating. Read-only by default (shows a dash when unrated). When
// `onChange` is given it's interactive: hollow (☆) above the rating, solid gold
// (★) up to it, with hover preview. Clicking a star sets that rating; clicking
// the current top star again clears it to 0.
export function RatingStars({ value, max = 5, onChange }: Props) {
const [hover, setHover] = useState(0)
const stars = Array.from({ length: max }, (_, i) => i + 1)
if (!onChange) {
if (!value) return <span className="text-faint">—</span>
return (
<span className="whitespace-nowrap tracking-tight" title={`${value} / 5`}>
{[1, 2, 3, 4, 5].map((i) => (
<span className="whitespace-nowrap tracking-tight" title={`${value} / ${max}`}>
{stars.map((i) => (
<span key={i} className={i <= value ? 'text-gold' : 'text-ink-600'}>
{i <= value ? '★' : '☆'}
</span>
@@ -28,8 +31,8 @@ export function RatingStars({ value, onChange }: Props) {
const shown = hover || value
return (
<span className="whitespace-nowrap tracking-tight" title={`${value} / 5`}>
{[1, 2, 3, 4, 5].map((i) => (
<span className="whitespace-nowrap tracking-tight" title={`${value} / ${max}`}>
{stars.map((i) => (
<button
key={i}
onClick={(e) => {