Skip to content

Commit 040f9e8

Browse files
committed
working on qr logo
1 parent aac49cc commit 040f9e8

File tree

4 files changed

+31
-10
lines changed

4 files changed

+31
-10
lines changed

src/internal/components/QrCode/QrCodeSvg.tsx

+1-3
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export type QRCodeSVGProps = {
2424
size?: number;
2525
color?: string;
2626
backgroundColor?: string;
27-
logo?: { uri: string };
27+
logo?: React.ReactNode;
2828
logoSize?: number;
2929
logoBackgroundColor?: string;
3030
logoMargin?: number;
@@ -115,8 +115,6 @@ export function QRCodeSVG({
115115
gradientRadiusMax,
116116
]);
117117

118-
console.log({ value, path, color, isRadialGradient, bgColor, fillColor });
119-
120118
if (!path) {
121119
return null;
122120
}

src/internal/components/QrCode/useLogo.tsx

+6-6
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { useMemo } from 'react';
22

33
type RenderLogoProps = {
44
size: number;
5-
logo: { uri: string } | undefined;
5+
logo: React.ReactNode | undefined;
66
logoSize: number;
77
logoBackgroundColor: string;
88
logoMargin: number;
@@ -27,7 +27,7 @@ export function useLogo({
2727
logoBorderRadius + (logoMargin / logoSize) * logoBorderRadius;
2828

2929
return (
30-
<g x={logoPosition} y={logoPosition}>
30+
<g transform={`translate(${logoPosition}, ${logoPosition})`}>
3131
<defs>
3232
<clipPath id="clip-logo-background">
3333
<rect
@@ -55,13 +55,13 @@ export function useLogo({
5555
/>
5656
</g>
5757
<g x={logoMargin} y={logoMargin}>
58-
<image
58+
<g
5959
width={logoSize}
6060
height={logoSize}
61-
preserveAspectRatio="xMidYMid slice"
62-
href={logo.uri}
6361
clipPath="url(#clip-logo)"
64-
/>
62+
>
63+
{logo}
64+
</g>
6565
</g>
6666
</g>
6767
);

src/internal/svg/cbwSvg.tsx

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { background, icon } from '../../styles/theme';
2+
3+
export const cbwSvg = (width: number, height: number) => (
4+
<svg
5+
width={width}
6+
height={height}
7+
viewBox="0 0 1024 1024"
8+
xmlns="http://www.w3.org/2000/svg"
9+
>
10+
<title>Wallet Icon</title>
11+
<rect width="1024" height="1024" fill="#0052FF" />
12+
<path
13+
fillRule="evenodd"
14+
clipRule="evenodd"
15+
d="M152 512C152 710.823 313.177 872 512 872C710.823 872 872 710.823 872 512C872 313.177 710.823 152 512 152C313.177 152 152 313.177 152 512ZM420 396C406.745 396 396 406.745 396 420V604C396 617.255 406.745 628 420 628H604C617.255 628 628 617.255 628 604V420C628 406.745 617.255 396 604 396H420Z"
16+
fill="white"
17+
/>
18+
</svg>
19+
);

src/wallet/components/island/WalletIslandQrReceive.tsx

+5-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { copySvg } from '../../../internal/svg/copySvg';
55
import { border, cn, color, pressable, text } from '../../../styles/theme';
66
import { useWalletContext } from '../WalletProvider';
77
import { useWalletIslandContext } from './WalletIslandProvider';
8+
import { cbwSvg } from '../../../internal/svg/cbwSvg';
89

910
export function WalletIslandQrReceive() {
1011
const { address } = useWalletContext();
@@ -45,7 +46,10 @@ export function WalletIslandQrReceive() {
4546
</button>
4647
</div>
4748

48-
<QRCodeComponent value={address ? `ethereum:${address}` : ''} />
49+
<QRCodeComponent
50+
value={address ? `ethereum:${address}` : ''}
51+
logo={cbwSvg(24, 24)}
52+
/>
4953

5054
<button
5155
type="button"

0 commit comments

Comments
 (0)