Skip to content

Commit

Permalink
feat: style wallet button with props
Browse files Browse the repository at this point in the history
  • Loading branch information
Agilulfo1820 committed Jan 21, 2025
1 parent 6e92f40 commit f55377b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Button, HStack, Image, useMediaQuery } from '@chakra-ui/react';
import { useWallet } from '@/hooks';
import { WalletDisplay } from './WalletDisplay';
import { WalletButtonProps } from './types';
import { notFoundImage } from '@/utils';
import { WalletButtonProps } from './WalletButton';

type ConnectedWalletProps = WalletButtonProps & {
onOpen: () => void;
Expand All @@ -12,12 +12,13 @@ export const ConnectedWallet = ({
mobileVariant = 'iconAndDomain',
desktopVariant = 'iconAndDomain',
onOpen,
buttonStyle,
}: ConnectedWalletProps) => {
const { account } = useWallet();
const [isDesktop] = useMediaQuery('(min-width: 768px)');

return (
<Button onClick={onOpen} p={'0px 13px'} minH={'45px'}>
<Button {...buttonStyle} onClick={onOpen} p={'0px 13px'} minH={'45px'}>
<HStack>
<Image
src={account?.image ?? notFoundImage}
Expand Down
16 changes: 13 additions & 3 deletions packages/vechain-kit/src/components/WalletButton/WalletButton.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,24 @@
import { Button, useDisclosure } from '@chakra-ui/react';
import { Button, ButtonProps, useDisclosure } from '@chakra-ui/react';
import { useWallet } from '@/hooks';
import { useWallet as useDappKitWallet } from '@vechain/dapp-kit-react';
import { usePrivy } from '@privy-io/react-auth';
import { useEffect } from 'react';
import { ConnectModal, AccountModal } from '@/components';
import { ConnectedWallet } from './ConnectedWallet';
import { WalletButtonProps } from './types';
import { WalletDisplayVariant } from './types';
import { useTranslation } from 'react-i18next';
import { useVeChainKitConfig, VechainKitThemeProvider } from '@/providers';

export type WalletButtonProps = {
mobileVariant?: WalletDisplayVariant;
desktopVariant?: WalletDisplayVariant;
buttonStyle?: ButtonProps;
};

export const WalletButton = ({
mobileVariant = 'iconAndDomain',
desktopVariant = 'iconDomainAndAddress',
buttonStyle,
}: WalletButtonProps) => {
const { t } = useTranslation();
const { darkMode } = useVeChainKitConfig();
Expand Down Expand Up @@ -55,9 +62,12 @@ export const WalletButton = ({
mobileVariant={mobileVariant}
desktopVariant={desktopVariant}
onOpen={accountModal.onOpen}
buttonStyle={buttonStyle}
/>
) : (
<Button onClick={handleConnect}>{t('Login')}</Button>
<Button onClick={handleConnect} {...buttonStyle}>
{t('Login')}
</Button>
)}

<ConnectModal
Expand Down
5 changes: 0 additions & 5 deletions packages/vechain-kit/src/components/WalletButton/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,3 @@ export type WalletDisplayVariant =
| 'iconAndDomain'
| 'iconDomainAndAddress'
| 'iconDomainAndAssets';

export type WalletButtonProps = {
mobileVariant?: WalletDisplayVariant;
desktopVariant?: WalletDisplayVariant;
};

0 comments on commit f55377b

Please sign in to comment.