2020-01-06 21:29:44 +04:00
|
|
|
import React from "react";
|
|
|
|
|
|
|
|
export function ButtonSelect<T>({
|
|
|
|
options,
|
|
|
|
value,
|
2020-01-24 12:04:54 +02:00
|
|
|
onChange,
|
2020-01-06 21:29:44 +04:00
|
|
|
}: {
|
|
|
|
options: { value: T; text: string }[];
|
|
|
|
value: T | null;
|
|
|
|
onChange: (value: T) => void;
|
|
|
|
}) {
|
|
|
|
return (
|
|
|
|
<div className="buttonList">
|
|
|
|
{options.map(option => (
|
|
|
|
<button
|
|
|
|
key={option.text}
|
|
|
|
onClick={() => onChange(option.value)}
|
|
|
|
className={value === option.value ? "active" : ""}
|
|
|
|
>
|
|
|
|
{option.text}
|
|
|
|
</button>
|
|
|
|
))}
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|