@motor-hero/ui-kit 0.51.1 → 0.52.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@motor-hero/ui-kit",
3
- "version": "0.51.1",
3
+ "version": "0.52.0",
4
4
  "description": "Componentes React reutilizáveis para o ecossistema MotorHero — shadcn/ui + Tailwind CSS v4",
5
5
  "author": "MotorHero",
6
6
  "license": "UNLICENSED",
@@ -19,9 +19,12 @@ export interface RatingProps {
19
19
  "aria-label"?: string
20
20
  }
21
21
 
22
+ const formatNote = (value: number) =>
23
+ value.toLocaleString("pt-BR", { maximumFractionDigits: 1 })
24
+
22
25
  function defaultLabel(value: number) {
23
26
  return value > 0
24
- ? `Avaliação: ${value} de ${MAX_STARS} estrelas`
27
+ ? `Nota ${formatNote(value)} de ${MAX_STARS}`
25
28
  : "Avaliação: sem nota"
26
29
  }
27
30
 
@@ -43,18 +46,32 @@ export function Rating({
43
46
  aria-label={label}
44
47
  className={cn("inline-flex items-center gap-0.5", className)}
45
48
  >
46
- {Array.from({ length: MAX_STARS }, (_, index) => (
47
- <Star
48
- key={index}
49
- aria-hidden
50
- className={cn(
51
- sizeClasses[size],
52
- index < clamped
53
- ? "fill-amber-400 text-amber-400"
54
- : "text-muted-foreground",
55
- )}
56
- />
57
- ))}
49
+ {Array.from({ length: MAX_STARS }, (_, index) => {
50
+ // Média 4,3 pinta 30% da quinta estrela: a fração é a nota, não um arredondamento.
51
+ const fill = Math.min(1, Math.max(0, clamped - index))
52
+ return (
53
+ <span key={index} className="relative inline-flex">
54
+ <Star
55
+ aria-hidden
56
+ className={cn(sizeClasses[size], "text-muted-foreground")}
57
+ />
58
+ {fill > 0 && (
59
+ <span
60
+ className="absolute inset-y-0 left-0 overflow-hidden"
61
+ style={{ width: `${fill * 100}%` }}
62
+ >
63
+ <Star
64
+ aria-hidden
65
+ className={cn(
66
+ sizeClasses[size],
67
+ "max-w-none fill-amber-400 text-amber-400",
68
+ )}
69
+ />
70
+ </span>
71
+ )}
72
+ </span>
73
+ )
74
+ })}
58
75
  </div>
59
76
  )
60
77
  }