Improve form input
This commit is contained in:
parent
4a7f03fba6
commit
f40f0bdf32
1 changed files with 25 additions and 19 deletions
|
@ -22,15 +22,17 @@ export const Properties: React.FC<IPropertiesProps> = (props: IPropertiesProps)
|
||||||
.forEach((pair) => handleProperties(pair, groupInput, isDynamicInput, props.onChange));
|
.forEach((pair) => handleProperties(pair, groupInput, isDynamicInput, props.onChange));
|
||||||
|
|
||||||
const form = isDynamicInput
|
const form = isDynamicInput
|
||||||
? <div>
|
? <div className='grid grid-cols-2 gap-4'>
|
||||||
{ groupInput }
|
{ groupInput }
|
||||||
</div>
|
</div>
|
||||||
: <form
|
: <form
|
||||||
key={props.properties.id}
|
key={props.properties.id}
|
||||||
onSubmit={(event) => props.onSubmit(event, props.properties as ContainerProperties)}
|
onSubmit={(event) => props.onSubmit(event, props.properties as ContainerProperties)}
|
||||||
>
|
>
|
||||||
<input type='submit' className='normal-btn block mx-auto' value='Submit'/>
|
<input type='submit' className='normal-btn block mx-auto mb-4 border-2 border-blue-400 cursor-pointer' value='Submit'/>
|
||||||
{ groupInput }
|
<div className='grid grid-cols-2 gap-y-4'>
|
||||||
|
{ groupInput }
|
||||||
|
</div>
|
||||||
</form>
|
</form>
|
||||||
;
|
;
|
||||||
|
|
||||||
|
@ -67,16 +69,19 @@ const handleProperties = (
|
||||||
type = INPUT_TYPES[key];
|
type = INPUT_TYPES[key];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const className = `
|
||||||
|
w-full
|
||||||
|
text-xs font-medium transition-all text-gray-800 mt-1 px-3 py-2
|
||||||
|
bg-white border-2 border-white rounded-lg placeholder-gray-800
|
||||||
|
focus:outline-none focus:border-blue-500 focus:ring-1 focus:ring-blue-500
|
||||||
|
disabled:bg-slate-300 disabled:text-gray-500 disabled:border-slate-300 disabled:shadow-none`;
|
||||||
const isDisabled = ['id', 'parentId'].includes(key);
|
const isDisabled = ['id', 'parentId'].includes(key);
|
||||||
const input = isDynamicInput
|
const input = isDynamicInput
|
||||||
? <input
|
? <input
|
||||||
className='text-base font-medium transition-all text-gray-800 mt-1 block w-full px-3 py-2
|
key={key}
|
||||||
bg-white border-2 border-white rounded-lg placeholder-gray-800
|
|
||||||
focus:outline-none focus:border-blue-500 focus:ring-1 focus:ring-blue-500
|
|
||||||
disabled:bg-slate-300 disabled:text-gray-500 disabled:border-slate-300 disabled:shadow-none
|
|
||||||
'
|
|
||||||
type={type}
|
|
||||||
id={key}
|
id={key}
|
||||||
|
className={className}
|
||||||
|
type={type}
|
||||||
value={value}
|
value={value}
|
||||||
checked={checked}
|
checked={checked}
|
||||||
onChange={(event) => {
|
onChange={(event) => {
|
||||||
|
@ -89,22 +94,23 @@ const handleProperties = (
|
||||||
disabled={isDisabled}
|
disabled={isDisabled}
|
||||||
/>
|
/>
|
||||||
: <input
|
: <input
|
||||||
className='text-base font-medium transition-all text-gray-800 mt-1 block w-full px-3 py-2
|
key={key}
|
||||||
bg-white border-2 border-white rounded-lg placeholder-gray-800
|
|
||||||
focus:outline-none focus:border-blue-500 focus:ring-1 focus:ring-blue-500
|
|
||||||
disabled:bg-slate-300 disabled:text-gray-500 disabled:border-slate-300 disabled:shadow-none
|
|
||||||
'
|
|
||||||
type={type}
|
|
||||||
id={key}
|
id={key}
|
||||||
|
className={className}
|
||||||
|
type={type}
|
||||||
defaultValue={value}
|
defaultValue={value}
|
||||||
defaultChecked={checked}
|
defaultChecked={checked}
|
||||||
disabled={isDisabled}
|
disabled={isDisabled}
|
||||||
/>;
|
/>;
|
||||||
|
|
||||||
groupInput.push(
|
groupInput.push(
|
||||||
<div key={id} className='mt-4'>
|
<label
|
||||||
<label className='text-sm font-medium text-gray-800' htmlFor={key}>{key}</label>
|
key={id}
|
||||||
{input}
|
className='mt-4 text-xs font-medium text-gray-800'
|
||||||
</div>
|
htmlFor={key}
|
||||||
|
>
|
||||||
|
{key}
|
||||||
|
</label>
|
||||||
);
|
);
|
||||||
|
groupInput.push(input);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue