From ae436e1a0e89cd3bb360a29c9d734ca67fc31d7a Mon Sep 17 00:00:00 2001 From: Elio Struyf Date: Fri, 19 Jan 2024 13:26:42 +0100 Subject: [PATCH] Reuse text field component --- .../components/Common/TextField.tsx | 78 +++++++++++++++++++ .../components/Header/FilterInput.tsx | 38 +++------ .../components/Header/Searchbox.tsx | 40 ++++------ .../components/Media/DetailsInput.tsx | 27 +++---- .../components/Media/DetailsSlideOver.tsx | 8 +- .../components/SnippetsView/NewForm.tsx | 6 +- .../components/SnippetsView/SnippetInput.tsx | 27 ++----- .../SnippetsView/SnippetInputField.tsx | 30 +++---- .../components/TaxonomyView/FilterInput.tsx | 29 +++---- 9 files changed, 145 insertions(+), 138 deletions(-) create mode 100644 src/dashboardWebView/components/Common/TextField.tsx diff --git a/src/dashboardWebView/components/Common/TextField.tsx b/src/dashboardWebView/components/Common/TextField.tsx new file mode 100644 index 00000000..bfaaec9a --- /dev/null +++ b/src/dashboardWebView/components/Common/TextField.tsx @@ -0,0 +1,78 @@ +import { XCircleIcon } from '@heroicons/react/24/solid'; +import * as React from 'react'; + +export interface ITextFieldProps { + name: string; + value?: string; + placeholder?: string; + icon?: JSX.Element; + disabled?: boolean; + autoFocus?: boolean; + multiline?: boolean; + rows?: number; + onChange?: (value: string) => void; + onReset?: () => void; +} + +export const TextField: React.FunctionComponent = ({ + name, + value, + placeholder, + icon, + autoFocus, + multiline, + rows, + disabled, + onChange, + onReset +}: React.PropsWithChildren) => { + return ( +
+ { + icon && ( +
+ {icon} +
+ ) + } + + { + multiline ? ( +