import { render_and_copy } from "./common.tsx"; const Digit = ({ length_per_s, digits, }: { length_per_s: number; digits: (number | string)[]; }) => (
{...digits.map(d => (
{d}
))}
); // silly const make_digits = ({ up, cycle_up, cycle_down, }: { up: number[]; cycle_up: number; cycle_down: number; }) => [ ...new Array(cycle_up).flatMap(() => up), ...new Array(cycle_down).flatMap((_, i) => i == 0 ? up.toReversed().slice(1) : up.toReversed() ), ]; console.log( make_digits({ up: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], cycle_up: 6, cycle_down: 10, }) ); render_and_copy( (i < 10 ? 10 - i : -(i - 10)) .toString() .replace(/-([0-9])$/, "-0$1") .replace(/^([0-9])$/, "0$1") )} /> : (i < 30 * 60 ? 59 - (i % 60) : i % 60) .toString() .padStart(2, "0") )} /> );