Notes en étoiles uniquement : plus d'échelle sur 10
- Réglage « Notation » retiré, ainsi que le curseur sur 10 et l'affichage « /10 » (fiche, cartes, Top 5, stats, filtres, carte de partage) : tout s'affiche sur 5 étoiles - Les notes restent stockées comme avant (sur 10 en interne) : rien ne change pour les notes existantes - Réglage ratingScale retiré des réglages synchronisés et des sauvegardes ; textes inutiles retirés (18 langues) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YVo1qxKoBQCaMd7Ue8PGbe
This commit is contained in:
40 files changed
+61
-214
No files matched your search
@@ -2,16 +2,15 @@ import { t } from '../i18n'
|
||||
import { Star, X } from 'lucide-react'
|
||||
import type { MouseEvent } from 'react'
|
||||
import { cx, formatRating } from '../lib/utils'
|
||||
import type { RatingScale } from '../types'
|
||||
|
||||
/** Petite note compacte (étoile + valeur) pour les cartes. */
|
||||
export function RatingBadge({ value, scale }: { value?: number; scale: RatingScale }) {
|
||||
export function RatingBadge({ value }: { value?: number }) {
|
||||
if (value == null || value === 0) return null
|
||||
return (
|
||||
<span className="inline-flex items-center gap-1 text-xs font-semibold text-ink">
|
||||
<Star size={12} className="fill-accent text-accent" />
|
||||
{formatRating(value, scale)}
|
||||
<span className="font-normal text-ink-3">/{scale}</span>
|
||||
{formatRating(value)}
|
||||
<span className="font-normal text-ink-3">/5</span>
|
||||
</span>
|
||||
)
|
||||
}
|
||||
@@ -20,44 +19,17 @@ interface InputProps {
|
||||
/** Valeur interne sur 10 */
|
||||
value?: number
|
||||
onChange: (value: number | undefined) => void
|
||||
scale: RatingScale
|
||||
size?: 'lg' | 'sm'
|
||||
label?: string
|
||||
}
|
||||
|
||||
/**
|
||||
* Saisie de note.
|
||||
* - Échelle 5 : étoiles avec demi-étoiles (touche la moitié gauche d'une étoile pour ½).
|
||||
* - Échelle 10 : curseur au pas de 0,5.
|
||||
* La valeur est toujours stockée sur 10.
|
||||
* Saisie de note : étoiles avec demi-étoiles (touche la moitié gauche d'une étoile pour ½).
|
||||
* La valeur est stockée sur 10.
|
||||
*/
|
||||
export function RatingInput({ value, onChange, scale, size = 'lg', label }: InputProps) {
|
||||
export function RatingInput({ value, onChange, size = 'lg', label }: InputProps) {
|
||||
const px = size === 'lg' ? 34 : 24
|
||||
|
||||
if (scale === '10') {
|
||||
return (
|
||||
<div className="flex items-center gap-3">
|
||||
<input
|
||||
type="range"
|
||||
min={0}
|
||||
max={10}
|
||||
step={0.5}
|
||||
value={value ?? 0}
|
||||
aria-label={label ?? t('rating.outOf10')}
|
||||
onChange={(e) => {
|
||||
const v = Number(e.target.value)
|
||||
onChange(v === 0 ? undefined : v)
|
||||
}}
|
||||
className="h-2 flex-1 accent-accent-fill"
|
||||
/>
|
||||
<span className={cx('w-14 text-end font-semibold tabular-nums', size === 'lg' ? 'text-xl' : 'text-sm')}>
|
||||
{value ? formatRating(value, '10') : '—'}
|
||||
<span className="text-xs font-normal text-ink-3">/10</span>
|
||||
</span>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
const stars = (value ?? 0) / 2
|
||||
const pick = (e: MouseEvent<HTMLButtonElement>, index: number) => {
|
||||
const rect = e.currentTarget.getBoundingClientRect()
|
||||
@@ -91,7 +63,7 @@ export function RatingInput({ value, onChange, scale, size = 'lg', label }: Inpu
|
||||
)
|
||||
})}
|
||||
<span className={cx('ms-2 tabular-nums text-ink-2', size === 'lg' ? 'text-base' : 'text-xs')}>
|
||||
{value ? formatRating(value, '5') : ''}
|
||||
{value ? formatRating(value) : ''}
|
||||
</span>
|
||||
{value != null && size === 'lg' && (
|
||||
<button type="button" onClick={() => onChange(undefined)} className="ms-auto p-1 text-ink-3" aria-label={t('rating.clear')}>
|
||||
|
||||
Reference in new issue
Block a user