import { useState } from 'react'; import { RollDigit } from './RollDigit'; import './RollClock.css'; interface DateInfo { dateString: string; weekday: string; } interface RollClockProps { time: string; // "HH:MM:SS" format size: number; dateInfo: DateInfo; period?: string; is24Hour: boolean; onToggleFormat: () => void; } export function RollClock({ time, size, dateInfo, period, is24Hour, onToggleFormat }: RollClockProps) { // Roll direction: 'down' = roll down, 'up' = roll up const [direction, setDirection] = useState<'down' | 'up'>('down'); // Parse time - it's already in 12h format when period is provided const [hoursStr, minutes, seconds] = time.split(':'); const displayHours = hoursStr; const buttonSize = size * 0.25; const periodSize = size * 0.20; const dateSize = size * 0.20; // Toggle direction const toggleDirection = () => { setDirection((prev) => (prev === 'down' ? 'up' : 'down')); }; return (
{period && ( {period} )}
{dateInfo.dateString} {dateInfo.weekday}
{/* Hours */}
: {/* Minutes */}
: {/* Seconds */}
{/* Direction toggle button */}
); }