import {jsx} from '../src/jsx'; import {render, Component} from './snabb-component'; import './app.css'; interface TimeUnitProps { unit: 'hours' | 'minutes' | 'seconds'; value: number; maxValue?: number; } const ProgressCircle = ({unit, value, maxValue}: TimeUnitProps) => { const radiusForUnit = { seconds: 185, minutes: 150, hours: 115, }; const radius = radiusForUnit[unit]; const circumference = Math.PI * 2 * radius; const progress = 1 - value / maxValue; return ( ); }; const TimeSpans = ({ hours, minutes, seconds, ampm, }: { hours: number; minutes: number; seconds: number; ampm: string; }) => ( <> {String(hours).padStart(2, `0`)} {String(minutes).padStart(2, `0`)} {String(seconds).padStart(2, `0`)} {ampm} ); interface ClockAppState { date?: Date; } class ClockApp extends Component { constructor() { super(); this.update({date: new Date()}); // update date every second setInterval(() => this.update({date: new Date()}), 1000); } render() { // inspired from https://codepen.io/prathameshkoshti/pen/Rwwaqgv const {date} = this.state; const hours = date.getHours() > 12 ? date.getHours() - 12 : date.getHours(); const minutes = date.getMinutes(); const seconds = date.getSeconds(); const ampm = date.getHours() >= 12 ? `PM` : `AM`; return (
); } } render(ClockApp, document.body);