[feat] number-ball (#1)

This commit was merged in pull request #1.
This commit is contained in:
He
2026-06-15 19:33:30 +08:00
committed by GitHub
parent 02c5694189
commit 135ffa1df4
4 changed files with 26 additions and 15 deletions
+9 -4
View File
@@ -8,19 +8,23 @@ interface NumberBallProps {
state: "idle" | "highlighted" | "used"
colorIndex?: number
size?: "normal" | "large"
dimmed?: boolean
}
export function NumberBall({ number, state, colorIndex, size = "normal" }: NumberBallProps) {
export function NumberBall({ number, state, colorIndex, size = "normal", dimmed = false }: NumberBallProps) {
const isHighlighted = state === "highlighted"
const borderColor = isHighlighted && colorIndex !== undefined
const hasColor = colorIndex !== undefined
const borderColor = hasColor
? COLORS[colorIndex]
: state === "idle" ? "#e2e6ea"
: "#eef0f2"
const bgColor = isHighlighted && colorIndex !== undefined
const bgColor = isHighlighted && hasColor
? COLORS[colorIndex]
: "transparent"
const textColor = isHighlighted && colorIndex !== undefined
const textColor = isHighlighted && hasColor
? "#ffffff"
: hasColor ? COLORS[colorIndex]
: state === "idle" ? "#8a95a1"
: "#cdd2d8"
@@ -30,6 +34,7 @@ export function NumberBall({ number, state, colorIndex, size = "normal" }: Numbe
"flex items-center justify-center font-mono select-none transition-all duration-150",
size === "normal" && "w-8 h-8 text-sm",
size === "large" && "w-14 h-14 text-lg",
dimmed && !isHighlighted && "opacity-30",
)}
style={{
border: `1px solid ${borderColor}`,