Better Header validation

This commit is contained in:
Gregory Schier
2023-03-20 01:38:05 -07:00
parent ea9f8d3ab2
commit 80dd1e457b
3 changed files with 30 additions and 6 deletions

View File

@@ -1,11 +1,11 @@
import classnames from 'classnames';
import { useMemo, useState } from 'react';
import type { HTMLAttributes, ReactNode } from 'react';
import { useMemo, useState } from 'react';
import type { EditorProps } from './Editor';
import { Editor } from './Editor';
import { HStack, VStack } from './Stacks';
type Props = Omit<HTMLAttributes<HTMLInputElement>, 'onChange' | 'onFocus'> &
export type InputProps = Omit<HTMLAttributes<HTMLInputElement>, 'onChange' | 'onFocus'> &
Pick<EditorProps, 'contentType' | 'useTemplating' | 'autocomplete'> & {
name: string;
label: string;
@@ -41,7 +41,7 @@ export function Input({
validate,
require,
...props
}: Props) {
}: InputProps) {
const [currentValue, setCurrentValue] = useState(defaultValue ?? '');
const id = `input-${name}`;
const inputClassName = classnames(
@@ -80,7 +80,7 @@ export function Input({
containerClassName,
'relative w-full rounded-md text-gray-900',
'border border-gray-200 focus-within:border-focus',
!isValid && 'border-invalid',
!isValid && '!border-invalid',
size === 'md' && 'h-md',
size === 'sm' && 'h-sm',
)}