Skip to content

Commit

Permalink
feat: add ChromeColorful icon (#188)
Browse files Browse the repository at this point in the history
* feat: add ChromeColorful icon

* refactor: use ChromeColorful icon and remove useless constants

---------

Co-authored-by: yutingzhao1991 <[email protected]>
  • Loading branch information
yutingzhao1991 and yutingzhao1991 authored Dec 7, 2023
1 parent 11df8dd commit 1bb5c2e
Show file tree
Hide file tree
Showing 12 changed files with 55 additions and 80 deletions.
5 changes: 2 additions & 3 deletions packages/assets/src/wallets/meta-mask.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { WalletMetadata } from '@ant-design/web3-common';
import { MetaMaskColorful } from '@ant-design/web3-icons';
import { MetaMaskColorful, ChromeColorful } from '@ant-design/web3-icons';

export const metadata_MetaMask: WalletMetadata = {
icon: <MetaMaskColorful />,
Expand All @@ -11,8 +11,7 @@ export const metadata_MetaMask: WalletMetadata = {
extensions: [
{
key: 'Chrome',
browserIcon:
'https://github.com/ant-design/ant-design/assets/10286961/0d4e4ac7-8f89-4147-a06a-de72c02e85cb',
browserIcon: <ChromeColorful />,
browserName: 'Chrome',
link: 'https://chrome.google.com/webstore/detail/metamask/nkbihfbeogaeaoehlefnkodbefgpgknn',
description: 'Access your wallet right from your favorite web browser.',
Expand Down
2 changes: 1 addition & 1 deletion packages/common/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export type WalletExtensionItem = {
* @desc 浏览器扩展程序的图标
* @descEn Icon of browser extension
*/
browserIcon: string;
browserIcon: React.ReactNode | string;
/**
* @desc 浏览器扩展程序的名称
* @descEn Name of browser extension
Expand Down
10 changes: 10 additions & 0 deletions packages/icons/src/components/chrome-colorful.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import * as React from 'react';
import AntdIcon from '@ant-design/icons';
import { ReactComponent as SVGComponent } from '../svgs/chrome-colorful.svg';
import { type IconBaseProps } from '@ant-design/icons/lib/components/Icon';

export const ChromeColorful = React.forwardRef<HTMLSpanElement, IconBaseProps>((props, ref) => (
<AntdIcon {...props} ref={ref} component={SVGComponent} />
));

ChromeColorful.displayName = 'ChromeColorful';
1 change: 1 addition & 0 deletions packages/icons/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ export * from './components/usdt-circle-filled';
export * from './components/sui-colorful';
export * from './components/sui-filled';
export * from './components/sui-circle-filled';
export * from './components/chrome-colorful';
28 changes: 28 additions & 0 deletions packages/icons/src/svgs/chrome-colorful.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 7 additions & 1 deletion packages/web3/src/connect-modal/components/WalletCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,13 @@ const WalletCard: React.FC = () => {
{selectedExtension && (
<CardItem
link={selectedExtension.link}
icon={<img src={selectedExtension.browserIcon} />}
icon={
typeof selectedExtension.browserIcon === 'string' ? (
<img src={selectedExtension.browserIcon} />
) : (
selectedExtension.browserIcon
)
}
title={`${selectedWallet!.name} for ${selectedExtension.browserName}`}
desc={selectedExtension.description}
/>
Expand Down
18 changes: 2 additions & 16 deletions packages/web3/src/connector/demos/basic.tsx
Original file line number Diff line number Diff line change
@@ -1,27 +1,13 @@
import React from 'react';
import type { Account } from '@ant-design/web3';
import { metadata_MetaMask, metadata_WalletConnect } from '@ant-design/web3-assets';
import { Connector, ConnectButton } from '@ant-design/web3';

const App: React.FC = () => {
const [account, setAccount] = React.useState<Account>();
return (
<Connector
availableWallets={[
{
name: 'MetaMask',
remark: 'Easy-to-use browser extension.',
extensions: [
{
key: 'Chrome',
browserIcon:
'https://github.com/ant-design/ant-design/assets/10286961/0d4e4ac7-8f89-4147-a06a-de72c02e85cb',
browserName: 'Chrome',
link: 'https://chrome.google.com/webstore/detail/metamask/nkbihfbeogaeaoehlefnkodbefgpgknn',
description: 'Access your wallet right from your favorite web browser.',
},
],
},
]}
availableWallets={[metadata_MetaMask, metadata_WalletConnect]}
connect={async () =>
new Promise((resolve) => {
setTimeout(() => {
Expand Down
18 changes: 2 additions & 16 deletions packages/web3/src/connector/demos/custom-trigger.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from 'react';
import type { Account, ConnectorTriggerProps } from '@ant-design/web3';
import { metadata_MetaMask, metadata_WalletConnect } from '@ant-design/web3-assets';
import { Connector } from '@ant-design/web3';
import { Typography } from 'antd';

Expand All @@ -16,22 +17,7 @@ const App: React.FC = () => {
const [account, setAccount] = React.useState<Account>();
return (
<Connector
availableWallets={[
{
name: 'MetaMask',
remark: 'Easy-to-use browser extension.',
extensions: [
{
key: 'Chrome',
browserIcon:
'https://github.com/ant-design/ant-design/assets/10286961/0d4e4ac7-8f89-4147-a06a-de72c02e85cb',
browserName: 'Chrome',
link: 'https://chrome.google.com/webstore/detail/metamask/nkbihfbeogaeaoehlefnkodbefgpgknn',
description: 'Access your wallet right from your favorite web browser.',
},
],
},
]}
availableWallets={[metadata_MetaMask, metadata_WalletConnect]}
connect={async () =>
new Promise((resolve) => {
setTimeout(() => {
Expand Down
1 change: 0 additions & 1 deletion packages/web3/src/constants/index.ts

This file was deleted.

41 changes: 0 additions & 41 deletions packages/web3/src/constants/presets.ts

This file was deleted.

2 changes: 2 additions & 0 deletions packages/web3/src/icons/demos/colorful.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
WalletColorful,
WalletWhiteColorful,
SuiColorful,
ChromeColorful,
} from '@ant-design/web3-icons';
import { Space } from 'antd';

Expand Down Expand Up @@ -40,6 +41,7 @@ const App: React.FC = () => {
}}
/>
<SuiColorful style={style} />
<ChromeColorful style={style} />
</Space>
);
};
Expand Down
1 change: 0 additions & 1 deletion packages/web3/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ export * from './address';
export * from './browser-link';
export * from './nft-image';
export * from './nft-card';
export * from './constants';
export * from './hooks';
export * from './web3-config-provider';

Expand Down

0 comments on commit 1bb5c2e

Please sign in to comment.