Commit c79c669e authored by tom goriunov's avatar tom goriunov Committed by GitHub

Contract verification: Improve the selection of a compiler version (#1257)

Fixes #1164
parent cf62ddb1
...@@ -44,6 +44,18 @@ const variantFloating = defineStyle((props) => { ...@@ -44,6 +44,18 @@ const variantFloating = defineStyle((props) => {
fontSize: 'xs', fontSize: 'xs',
lineHeight: '16px', lineHeight: '16px',
borderTopRightRadius: 'none', borderTopRightRadius: 'none',
'& svg': {
width: '16px',
height: '16px',
},
},
'& svg': {
transitionProperty: 'width, height',
transitionDuration: 'normal',
transitionTimingFunction: 'ease',
width: '24px',
height: '24px',
mr: '2',
}, },
}; };
}); });
......
import { chakra, Checkbox, Code } from '@chakra-ui/react'; import { chakra, Checkbox, Code, Icon } from '@chakra-ui/react';
import { useQueryClient } from '@tanstack/react-query'; import { useQueryClient } from '@tanstack/react-query';
import React from 'react'; import React from 'react';
import type { ControllerRenderProps } from 'react-hook-form'; import type { ControllerRenderProps } from 'react-hook-form';
...@@ -7,6 +7,7 @@ import { useFormContext, Controller } from 'react-hook-form'; ...@@ -7,6 +7,7 @@ import { useFormContext, Controller } from 'react-hook-form';
import type { FormFields } from '../types'; import type { FormFields } from '../types';
import type { SmartContractVerificationConfig } from 'types/api/contract'; import type { SmartContractVerificationConfig } from 'types/api/contract';
import iconSearch from 'icons/search.svg';
import { getResourceKey } from 'lib/api/useApiQuery'; import { getResourceKey } from 'lib/api/useApiQuery';
import useIsMobile from 'lib/hooks/useIsMobile'; import useIsMobile from 'lib/hooks/useIsMobile';
import FancySelect from 'ui/shared/FancySelect/FancySelect'; import FancySelect from 'ui/shared/FancySelect/FancySelect';
...@@ -54,7 +55,8 @@ const ContractVerificationFieldCompiler = ({ isVyper }: Props) => { ...@@ -54,7 +55,8 @@ const ContractVerificationFieldCompiler = ({ isVyper }: Props) => {
loadOptions={ loadOptions } loadOptions={ loadOptions }
defaultOptions defaultOptions
size={ isMobile ? 'md' : 'lg' } size={ isMobile ? 'md' : 'lg' }
placeholder="Compiler" placeholder="Compiler (enter version or use the dropdown)"
placeholderIcon={ <Icon as={ iconSearch }/> }
isDisabled={ formState.isSubmitting } isDisabled={ formState.isSubmitting }
error={ error } error={ error }
isRequired isRequired
......
...@@ -11,6 +11,7 @@ import InputPlaceholder from 'ui/shared/InputPlaceholder'; ...@@ -11,6 +11,7 @@ import InputPlaceholder from 'ui/shared/InputPlaceholder';
interface CommonProps { interface CommonProps {
error?: Merge<FieldError, FieldErrorsImpl<Option>> | undefined; error?: Merge<FieldError, FieldErrorsImpl<Option>> | undefined;
placeholderIcon?: React.ReactNode;
} }
interface RegularSelectProps extends SelectProps<Option, boolean, GroupBase<Option>>, CommonProps { interface RegularSelectProps extends SelectProps<Option, boolean, GroupBase<Option>>, CommonProps {
...@@ -59,6 +60,7 @@ const FancySelect = (props: Props, ref: React.LegacyRef<HTMLDivElement>) => { ...@@ -59,6 +60,7 @@ const FancySelect = (props: Props, ref: React.LegacyRef<HTMLDivElement>) => {
/> />
<InputPlaceholder <InputPlaceholder
text={ typeof props.placeholder === 'string' ? props.placeholder : '' } text={ typeof props.placeholder === 'string' ? props.placeholder : '' }
icon={ props.placeholderIcon }
error={ props.error } error={ props.error }
isFancy isFancy
/> />
......
...@@ -4,13 +4,14 @@ import type { FieldError } from 'react-hook-form'; ...@@ -4,13 +4,14 @@ import type { FieldError } from 'react-hook-form';
interface Props { interface Props {
text: string; text: string;
icon?: React.ReactNode;
error?: Partial<FieldError>; error?: Partial<FieldError>;
className?: string; className?: string;
isFancy?: boolean; isFancy?: boolean;
isInModal?: boolean; isInModal?: boolean;
} }
const InputPlaceholder = ({ text, error, className, isFancy, isInModal }: Props) => { const InputPlaceholder = ({ text, icon, error, className, isFancy, isInModal }: Props) => {
let errorMessage = error?.message; let errorMessage = error?.message;
if (!errorMessage && error?.type === 'pattern') { if (!errorMessage && error?.type === 'pattern') {
...@@ -20,9 +21,11 @@ const InputPlaceholder = ({ text, error, className, isFancy, isInModal }: Props) ...@@ -20,9 +21,11 @@ const InputPlaceholder = ({ text, error, className, isFancy, isInModal }: Props)
return ( return (
<FormLabel <FormLabel
className={ className } className={ className }
alignItems="center"
{ ...(isFancy ? { 'data-fancy': true } : {}) } { ...(isFancy ? { 'data-fancy': true } : {}) }
{ ...(isInModal ? { 'data-in-modal': true } : {}) } { ...(isInModal ? { 'data-in-modal': true } : {}) }
> >
{ icon }
<chakra.span>{ text }</chakra.span> <chakra.span>{ text }</chakra.span>
{ errorMessage && <chakra.span order={ 3 } whiteSpace="pre"> - { errorMessage }</chakra.span> } { errorMessage && <chakra.span order={ 3 } whiteSpace="pre"> - { errorMessage }</chakra.span> }
</FormLabel> </FormLabel>
......
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