Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: optimize connect modal UI #776

Merged
merged 5 commits into from
Apr 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/red-doors-drop.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@ant-design/web3": minor
---

feat: optimize connect modal ui

Large diffs are not rendered by default.

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/web3/src/connect-modal/components/QrCode.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ const QrCode: React.FC<QrCodeProps> = (props) => {
className={`${prefixCls}-qr-code`}
value={qrCodeValue}
status={!loading ? 'active' : 'loading'}
size={simple ? 332 : 400}
size={simple ? 332 : 350}
iconSize={60}
type="svg"
/>
Expand Down
11 changes: 7 additions & 4 deletions packages/web3/src/connect-modal/components/WalletList.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { forwardRef, useContext, useImperativeHandle, useMemo } from 'react';
import { QrcodeOutlined } from '@ant-design/icons';
import { Button, List, Space } from 'antd';
import { Button, List, Space, Typography } from 'antd';
import classNames from 'classnames';

import { connectModalContext } from '../context';
Expand Down Expand Up @@ -68,7 +68,6 @@ const WalletList = forwardRef<ConnectModalActionType, WalletListProps>((props, r
selectWallet,
};
});

const renderContent = (params?: { group?: string }) => {
const { group } = params || {};
return (
Expand All @@ -94,7 +93,9 @@ const WalletList = forwardRef<ConnectModalActionType, WalletListProps>((props, r
) : (
<div className={`${prefixCls}-icon`}>{item.icon}</div>
)}
<div className={`${prefixCls}-name`}>{item.name}</div>
<Typography.Text ellipsis={{ tooltip: true }} className={`${prefixCls}-name`}>
{item.name}
</Typography.Text>
</div>
<Space>
<PluginTag wallet={item} />
Expand All @@ -112,7 +113,9 @@ const WalletList = forwardRef<ConnectModalActionType, WalletListProps>((props, r
<QrcodeOutlined />
</Button>
) : (
<div className={`${prefixCls}-qr-icon-empty`} />
walletList.some((w) => w.getQrCode) && (
<div className={`${prefixCls}-qr-icon-empty`} />
)
)}
</Space>
</List.Item>
Expand Down
8 changes: 8 additions & 0 deletions packages/web3/src/connect-modal/demos/basic.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,14 @@ const walletList: Wallet[] = [
);
},
},
{
icon: 'https://xsgames.co/randomusers/avatar.php?g=pixel&key=3',
name: 'Test Wallet3 Have a Long Name',
remark: 'remark 3',
app: {
link: 'https://test.com/xxx',
},
},
];
const groupOrder = (a: string, b: string) => {
if (a === 'Popular') return -1;
Expand Down
20 changes: 16 additions & 4 deletions packages/web3/src/connect-modal/style/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ const getThemeStyle = (token: ConnectModalToken): CSSInterpolation => {
display: 'flex',
justifyContent: 'space-between',
position: 'relative',

height: 518,
[`${componentCls}-title`]: {
fontSize: token.fontSizeXL,
lineHeight: '28px',
Expand Down Expand Up @@ -101,7 +101,6 @@ const getThemeStyle = (token: ConnectModalToken): CSSInterpolation => {
paddingInline: token.paddingMD,
overflow: 'auto',
[`${componentCls}-wallet-list`]: {
maxHeight: 390,
overflow: 'scroll',
'&::-webkit-scrollbar': {
display: 'none',
Expand All @@ -123,29 +122,37 @@ const getThemeStyle = (token: ConnectModalToken): CSSInterpolation => {
transition: 'background .3s, color .3s',
marginBlockEnd: 5,
border: 'none',
width: '100%',
[`${componentCls}-content`]: {
display: 'flex',
flex: 1,
alignItems: 'center',
width: '100%',
overflow: 'hidden',
[`${componentCls}-icon`]: {
borderRadius: 8,
overflow: 'hidden',
width: token.iconSize,
height: token.iconSize,
fontSize: token.iconSize,
lineHeight: `${token.iconSize}px`,
flexShrink: 0,
},
[`${componentCls}-img`]: {
borderRadius: 8,
overflow: 'hidden',
width: token.iconSize,
height: token.iconSize,
flexShrink: 0,
},
[`${componentCls}-name`]: {
fontSize: token.fontSizeLG,
justifySelf: 'flex-start',
marginInlineStart: token.marginSM,
color: token.colorText,
wordBreak: 'break-word',
flex: 1,
marginInlineEnd: token.marginXS,
},
},
[`${componentCls}-qr-icon-empty`]: {
Expand Down Expand Up @@ -236,6 +243,9 @@ const getThemeStyle = (token: ConnectModalToken): CSSInterpolation => {
},
[`${componentCls}-simple-guide-panel`]: {
marginBlockStart: 0,
[`${componentCls}-guide-list`]: {
maxHeight: 280,
},
},
[`${componentCls}-guide-list`]: {
marginBlock: token.marginLG,
Expand Down Expand Up @@ -299,7 +309,7 @@ const getThemeStyle = (token: ConnectModalToken): CSSInterpolation => {
height: '100%',
[`${componentCls}-list`]: {
marginBlockStart: token.marginXL,
minHeight: 286,
height: 286,
overflow: 'auto',
[`${componentCls}-item`]: {
marginBlockEnd: token.marginLG,
Expand Down Expand Up @@ -340,9 +350,11 @@ const getThemeStyle = (token: ConnectModalToken): CSSInterpolation => {
},
[`${componentCls}-card-list`]: {
marginBlockStart: 25,
height: '90%',
overflow: 'auto',
[`${componentCls}-card-item`]: {
width: '100%',
height: 220,
height: 200,
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
Expand Down
Loading