diff --git a/src/components/SelectInput.tsx b/src/components/SelectInput.tsx new file mode 100644 index 0000000..3701e9b --- /dev/null +++ b/src/components/SelectInput.tsx @@ -0,0 +1,35 @@ +import * as React from 'react' +export function SelectInput({ + value, + onChange, + options, + ...selectProps +}: Override< + React.DetailedHTMLProps, HTMLSelectElement>, + IO & { + options: Option[] + } +>) { + return ( + + ) +} +export type Option = { + key: string + label: string + value: T +} diff --git a/src/components/settings/FileTreeSettings.tsx b/src/components/settings/FileTreeSettings.tsx index abef626..2a1dc12 100644 --- a/src/components/settings/FileTreeSettings.tsx +++ b/src/components/settings/FileTreeSettings.tsx @@ -3,14 +3,11 @@ import { SimpleToggleField } from 'components/SimpleToggleField' import { useConfigs } from 'containers/ConfigsContext' import * as React from 'react' import { Config } from 'utils/configHelper' +import { Option, SelectInput } from '../SelectInput' import { Field } from './Field' import { SettingsSection } from './SettingsSection' -const options: { - key: Config['icons'] - value: Config['icons'] - label: string -}[] = [ +const options: Option[] = [ { key: 'rich', value: 'rich', @@ -35,21 +32,16 @@ export function FileTreeSettings(props: React.PropsWithChildren) { return ( - + /> = { + value: T + onChange(value: T): void +} + +// do not use with generics +type Override = Omit & Incoming