import preact from "preact"; import { observer } from "./observer"; import { css } from "typesafecss"; @observer export class ButtonSelector extends preact.Component<{ title?: string; value: T; options: { value: T; title: preact.ComponentChild; isDefault?: boolean; hotkeys?: string[] }[]; onChange: (value: T) => void; noPadding?: boolean; noDefault?: boolean; noUI?: boolean; classWrapper?: string; }> { render() { const { options, onChange, title } = this.props; const selectedValue = this.props.value; let selectedOption = ( options.find(o => o.value === selectedValue) || (!this.props.noDefault ? (options.find(o => o.isDefault) || options[0]) : undefined) )?.value; return (
{title &&
{title}
} {options.map(({ value, title, hotkeys }) => )}
); } }