diff --git a/CHANGELOG.md b/CHANGELOG.md index 52a8f079..559eec76 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ ### 🎨 Enhancements +- [#441](https://github.com/estruyf/vscode-front-matter/issues/441): Show input descriptions for snippet and data forms - [#798](https://github.com/estruyf/vscode-front-matter/issues/798): Changed dialog to slide-over for the snippet forms - [#799](https://github.com/estruyf/vscode-front-matter/issues/799): Added `frontMatter.logging` setting to define the logging output. Options are `info`, `warn`, `error`, and `verbose`. Default is `info`. - [#800](https://github.com/estruyf/vscode-front-matter/issues/800): Add colors for the Front Matter CMS output diff --git a/src/components/uniforms-frontmatter/BoolField.tsx b/src/components/uniforms-frontmatter/BoolField.tsx index 08296e91..4b80dc1d 100644 --- a/src/components/uniforms-frontmatter/BoolField.tsx +++ b/src/components/uniforms-frontmatter/BoolField.tsx @@ -7,7 +7,7 @@ import { LabelField } from './LabelField'; export type BoolFieldProps = HTMLFieldProps< boolean, HTMLDivElement, - { inputRef?: Ref } + { inputRef?: Ref, description?: string } >; function Bool({ @@ -37,6 +37,12 @@ function Bool({ /> + + { + props.description && ( + {props.description} + ) + } ); } diff --git a/src/components/uniforms-frontmatter/DateField.tsx b/src/components/uniforms-frontmatter/DateField.tsx index 512536ec..a6fe36b2 100644 --- a/src/components/uniforms-frontmatter/DateField.tsx +++ b/src/components/uniforms-frontmatter/DateField.tsx @@ -9,7 +9,7 @@ const dateFormat = (value?: Date) => value?.toISOString().slice(0, -8); export type DateFieldProps = HTMLFieldProps< Date, HTMLDivElement, - { inputRef?: Ref; max?: Date; min?: Date } + { inputRef?: Ref; max?: Date; min?: Date, description?: string } >; function Date({ @@ -50,6 +50,12 @@ function Date({ type="datetime-local" value={dateFormat(value) ?? ''} /> + + { + props.description && ( + {props.description} + ) + } ); } diff --git a/src/components/uniforms-frontmatter/LongTextField.tsx b/src/components/uniforms-frontmatter/LongTextField.tsx index e8ee54fc..a36cf44c 100644 --- a/src/components/uniforms-frontmatter/LongTextField.tsx +++ b/src/components/uniforms-frontmatter/LongTextField.tsx @@ -6,7 +6,7 @@ import { LabelField } from './LabelField'; export type LongTextFieldProps = HTMLFieldProps< string, HTMLDivElement, - { inputRef?: Ref } + { inputRef?: Ref, description?: string } >; function LongText({ @@ -36,6 +36,12 @@ function LongText({ ref={inputRef} value={value ?? ''} /> + + { + props.description && ( + {props.description} + ) + } ); } diff --git a/src/components/uniforms-frontmatter/NumField.tsx b/src/components/uniforms-frontmatter/NumField.tsx index e61aaeb4..09026e56 100644 --- a/src/components/uniforms-frontmatter/NumField.tsx +++ b/src/components/uniforms-frontmatter/NumField.tsx @@ -6,7 +6,7 @@ import { LabelField } from './LabelField'; export type NumFieldProps = HTMLFieldProps< number, HTMLDivElement, - { decimal?: boolean; inputRef?: Ref } + { decimal?: boolean; inputRef?: Ref, description?: string } >; function Num({ @@ -47,6 +47,12 @@ function Num({ type="number" value={value ?? ''} /> + + { + props.description && ( + {props.description} + ) + } ); } diff --git a/src/components/uniforms-frontmatter/TextField.tsx b/src/components/uniforms-frontmatter/TextField.tsx index 90e35396..b67a59c3 100644 --- a/src/components/uniforms-frontmatter/TextField.tsx +++ b/src/components/uniforms-frontmatter/TextField.tsx @@ -6,7 +6,7 @@ import { LabelField } from './LabelField'; export type TextFieldProps = HTMLFieldProps< string, HTMLDivElement, - { inputRef?: Ref } + { inputRef?: Ref, description?: string } >; function Text({ @@ -40,6 +40,12 @@ function Text({ type={type} value={value ?? ''} /> + + { + props.description && ( + {props.description} + ) + } ); } diff --git a/src/components/uniforms-frontmatter/UnknownField.tsx b/src/components/uniforms-frontmatter/UnknownField.tsx index 2d12836d..046e6ec4 100644 --- a/src/components/uniforms-frontmatter/UnknownField.tsx +++ b/src/components/uniforms-frontmatter/UnknownField.tsx @@ -8,7 +8,7 @@ import { LocalizationKey } from '../../localization'; export type UnknownFieldProps = HTMLFieldProps< string, HTMLDivElement, - { inputRef?: Ref } + { inputRef?: Ref, description?: string } >; function UnknownField({ @@ -30,6 +30,12 @@ function UnknownField({
{l10n.t(LocalizationKey.fieldUnknown)}
+ + { + props.description && ( + {props.description} + ) + } ); } diff --git a/src/dashboardWebView/components/Common/TextField.tsx b/src/dashboardWebView/components/Common/TextField.tsx index bfaaec9a..8d9a90d7 100644 --- a/src/dashboardWebView/components/Common/TextField.tsx +++ b/src/dashboardWebView/components/Common/TextField.tsx @@ -5,6 +5,7 @@ export interface ITextFieldProps { name: string; value?: string; placeholder?: string; + description?: string; icon?: JSX.Element; disabled?: boolean; autoFocus?: boolean; @@ -18,6 +19,7 @@ export const TextField: React.FunctionComponent = ({ name, value, placeholder, + description, icon, autoFocus, multiline, @@ -27,52 +29,63 @@ export const TextField: React.FunctionComponent = ({ onReset }: React.PropsWithChildren) => { return ( -
- { - icon && ( -
- {icon} -
- ) - } + <> + +
+ { + icon && ( +
+ {icon} +
+ ) + } + + { + multiline ? ( +