Files
CT/src/View/Components/colorPicker.tsx
T

31 lines
923 B
TypeScript
Raw Normal View History

import * as React from "bloatless-react";
2026-04-08 14:02:12 +00:00
import { Colors } from "../../colors";
2026-04-08 14:02:12 +00:00
export function ColorPicker(selectedColor: React.State<Colors>) {
2026-04-01 08:29:39 +00:00
return (
<div class="flex-row gap width-input">
2026-04-08 14:02:12 +00:00
{...Object.values(Colors).map((color) => {
2026-04-01 08:29:39 +00:00
const isSelected = React.createProxyState(
[selectedColor],
() => selectedColor.value == color,
);
2026-04-01 08:29:39 +00:00
function setColor() {
selectedColor.value = color;
}
2026-04-01 08:29:39 +00:00
return (
<button
color={color}
class="fill-color width-100 flex"
style="height: 2rem"
toggle:selected={isSelected}
on:click={setColor}
></button>
);
})}
</div>
);
}