22 lines
462 B
TypeScript
22 lines
462 B
TypeScript
import * as React from "bloatless-react";
|
|||
|
|
|
||
|
|
export function OptionButton<T>(
|
||
|
|
text: string,
|
||
|
|
value: T,
|
||
|
|
selection: React.State<T>,
|
||
|
|
) {
|
||
|
|
function select() {
|
||
|
|
selection.value = value;
|
||
|
|
}
|
||
|
|
const isSelected = React.createProxyState(
|
||
|
|
[selection],
|
||
|
|
() => selection.value == value,
|
||
|
|
);
|
||
|
|
|
||
|
|
return (
|
||
|
|
<button class="standard" toggle:selected={isSelected} on:click={select}>
|
||
|
|
{text}
|
||
|
|
</button>
|
||
|
|
);
|
||
|
|
}
|