Commit 411af874 authored by Max Alekseenko's avatar Max Alekseenko

remove input custom styles

parent 728463b1
...@@ -4,8 +4,8 @@ import React, { useEffect } from 'react'; ...@@ -4,8 +4,8 @@ import React, { useEffect } from 'react';
import { useRewardsContext } from 'lib/contexts/rewards'; import { useRewardsContext } from 'lib/contexts/rewards';
import { apos } from 'lib/html-entities'; import { apos } from 'lib/html-entities';
import CopyField from 'ui/rewards/CopyField';
import DailyRewardClaimButton from 'ui/rewards/DailyRewardClaimButton'; import DailyRewardClaimButton from 'ui/rewards/DailyRewardClaimButton';
import ReadOnlyInputWithCopy from 'ui/rewards/ReadOnlyInputWithCopy';
import RewardsDashboardCard from 'ui/rewards/RewardsDashboardCard'; import RewardsDashboardCard from 'ui/rewards/RewardsDashboardCard';
import RewardsDashboardCardValue from 'ui/rewards/RewardsDashboardCardValue'; import RewardsDashboardCardValue from 'ui/rewards/RewardsDashboardCardValue';
import LinkExternal from 'ui/shared/links/LinkExternal'; import LinkExternal from 'ui/shared/links/LinkExternal';
...@@ -104,13 +104,13 @@ const RewardsDashboard = () => { ...@@ -104,13 +104,13 @@ const RewardsDashboard = () => {
py={{ base: 4, md: 0 }} py={{ base: 4, md: 0 }}
flexDirection={{ base: 'column', md: 'row' }} flexDirection={{ base: 'column', md: 'row' }}
> >
<CopyField <ReadOnlyInputWithCopy
label="Referral link" label="Referral link"
value={ `https://eth.blockscout.com?ref=${ referralsQuery.data?.code }` } value={ `https://eth.blockscout.com?ref=${ referralsQuery.data?.code }` }
isLoading={ referralsQuery.isPending } isLoading={ referralsQuery.isPending }
flex={ 2 } flex={ 2 }
/> />
<CopyField <ReadOnlyInputWithCopy
label="Referral code" label="Referral code"
value={ referralsQuery.data?.code || '' } value={ referralsQuery.data?.code || '' }
isLoading={ referralsQuery.isPending } isLoading={ referralsQuery.isPending }
......
import { FormControl, Input, InputGroup, InputRightElement, Skeleton, chakra, useColorModeValue } from '@chakra-ui/react';
import React from 'react';
import CopyToClipboard from 'ui/shared/CopyToClipboard';
import InputPlaceholder from 'ui/shared/InputPlaceholder';
type Props = {
label: string;
value: string;
className?: string;
isLoading?: boolean;
};
const CopyField = ({ label, value, className, isLoading }: Props) => {
const bgColor = ` ${ useColorModeValue('gray.200', 'blackAlpha.900') } !important`;
return (
<FormControl variant="floating" id={ label } className={ className }>
<Skeleton isLoaded={ !isLoading }>
<InputGroup>
<Input
readOnly
fontWeight="500"
value={ value }
overflow="hidden"
textOverflow="ellipsis"
pr="40px !important"
bgColor={ bgColor }
borderColor={ bgColor }
borderRadius="12px !important"
/>
<InputPlaceholder text={ label } bgColor={ bgColor }/>
<InputRightElement w="40px" display="flex" justifyContent="flex-end" pr={ 2 }>
<CopyToClipboard text={ value }/>
</InputRightElement>
</InputGroup>
</Skeleton>
</FormControl>
);
};
export default chakra(CopyField);
import { FormControl, Input, InputGroup, InputRightElement, Skeleton, chakra } from '@chakra-ui/react';
import React from 'react';
import CopyToClipboard from 'ui/shared/CopyToClipboard';
import InputPlaceholder from 'ui/shared/InputPlaceholder';
type Props = {
label: string;
value: string;
className?: string;
isLoading?: boolean;
};
const ReadOnlyInputWithCopy = ({ label, value, className, isLoading }: Props) => (
<FormControl variant="floating" id={ label } className={ className }>
<Skeleton isLoaded={ !isLoading }>
<InputGroup>
<Input
readOnly
fontWeight="500"
value={ value }
overflow="hidden"
textOverflow="ellipsis"
sx={{
'&:not(:placeholder-shown)': {
pr: '40px',
},
}}
/>
<InputPlaceholder text={ label }/>
<InputRightElement w="40px" display="flex" justifyContent="flex-end" pr={ 2 }>
<CopyToClipboard text={ value }/>
</InputRightElement>
</InputGroup>
</Skeleton>
</FormControl>
);
export default chakra(ReadOnlyInputWithCopy);
...@@ -10,7 +10,7 @@ import meritsIcon from 'icons/merits_colored.svg'; ...@@ -10,7 +10,7 @@ import meritsIcon from 'icons/merits_colored.svg';
import { useRewardsContext } from 'lib/contexts/rewards'; import { useRewardsContext } from 'lib/contexts/rewards';
import IconSvg from 'ui/shared/IconSvg'; import IconSvg from 'ui/shared/IconSvg';
import CopyField from '../CopyField'; import ReadOnlyInputWithCopy from '../ReadOnlyInputWithCopy';
type Props = { type Props = {
isReferral: boolean; isReferral: boolean;
...@@ -84,7 +84,7 @@ const CongratsStepContent = ({ isReferral }: Props) => { ...@@ -84,7 +84,7 @@ const CongratsStepContent = ({ isReferral }: Props) => {
</Skeleton> </Skeleton>
{ ' ' }bonus on all merits earned by your referrals { ' ' }bonus on all merits earned by your referrals
</Text> </Text>
<CopyField <ReadOnlyInputWithCopy
label="Referral link" label="Referral link"
value={ refLink } value={ refLink }
isLoading={ referralsQuery.isLoading } isLoading={ referralsQuery.isLoading }
......
...@@ -107,7 +107,6 @@ const LoginStepContent = ({ goNext, closeModal }: Props) => { ...@@ -107,7 +107,6 @@ const LoginStepContent = ({ goNext, closeModal }: Props) => {
<FormControl variant="floating" id="referral-code" mt={ 3 }> <FormControl variant="floating" id="referral-code" mt={ 3 }>
<Input <Input
fontWeight="500" fontWeight="500"
borderRadius="12px !important"
value={ refCode } value={ refCode }
onChange={ handleRefCodeChange } onChange={ handleRefCodeChange }
isInvalid={ refCodeError } isInvalid={ refCodeError }
......
...@@ -7,10 +7,9 @@ interface Props { ...@@ -7,10 +7,9 @@ interface Props {
icon?: React.ReactNode; icon?: React.ReactNode;
error?: Partial<FieldError>; error?: Partial<FieldError>;
isFancy?: boolean; isFancy?: boolean;
className?: string;
} }
const InputPlaceholder = ({ text, icon, error, isFancy, className }: Props) => { const InputPlaceholder = ({ text, icon, error, isFancy }: Props) => {
let errorMessage = error?.message; let errorMessage = error?.message;
if (!errorMessage && error?.type === 'pattern') { if (!errorMessage && error?.type === 'pattern') {
...@@ -23,7 +22,6 @@ const InputPlaceholder = ({ text, icon, error, isFancy, className }: Props) => { ...@@ -23,7 +22,6 @@ const InputPlaceholder = ({ text, icon, error, isFancy, className }: Props) => {
{ ...(isFancy ? { 'data-fancy': true } : {}) } { ...(isFancy ? { 'data-fancy': true } : {}) }
variant="floating" variant="floating"
bgColor="deeppink" bgColor="deeppink"
className={ className }
> >
{ icon } { icon }
<chakra.span>{ text }</chakra.span> <chakra.span>{ text }</chakra.span>
...@@ -32,4 +30,4 @@ const InputPlaceholder = ({ text, icon, error, isFancy, className }: Props) => { ...@@ -32,4 +30,4 @@ const InputPlaceholder = ({ text, icon, error, isFancy, className }: Props) => {
); );
}; };
export default React.memo(chakra(InputPlaceholder)); export default React.memo(InputPlaceholder);
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