-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: make wallet icon size adapt to button size
- Loading branch information
Showing
9 changed files
with
41 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 21 additions & 2 deletions
23
packages/wallet-adapter-mantine-ui/src/lib/wallet-icon.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,32 @@ | ||
import { Image, ImageProps } from '@mantine/core' | ||
import { ButtonProps, Image, ImageProps, MantineSize } from '@mantine/core' | ||
import type { Wallet } from '@solana/wallet-adapter-react' | ||
import React from 'react' | ||
|
||
export interface WalletIconProps extends ImageProps { | ||
wallet: Wallet | null | ||
size?: ButtonProps['size'] | ||
} | ||
|
||
export function WalletIcon({ wallet, ...props }: WalletIconProps) { | ||
const size = convertSize(props.size) | ||
return wallet ? ( | ||
<Image src={wallet.adapter.icon} alt={`${wallet.adapter.name} icon`} height={28} width={28} {...props} /> | ||
<Image src={wallet.adapter.icon} alt={`${wallet.adapter.name} icon`} height={size} width={size} {...props} /> | ||
) : null | ||
} | ||
|
||
function convertSize(size?: ButtonProps['size']): number { | ||
switch (size) { | ||
case 'xs': | ||
return 16 | ||
case 'sm': | ||
return 20 | ||
case 'md': | ||
return 28 | ||
case 'lg': | ||
return 32 | ||
case 'xl': | ||
return 38 | ||
default: | ||
return 28 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.