import type { FlatTemplatable } from "tempstream"; import { tempstream, TempstreamJSX } from "tempstream"; import type { Stringifiable } from "tempstream/@types/stringify.js"; const make_id = (function* () { let i = 0; while (true) { yield i++; if (i == 999999999) { i = 0; } } })(); export async function horizontalScroller({ classes = [], elements, render = async ({ scroller, markers }) => tempstream`${scroller}${markers}`, }: { classes?: string[]; elements: (Stringifiable | Promise)[]; render?: (options: { scroller: FlatTemplatable; markers: FlatTemplatable; }) => Promise; }) { const id = make_id.next().value; const scroller_id = `horizontal-scroller-${id}`; const scroller = (
{elements.map((e, index) => (
{e}
))}
); const markers = (
{elements.map(() => (
))}
); return (
{render({ scroller, markers })}
); }