From d51763dfc3c21a6d3550fe851fc9140f05f7d994 Mon Sep 17 00:00:00 2001 From: mehbark Date: Mon, 10 Jul 2023 15:57:51 -0400 Subject: [PATCH] sort of working, going to make it interactive --- ...eople_who_eat_croissants_are_dangerous.tsx | 47 +++++++++++++++---- 1 file changed, 39 insertions(+), 8 deletions(-) diff --git a/html/hot_people_who_eat_croissants_are_dangerous.tsx b/html/hot_people_who_eat_croissants_are_dangerous.tsx index 633b818..5990229 100644 --- a/html/hot_people_who_eat_croissants_are_dangerous.tsx +++ b/html/hot_people_who_eat_croissants_are_dangerous.tsx @@ -4,20 +4,51 @@ import { Component } from "./jsx/jsx-runtime.ts"; const peopleify = (...people: string[]): string[] => people.map(p => `${p} people`); -const wheel = (...items: Html[]): Html => ( +const animation_length = (num_items: number): number => num_items / 5; + +const wheel_style = (num_items: number, delay_seconds = 0): string => + `transform: translateY(calc(2rem * -${num_items})); animation: ${animation_length( + num_items + )}s 0s ease-in-out reverse none running spin; animation-delay: ${delay_seconds}s;`; + +const get_delays = (...lengths: number[]): number[] => { + let out = [0]; + for (const l of lengths) { + out.push((out.at(-1) ?? 0) + animation_length(l)); + } + return out; +}; +const Wheel: Component = ({ delay_seconds }, children) => (
- {...items.map(i =>
{i}
)} +
+
+ {...children.map(i =>
{i}
)} +
); -const Take: Component = ({ subjects, objects, adjectives }, _) => ( -
- {wheel(...subjects)} who eat {wheel(...objects)} are{" "} - {wheel(...adjectives)} -
-); +// i'll probably just hardcode the delays... lame but w/e +const Take: Component = ({ subjects, objects, adjectives }, _) => { + const [d1, d2, d3] = get_delays( + subjects.length, + objects.length, + adjectives.length + ); + console.log(get_delays(subjects.length, objects.length, adjectives.length)); + return ( +
+ {...subjects} who eat{" "} + {...objects} are{" "} + {...adjectives} +
+ ); +}; // might want to have the final item be seperate +// turned out to be unnecessary debug_render(