You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
20 lines
578 B
React
20 lines
578 B
React
2 years ago
|
import { useRef } from 'preact/hooks'
|
||
|
import { Icon } from './Icon.jsx'
|
||
|
|
||
|
export const ComboBox = ({ selected, options }) => {
|
||
|
const selectRef = useRef()
|
||
|
|
||
|
return (
|
||
|
<div class="input-combo" onClick={() => selectRef.current?.click()}>
|
||
|
<select ref={selectRef}>
|
||
|
{options.map(({ label, value }) => (
|
||
|
<option value={value} selected={value === selected}>
|
||
|
{label}
|
||
|
</option>
|
||
|
))}
|
||
|
</select>
|
||
|
<Icon name="expand_more" />
|
||
|
</div>
|
||
|
)
|
||
|
}
|