diff --git a/assets/media/styles.css b/assets/media/styles.css index 049ae142..9a3030da 100644 --- a/assets/media/styles.css +++ b/assets/media/styles.css @@ -428,6 +428,15 @@ input:checked + .field__toggle__slider:before { margin-right: .5rem; } +.metadata_field__textarea, .metadata_field__textarea:focus { + outline: none; +} + +.metadata_field__limit { + color: var(--vscode-inputValidation-warningBorder); + margin-top: .25rem; +} + /* File list */ .file_list vscode-label { border-bottom: 1px solid var(--vscode-foreground); diff --git a/src/viewpanel/components/Fields/TextField.tsx b/src/viewpanel/components/Fields/TextField.tsx new file mode 100644 index 00000000..07c1a89b --- /dev/null +++ b/src/viewpanel/components/Fields/TextField.tsx @@ -0,0 +1,52 @@ +import { PencilIcon } from '@heroicons/react/outline'; +import * as React from 'react'; +import { VsLabel } from '../VscodeComponents'; + +export interface ITextFieldProps { + label: string; + value: string | null; + limit: number | undefined; + rows?: number; + onChange: (txtValue: string) => void; +} + +export const TextField: React.FunctionComponent = ({limit, label, value, rows, onChange}: React.PropsWithChildren) => { + const [ text, setText ] = React.useState(value); + + const onTextChange = (txtValue: string) => { + setText(txtValue); + onChange(txtValue); + }; + + React.useEffect(() => { + if (text !== value) { + setText(value); + } + }, [ value ]); + + return ( +
+ +
+ {label} +
+
+ +