cohost/html/spinny.tsx

66 lines
1.5 KiB
TypeScript
Raw Normal View History

2023-07-12 14:15:53 -04:00
import { render_and_copy } from "./common.tsx";
2023-07-10 00:11:33 -04:00
2023-07-12 14:15:53 -04:00
const Spinny = ({ depth }: { depth: number }) => (
2023-07-10 00:11:33 -04:00
<div class="main">
<Square depth={depth} num_squares={depth} />
</div>
);
function color(depth: number, num_squares: number): string {
return (
[
// roygbv
"#FF6961",
"#FFB347",
"#FFFF99",
"#77DD77",
"#ADD8E6",
"#B19CD9",
//t
"#5DCDFA",
"#F1A5B7",
"white",
"#F1A5B7",
"#5DCDFA",
// p
"#FE218A",
"#FCD800",
"#20B0FE",
// "#FFB6C1",
// "#98E6E6",
// "#FFDAB9",
// "#E6E6FA",
// "#98FF98",
// "#FF7F50",
// "#C8A2C8",
// "#FFA07A",
// "#87CEEB",
// "#FFCCCC",
][num_squares - depth] ?? "none"
);
}
//TODO: MAYBE: try to get a backup pulse animation for preferes-reduced motion
// low priority because it already turns off the animation thankfully
// ${depth % 2 == 0 ? "cw" : "ccw"}
2023-07-12 14:15:53 -04:00
const Square = ({
depth,
num_squares,
}: {
depth: number;
num_squares: number;
}) =>
2023-07-10 00:11:33 -04:00
depth == 0 ? (
<></>
) : (
<div
class={`spin`}
style={`background-color: ${color(depth, num_squares)};`}
>
<Square depth={depth - 1} num_squares={num_squares} />
</div>
);
2023-07-12 14:15:53 -04:00
render_and_copy(<Spinny depth={14} />);