cohost/html/hot_people_who_eat_croissants_are_dangerous.tsx

182 lines
5.1 KiB
TypeScript
Raw Normal View History

import { Main } from "./common.tsx";
import { Html, debug_render, render } from "./html.ts";
2023-07-10 14:52:20 -04:00
import { Component } from "./jsx/jsx-runtime.ts";
2023-07-10 14:57:18 -04:00
const peopleify = (...people: string[]): string[] =>
2023-07-11 15:25:40 -04:00
// non-breaking space v
people.map(p => `${p}\u202fpeople`);
2023-07-10 14:57:18 -04:00
2023-07-10 22:37:47 -04:00
const animation_length = (num_items: number): number => /*num_items / 5*/ 3;
2023-07-11 14:19:46 -04:00
const wheel_style = (num_items: number, width?: number): string =>
`transform: translateY(calc(2rem * -${num_items})); animation: ${animation_length(
num_items
2023-07-11 14:19:46 -04:00
)}s ease-in-out reverse none running spin; ${
width ? `width: ${width * 100}%;` : ""
}`;
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;
};
2023-07-11 14:19:46 -04:00
const Wheel: Component = ({ items, width, classes }, _) => (
<details class="wheel">
<summary>
{...items.map((i: string) => <div class="wheel-item">{i}</div>)}
</summary>
2023-07-11 14:19:46 -04:00
<div
class={`wheel-inner ${classes ? classes.join(" ") : ""}`}
style={wheel_style(items.length, width)}
>
{/* <div class="wheel-item empty"></div> */}
2023-07-10 19:52:09 -04:00
{...items.map((item: string, i: number) => (
<div
class={`wheel-item ${i + 1 == items.length ? "last" : ""}`}
>
{item}
</div>
))}
</div>
</details>
2023-07-10 14:52:20 -04:00
);
2023-07-11 12:43:32 -04:00
function slices<T>(arr: T[]): T[][] {
return arr.map((_, i) => arr.slice(0, i));
}
2023-07-11 14:19:46 -04:00
function weird_slices<T>(arr: T[]): T[][] {
return arr.map(item => [...arr.filter(t => t != item), item]);
}
2023-07-11 12:43:32 -04:00
const MultiWheel: Component = ({ items }, _) => (
2023-07-11 15:25:40 -04:00
<span class="multiwheel">
2023-07-11 14:19:46 -04:00
{...weird_slices(items).map(items => (
2023-07-11 15:25:40 -04:00
<Wheel items={items} /*width={1 / items.length}*/ />
2023-07-11 12:43:32 -04:00
))}
2023-07-11 14:19:46 -04:00
<Wheel items={items} classes={["invisible"]} />
2023-07-11 15:25:40 -04:00
</span>
2023-07-11 12:43:32 -04:00
);
// i'll probably just hardcode the delays... lame but w/e
2023-07-10 19:52:09 -04:00
// nope
// it would be possible to have it so the final text is actually properyly selectable maybe but eh
const Take: Component = ({ subjects, objects, adjectives }, _) => (
<div class="take">
2023-07-11 15:25:40 -04:00
<MultiWheel items={subjects} /> <span class="bridge">who eat</span>{" "}
<MultiWheel items={objects} /> <span class="bridge">are</span>{" "}
2023-07-11 12:43:32 -04:00
<MultiWheel items={adjectives} />
</div>
);
2023-07-10 14:52:20 -04:00
2023-07-10 19:52:09 -04:00
const Checkmark: Component = () => (
<img
class="checkmark"
src="https://static.pyrope.net/white-twitter-checkmark.png"
alt="the old, white twitter verified checkmark"
/>
);
const Author: Component = () => (
<div class="author">
<img
class="pfp"
src="https://static.pyrope.net/phoebe_bridgers-pfp.jpg"
alt="a picture of a blonde, white woman wearing a black coat and looking at her phone. presumably phoebe bridgers"
/>
<div class="names">
<div class="display-name">
traitor joe <Checkmark />
</div>
<div class="username">@phoebe_bridgers</div>
</div>
</div>
);
2023-07-10 22:37:47 -04:00
const Info: Component = () => (
<div class="info">
<span class="time">10:02 PM</span> ·{" "}
<span class="date">Feb 20, 2021</span> ·{" "}
<span class="device">Twitter for iPhone</span>
</div>
);
const Stats: Component = () => (
<div class="stats">
<span class="retweets">
<span class="stat">3,228</span> Retweets
</span>
<span class="quote-tweets">
<span class="stat">803</span> Quote Tweets
</span>
<span class="likes">
<span class="stat">39.3K</span> Likes
</span>
</div>
);
2023-07-10 14:52:20 -04:00
// might want to have the final item be seperate
// turned out to be unnecessary
2023-07-10 14:52:20 -04:00
debug_render(
<Main>
2023-07-10 19:52:09 -04:00
<Author />
<Take
subjects={peopleify(
"poor",
"fat",
"dumb",
"tall",
"short",
"poor",
"fat",
"dumb",
"tall",
"hot"
)}
objects={[
"apples",
"bread",
"pasta",
"candy",
"rice",
"beans",
"apples",
"bread",
"candy",
"rice",
"beans",
"apples",
"bread",
"pasta",
"candy",
"rice",
"croissants",
]}
adjectives={[
"vibes",
"mean",
"dumb",
"cool",
"hot",
"stupid",
"funny",
"vibes",
"mean",
"dumb",
"cool",
"hot",
"stupid",
"dangerous",
]}
/>
2023-07-10 22:37:47 -04:00
<Info />
<hr />
<Stats />
<hr />
<div class="bottom"></div>
</Main>
2023-07-10 14:52:20 -04:00
);