diff --git a/src/dashboardWebView/components/Common/NumberField.tsx b/src/dashboardWebView/components/Common/NumberField.tsx new file mode 100644 index 00000000..f3714237 --- /dev/null +++ b/src/dashboardWebView/components/Common/NumberField.tsx @@ -0,0 +1,68 @@ +import { XCircleIcon } from '@heroicons/react/24/solid'; +import * as React from 'react'; + +export interface INumberFieldProps { + name: string; + value?: string; + placeholder?: string; + description?: string; + icon?: JSX.Element; + disabled?: boolean; + autoFocus?: boolean; + onChange?: (value: string) => void; + onReset?: () => void; +} + +export const NumberField: React.FunctionComponent = ({ + name, + value, + placeholder, + description, + icon, + autoFocus, + disabled, + onChange, + onReset +}: React.PropsWithChildren) => { + return ( + <> +
+ { + icon && ( +
+ {icon} +
+ ) + } + + onChange && onChange(e.target.value)} + disabled={!!disabled} + /> + + {(value && onReset) && ( + + )} +
+ + { + description && ( +

+ {description} +

+ ) + } + + ); +}; diff --git a/src/dashboardWebView/components/SnippetsView/SnippetInputField.tsx b/src/dashboardWebView/components/SnippetsView/SnippetInputField.tsx index d71e0b1f..199154f6 100644 --- a/src/dashboardWebView/components/SnippetsView/SnippetInputField.tsx +++ b/src/dashboardWebView/components/SnippetsView/SnippetInputField.tsx @@ -3,6 +3,7 @@ import { ChevronDownIcon } from '@heroicons/react/24/outline'; import { Choice, SnippetField, SnippetInfoField } from '../../../models'; import { useEffect } from 'react'; import { TextField } from '../Common/TextField'; +import { NumberField } from '../Common/NumberField'; export interface ISnippetInputFieldProps { field: SnippetField; @@ -78,6 +79,17 @@ export const SnippetInputField: React.FunctionComponent ); } + if (field.type === 'number') { + return ( + onValueChange(field, e)} + /> + ); + } + return ( = ( - _: React.PropsWithChildren -) => { +export const Snippets: React.FunctionComponent = () => { const settings = useRecoilValue(SettingsSelector); const viewData = useRecoilValue(ViewDataSelector); const mode = useRecoilValue(ModeAtom);