"use client";
interface AnalogClockProps {
time: Date;
theme: "light" | "dark" | "blue" | "gradient";
}
/**
* 아날로그 시계 컴포넌트
* - SVG 기반 아날로그 시계
* - 시침, 분침, 초침 애니메이션
* - 테마별 색상 지원
*/
export function AnalogClock({ time, theme }: AnalogClockProps) {
const hours = time.getHours() % 12;
const minutes = time.getMinutes();
const seconds = time.getSeconds();
// 각도 계산 (12시 방향을 0도로, 시계방향으로 회전)
const secondAngle = seconds * 6 - 90; // 6도씩 회전 (360/60)
const minuteAngle = minutes * 6 + seconds * 0.1 - 90; // 6도씩 + 초당 0.1도
const hourAngle = hours * 30 + minutes * 0.5 - 90; // 30도씩 + 분당 0.5도
// 테마별 색상
const colors = getThemeColors(theme);
return (
);
}
/**
* 테마별 색상 반환
*/
function getThemeColors(theme: string) {
const themes = {
light: {
background: "#ffffff",
border: "#d1d5db",
tick: "#9ca3af",
number: "#374151",
hourHand: "#1f2937",
minuteHand: "#4b5563",
secondHand: "#ef4444",
center: "#1f2937",
},
dark: {
background: "#1f2937",
border: "#4b5563",
tick: "#6b7280",
number: "#f9fafb",
hourHand: "#f9fafb",
minuteHand: "#d1d5db",
secondHand: "#ef4444",
center: "#f9fafb",
},
blue: {
background: "#dbeafe",
border: "#3b82f6",
tick: "#60a5fa",
number: "#1e40af",
hourHand: "#1e3a8a",
minuteHand: "#2563eb",
secondHand: "#ef4444",
center: "#1e3a8a",
},
gradient: {
background: "#fce7f3",
border: "#ec4899",
tick: "#f472b6",
number: "#9333ea",
hourHand: "#7c3aed",
minuteHand: "#a855f7",
secondHand: "#ef4444",
center: "#7c3aed",
},
};
return themes[theme as keyof typeof themes] || themes.light;
}