Commit e4c382c8 authored by tom's avatar tom

update form layout and button styling

parent 70cfab2a
...@@ -119,13 +119,11 @@ const ContractMethodCallable = <T extends SmartContractMethod>({ data, onSubmit, ...@@ -119,13 +119,11 @@ const ContractMethodCallable = <T extends SmartContractMethod>({ data, onSubmit,
<Box> <Box>
<chakra.form <chakra.form
noValidate noValidate
display="flex" display="grid"
columnGap={ 3 } columnGap={ 3 }
flexDir={{ base: 'column', lg: 'row' }} rowGap={{ base: 2, lg: 3 }}
rowGap={ 2 } gridTemplateColumns={{ base: 'minmax(0, 1fr)', lg: 'minmax(min-content, 180px) minmax(0, 1fr)' }}
alignItems={{ base: 'flex-start', lg: 'center' }}
onSubmit={ handleSubmit(onFormSubmit) } onSubmit={ handleSubmit(onFormSubmit) }
flexWrap="wrap"
onChange={ handleFormChange } onChange={ handleFormChange }
> >
{ inputs.map(({ type, name }, index) => { { inputs.map(({ type, name }, index) => {
...@@ -146,13 +144,15 @@ const ContractMethodCallable = <T extends SmartContractMethod>({ data, onSubmit, ...@@ -146,13 +144,15 @@ const ContractMethodCallable = <T extends SmartContractMethod>({ data, onSubmit,
}) } }) }
<Button <Button
isLoading={ isLoading } isLoading={ isLoading }
loadingText={ isWrite ? 'Write' : 'Query' } loadingText={ isWrite ? 'Write' : 'Read' }
variant="outline" variant="outline"
size="sm" size="sm"
flexShrink={ 0 } flexShrink={ 0 }
width="min-content"
px={ 4 }
type="submit" type="submit"
> >
{ isWrite ? 'Write' : 'Query' } { isWrite ? 'Write' : 'Read' }
</Button> </Button>
</chakra.form> </chakra.form>
{ 'outputs' in data && !isWrite && data.outputs.length > 0 && ( { 'outputs' in data && !isWrite && data.outputs.length > 0 && (
......
import { import {
Box,
FormControl, FormControl,
Input, Input,
InputGroup, InputGroup,
...@@ -50,9 +51,8 @@ const ContractMethodField = ({ control, name, valueType, placeholder, setValue, ...@@ -50,9 +51,8 @@ const ContractMethodField = ({ control, name, valueType, placeholder, setValue,
return ( return (
<FormControl <FormControl
id={ name } id={ name }
flexBasis={{ base: '100%', lg: 'calc((100% - 24px) / 3 - 65px)' }} w="100%"
w={{ base: '100%', lg: 'auto' }} mb={{ base: 1, lg: 0 }}
flexGrow={ 1 }
isDisabled={ isDisabled } isDisabled={ isDisabled }
> >
<InputGroup size="xs"> <InputGroup size="xs">
...@@ -61,6 +61,7 @@ const ContractMethodField = ({ control, name, valueType, placeholder, setValue, ...@@ -61,6 +61,7 @@ const ContractMethodField = ({ control, name, valueType, placeholder, setValue,
ref={ ref } ref={ ref }
placeholder={ placeholder } placeholder={ placeholder }
paddingRight={ hasZerosControl ? '120px' : '40px' } paddingRight={ hasZerosControl ? '120px' : '40px' }
autoComplete="off"
/> />
<InputRightElement w="auto" right={ 1 }> <InputRightElement w="auto" right={ 1 }>
{ field.value && <ClearButton onClick={ handleClear } isDisabled={ isDisabled }/> } { field.value && <ClearButton onClick={ handleClear } isDisabled={ isDisabled }/> }
...@@ -72,12 +73,21 @@ const ContractMethodField = ({ control, name, valueType, placeholder, setValue, ...@@ -72,12 +73,21 @@ const ContractMethodField = ({ control, name, valueType, placeholder, setValue,
}, [ name, isDisabled, placeholder, hasZerosControl, handleClear, handleAddZeroesClick ]); }, [ name, isDisabled, placeholder, hasZerosControl, handleClear, handleAddZeroesClick ]);
return ( return (
<Controller <>
name={ name } <Box
control={ control } fontWeight={ 500 }
render={ renderInput } lineHeight="20px"
/> py={{ lg: '6px' }}
fontSize="sm"
>
{ name } ({ valueType })
</Box>
<Controller
name={ name }
control={ control }
render={ renderInput }
/>
</>
); );
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment