Commit 38ad4c79 authored by tom's avatar tom

refactor button theme

parent b9b8ee0d
import { defineStyle, defineStyleConfig } from '@chakra-ui/styled-system'; import { defineStyle, defineStyleConfig } from '@chakra-ui/styled-system';
import { mode } from '@chakra-ui/theme-tools'; import { mode } from '@chakra-ui/theme-tools';
import { runIfFn } from '@chakra-ui/utils';
const variantPrimary = defineStyle({ const variantSolid = defineStyle((props) => {
bg: 'blue.600', const { colorScheme: c } = props;
color: 'white',
fontWeight: 600, if (c === 'gray') {
_hover: { const bg = mode(`gray.100`, `whiteAlpha.200`)(props);
bg: 'blue.400',
return {
bg,
_hover: {
bg: mode(`gray.200`, `whiteAlpha.300`)(props),
_disabled: {
bg,
},
},
_active: { bg: mode(`gray.300`, `whiteAlpha.400`)(props) },
};
}
const bg = `${ c }.600`;
const color = 'white';
const hoverBg = `${ c }.400`;
const activeBg = `${ c }.700`;
return {
bg,
color,
_hover: {
bg: hoverBg,
_disabled: {
bg,
},
},
_disabled: { _disabled: {
bg: 'blue.600', opacity: 0.2,
}, },
}, _active: { bg: activeBg },
_disabled: { fontWeight: 600,
opacity: 0.2, };
},
}); });
const variantSecondary = defineStyle((props) => { const variantOutline = defineStyle((props) => {
const { colorScheme: c } = props;
const isGrayTheme = c === 'gray' || c === 'gray-dark';
const color = isGrayTheme ? mode('blackAlpha.800', 'whiteAlpha.800')(props) : mode(`${ c }.600`, `${ c }.300`)(props);
const borderColor = isGrayTheme ? mode('gray.200', 'gray.600')(props) : mode(`${ c }.600`, `${ c }.300`)(props);
const activeBg = isGrayTheme ? mode('blue.50', 'gray.600')(props) : mode(`${ c }.50`, 'gray.600')(props);
const activeColor = (() => {
if (c === 'gray') {
return mode('blue.400', 'gray.50')(props);
}
if (c === 'gray-dark') {
return mode('blue.700', 'gray.50')(props);
}
return 'blue.400';
})();
return { return {
color: mode('blue.600', 'blue.300')(props), color,
fontWeight: 600, fontWeight: props.fontWeight || 600,
borderColor: mode('blue.600', 'blue.300')(props), borderWidth: props.borderWidth || '2px',
border: '2px solid', borderStyle: 'solid',
borderColor,
bg: 'transparent',
_hover: { _hover: {
color: 'blue.400', color: 'blue.400',
borderColor: 'blue.400', borderColor: 'blue.400',
bg: 'transparent',
_active: {
bg: props.isActive ? activeBg : 'transparent',
borderColor: props.isActive ? activeBg : 'blue.400',
color: props.isActive ? activeColor : 'blue.400',
},
}, },
_disabled: { _disabled: {
opacity: 0.2, opacity: 0.2,
}, },
_active: {
bg: activeBg,
borderColor: activeBg,
color: activeColor,
},
}; };
}); });
const variantIcon = defineStyle((props) => { const variantSimple = defineStyle((props) => {
const outline = runIfFn(variantOutline, props);
return { return {
color: mode('blue.600', 'blue.300')(props), color: outline.color,
_hover: { _hover: {
color: mode('blue.400', 'blue.200')(props), color: outline._hover.color,
}, },
}; };
}); });
const variantIconBorder = defineStyle({
color: 'blue.600',
borderColor: 'blue.600',
border: '2px solid',
_hover: {
color: 'blue.400',
borderColor: 'blue.400',
},
_disabled: {
opacity: 0.2,
},
});
const variants = { const variants = {
primary: variantPrimary, solid: variantSolid,
secondary: variantSecondary, outline: variantOutline,
icon: variantIcon, simple: variantSimple,
iconBorder: variantIconBorder,
}; };
const baseStyle = defineStyle({ const baseStyle = defineStyle({
fontWeight: 'normal', fontWeight: 600,
borderRadius: 'base', borderRadius: 'base',
}); });
...@@ -97,6 +140,11 @@ const Button = defineStyleConfig({ ...@@ -97,6 +140,11 @@ const Button = defineStyleConfig({
baseStyle, baseStyle,
variants, variants,
sizes, sizes,
defaultProps: {
variant: 'solid',
size: 'md',
colorScheme: 'blue',
},
}); });
export default Button; export default Button;
...@@ -142,7 +142,6 @@ const ApiKeyForm: React.FC<Props> = ({ data, onClose, setAlertVisible }) => { ...@@ -142,7 +142,6 @@ const ApiKeyForm: React.FC<Props> = ({ data, onClose, setAlertVisible }) => {
<Box marginTop={ 8 }> <Box marginTop={ 8 }>
<Button <Button
size="lg" size="lg"
variant="primary"
onClick={ handleSubmit(onSubmit) } onClick={ handleSubmit(onSubmit) }
disabled={ !isValid } disabled={ !isValid }
isLoading={ mutation.isLoading } isLoading={ mutation.isLoading }
......
...@@ -40,7 +40,7 @@ const ProfileMenuContent = ({ name, nickname, email }: Props) => { ...@@ -40,7 +40,7 @@ const ProfileMenuContent = ({ name, nickname, email }: Props) => {
</VStack> </VStack>
</Box> </Box>
<Box mt={ 2 } pt={ 3 } borderTopColor={ borderColor } borderTopWidth="1px" { ...getDefaultTransitionProps() }> <Box mt={ 2 } pt={ 3 } borderTopColor={ borderColor } borderTopWidth="1px" { ...getDefaultTransitionProps() }>
<Button size="sm" width="full" variant="secondary">Sign Out</Button> <Button size="sm" width="full" variant="outline">Sign Out</Button>
</Box> </Box>
</Box> </Box>
); );
......
...@@ -168,7 +168,6 @@ const CustomAbiForm: React.FC<Props> = ({ data, onClose, setAlertVisible }) => { ...@@ -168,7 +168,6 @@ const CustomAbiForm: React.FC<Props> = ({ data, onClose, setAlertVisible }) => {
<Box marginTop={ 8 }> <Box marginTop={ 8 }>
<Button <Button
size="lg" size="lg"
variant="primary"
onClick={ handleSubmit(onSubmit) } onClick={ handleSubmit(onSubmit) }
disabled={ !isValid } disabled={ !isValid }
isLoading={ mutation.isLoading } isLoading={ mutation.isLoading }
......
...@@ -106,7 +106,6 @@ const ApiKeysPage: React.FC = () => { ...@@ -106,7 +106,6 @@ const ApiKeysPage: React.FC = () => {
{ Boolean(data.length) && list } { Boolean(data.length) && list }
<Stack marginTop={ 8 } spacing={ 5 } direction={{ base: 'column', lg: 'row' }}> <Stack marginTop={ 8 } spacing={ 5 } direction={{ base: 'column', lg: 'row' }}>
<Button <Button
variant="primary"
size="lg" size="lg"
onClick={ apiKeyModalProps.onOpen } onClick={ apiKeyModalProps.onOpen }
disabled={ !canAdd } disabled={ !canAdd }
......
...@@ -100,7 +100,6 @@ const CustomAbiPage: React.FC = () => { ...@@ -100,7 +100,6 @@ const CustomAbiPage: React.FC = () => {
{ data.length > 0 && list } { data.length > 0 && list }
<HStack marginTop={ 8 } spacing={ 5 }> <HStack marginTop={ 8 } spacing={ 5 }>
<Button <Button
variant="primary"
size="lg" size="lg"
onClick={ customAbiModalProps.onOpen } onClick={ customAbiModalProps.onOpen }
> >
......
...@@ -97,7 +97,6 @@ const WatchList: React.FC = () => { ...@@ -97,7 +97,6 @@ const WatchList: React.FC = () => {
{ Boolean(data?.length) && list } { Boolean(data?.length) && list }
<Box marginTop={ 8 }> <Box marginTop={ 8 }>
<Button <Button
variant="primary"
size="lg" size="lg"
onClick={ addressModalProps.onOpen } onClick={ addressModalProps.onOpen }
> >
......
...@@ -117,7 +117,6 @@ const AddressForm: React.FC<Props> = ({ data, onClose, setAlertVisible }) => { ...@@ -117,7 +117,6 @@ const AddressForm: React.FC<Props> = ({ data, onClose, setAlertVisible }) => {
<Box marginTop={ 8 }> <Box marginTop={ 8 }>
<Button <Button
size="lg" size="lg"
variant="primary"
onClick={ handleSubmit(onSubmit) } onClick={ handleSubmit(onSubmit) }
disabled={ !isValid } disabled={ !isValid }
isLoading={ pending } isLoading={ pending }
......
...@@ -99,7 +99,6 @@ const PrivateAddressTags = () => { ...@@ -99,7 +99,6 @@ const PrivateAddressTags = () => {
{ Boolean(addressTagsData?.length) && list } { Boolean(addressTagsData?.length) && list }
<Box marginTop={ 8 }> <Box marginTop={ 8 }>
<Button <Button
variant="primary"
size="lg" size="lg"
onClick={ addressModalProps.onOpen } onClick={ addressModalProps.onOpen }
> >
......
...@@ -99,7 +99,6 @@ const PrivateTransactionTags = () => { ...@@ -99,7 +99,6 @@ const PrivateTransactionTags = () => {
{ Boolean(transactionTagsData.length) && list } { Boolean(transactionTagsData.length) && list }
<Box marginTop={ 8 }> <Box marginTop={ 8 }>
<Button <Button
variant="primary"
size="lg" size="lg"
onClick={ transactionModalProps.onOpen } onClick={ transactionModalProps.onOpen }
> >
......
...@@ -116,7 +116,6 @@ const TransactionForm: React.FC<Props> = ({ data, onClose, setAlertVisible }) => ...@@ -116,7 +116,6 @@ const TransactionForm: React.FC<Props> = ({ data, onClose, setAlertVisible }) =>
<Box marginTop={ 8 }> <Box marginTop={ 8 }>
<Button <Button
size="lg" size="lg"
variant="primary"
onClick={ handleSubmit(onSubmit) } onClick={ handleSubmit(onSubmit) }
disabled={ !isValid } disabled={ !isValid }
isLoading={ pending } isLoading={ pending }
......
...@@ -95,7 +95,6 @@ const PublicTagsData = ({ changeToFormScreen, onTagDelete }: Props) => { ...@@ -95,7 +95,6 @@ const PublicTagsData = ({ changeToFormScreen, onTagDelete }: Props) => {
{ data.length > 0 && list } { data.length > 0 && list }
<Box marginTop={ 8 }> <Box marginTop={ 8 }>
<Button <Button
variant="primary"
size="lg" size="lg"
onClick={ changeToForm } onClick={ changeToForm }
> >
......
...@@ -55,7 +55,7 @@ export default function PublicTagFormAction({ control, index, fieldsLength, erro ...@@ -55,7 +55,7 @@ export default function PublicTagFormAction({ control, index, fieldsLength, erro
{ fieldsLength > 1 && ( { fieldsLength > 1 && (
<IconButton <IconButton
aria-label="delete" aria-label="delete"
variant="iconBorder" variant="outline"
w="30px" w="30px"
h="30px" h="30px"
onClick={ onRemoveFieldClick(index) } onClick={ onRemoveFieldClick(index) }
...@@ -65,7 +65,7 @@ export default function PublicTagFormAction({ control, index, fieldsLength, erro ...@@ -65,7 +65,7 @@ export default function PublicTagFormAction({ control, index, fieldsLength, erro
{ index === fieldsLength - 1 && fieldsLength < MAX_INPUTS_NUM && ( { index === fieldsLength - 1 && fieldsLength < MAX_INPUTS_NUM && (
<IconButton <IconButton
aria-label="add" aria-label="add"
variant="iconBorder" variant="outline"
w="30px" w="30px"
h="30px" h="30px"
onClick={ onAddFieldClick } onClick={ onAddFieldClick }
......
...@@ -231,7 +231,6 @@ const PublicTagsForm = ({ changeToDataScreen, data }: Props) => { ...@@ -231,7 +231,6 @@ const PublicTagsForm = ({ changeToDataScreen, data }: Props) => {
<HStack spacing={ 6 }> <HStack spacing={ 6 }>
<Button <Button
size="lg" size="lg"
variant="primary"
onClick={ handleSubmit(onSubmit) } onClick={ handleSubmit(onSubmit) }
disabled={ !isValid } disabled={ !isValid }
isLoading={ mutation.isLoading } isLoading={ mutation.isLoading }
...@@ -240,7 +239,7 @@ const PublicTagsForm = ({ changeToDataScreen, data }: Props) => { ...@@ -240,7 +239,7 @@ const PublicTagsForm = ({ changeToDataScreen, data }: Props) => {
</Button> </Button>
<Button <Button
size="lg" size="lg"
variant="secondary" variant="outline"
onClick={ changeToData } onClick={ changeToData }
disabled={ mutation.isLoading } disabled={ mutation.isLoading }
> >
......
...@@ -22,7 +22,7 @@ const CopyToClipboard = ({ text }: {text: string}) => { ...@@ -22,7 +22,7 @@ const CopyToClipboard = ({ text }: {text: string}) => {
icon={ <CopyIcon/> } icon={ <CopyIcon/> }
w="20px" w="20px"
h="20px" h="20px"
variant="icon" variant="simple"
display="inline-block" display="inline-block"
flexShrink={ 0 } flexShrink={ 0 }
onClick={ onCopy } onClick={ onCopy }
......
...@@ -65,7 +65,6 @@ const DeleteModal: React.FC<Props> = ({ ...@@ -65,7 +65,6 @@ const DeleteModal: React.FC<Props> = ({
</ModalBody> </ModalBody>
<ModalFooter> <ModalFooter>
<Button <Button
variant="primary"
size="lg" size="lg"
onClick={ onDeleteClick } onClick={ onDeleteClick }
isLoading={ mutation.isLoading } isLoading={ mutation.isLoading }
......
...@@ -18,7 +18,7 @@ const TableItemActionButtons = ({ onEditClick, onDeleteClick }: Props) => { ...@@ -18,7 +18,7 @@ const TableItemActionButtons = ({ onEditClick, onDeleteClick }: Props) => {
<Tooltip label="Edit"> <Tooltip label="Edit">
<IconButton <IconButton
aria-label="edit" aria-label="edit"
variant="icon" variant="simple"
w="30px" w="30px"
h="30px" h="30px"
onClick={ onEditClick } onClick={ onEditClick }
...@@ -29,7 +29,7 @@ const TableItemActionButtons = ({ onEditClick, onDeleteClick }: Props) => { ...@@ -29,7 +29,7 @@ const TableItemActionButtons = ({ onEditClick, onDeleteClick }: Props) => {
<Tooltip label="Delete"> <Tooltip label="Delete">
<IconButton <IconButton
aria-label="delete" aria-label="delete"
variant="icon" variant="simple"
w="30px" w="30px"
h="30px" h="30px"
onClick={ onDeleteClick } onClick={ onDeleteClick }
......
...@@ -187,7 +187,6 @@ const AddressForm: React.FC<Props> = ({ data, onClose, setAlertVisible }) => { ...@@ -187,7 +187,6 @@ const AddressForm: React.FC<Props> = ({ data, onClose, setAlertVisible }) => {
<Box marginTop={ 8 }> <Box marginTop={ 8 }>
<Button <Button
size="lg" size="lg"
variant="primary"
onClick={ handleSubmit(onSubmit) } onClick={ handleSubmit(onSubmit) }
isLoading={ pending } isLoading={ pending }
disabled={ !isValid } disabled={ !isValid }
......
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