Skip to content

Conversation

yutingzhao1991
Copy link
Collaborator

@yutingzhao1991 yutingzhao1991 commented Jun 26, 2025

close #1456

Summary by CodeRabbit

  • 新功能
    • 新增了 ConnectPanel 组件,提供卡片式 Web3 钱包连接面板,支持自定义钱包列表、图标与操作按钮。
  • 文档
    • 增加了 ConnectPanel 组件的中英文使用文档,包含示例与 API 说明。
  • 样式
    • 新增 ConnectPanel 组件的样式,支持主题和自定义样式扩展。

Copy link

changeset-bot bot commented Jun 26, 2025

⚠️ No Changeset found

Latest commit: f785b90

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link

vercel bot commented Jun 26, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
ant-design-web3 ❌ Failed (Inspect) Jun 26, 2025 7:59am

Copy link

coderabbitai bot commented Jun 26, 2025

📝 Walkthrough

Walkthrough

本次变更为 Web3 包新增了 ConnectPanel 组件及其样式和中英文文档。ConnectPanel 提供卡片式钱包连接面板,支持自定义钱包列表和点击事件。相关样式通过 useStyle 钩子实现,组件和样式已在包入口文件中导出。

Changes

文件/分组 变更摘要
.../connect-panel/index.tsx 新增 ConnectPanel 组件,支持钱包卡片列表、样式与点击事件。
.../connect-panel/style/index.ts 新增 ConnectPanel 组件样式生成与 useStyle 钩子。
.../connect-panel/index.md
...zh-CN.md
新增 ConnectPanel 组件的英文与中文文档,含用法与 API 说明。
.../connect-panel/index.ts 新增 re-export 语句,导出本目录下所有模块。
.../index.ts 新增导出 connect-panel 相关内容。

Sequence Diagram(s)

sequenceDiagram
  participant App
  participant ConnectPanel
  participant WalletCard

  App->>ConnectPanel: 传入 wallets, className, style 等 props
  ConnectPanel->>ConnectPanel: 使用 useStyle 生成样式
  loop 遍历 wallets
    ConnectPanel->>WalletCard: 渲染卡片(icon, name, actionText)
    WalletCard-->>ConnectPanel: 用户点击卡片,触发 onClick
  end
Loading

Assessment against linked issues

Objective Addressed Explanation
新增卡片式钱包快捷连接组件 ConnectPanel,支持自定义钱包卡片、点击事件等 (#1456)

Assessment against linked issues: Out-of-scope changes

(未发现超出 #1456 需求范围的代码变更)

Poem

兔子挥笔写新篇,
卡片连钱包,样式也新鲜。
点击即刻连世界,
钱包列表任你选。
代码与文档齐飞舞,
Web3 面板乐无边!
🐇💳✨

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

packages/web3/src/connect-panel/index.ts

Oops! Something went wrong! :(

ESLint: 8.57.1

ESLint couldn't find the plugin "eslint-plugin-react".

(The package "eslint-plugin-react" was not found when loaded as a Node module from the directory "".)

It's likely that the plugin isn't installed correctly. Try reinstalling by running the following:

npm install eslint-plugin-react@latest --save-dev

The plugin "eslint-plugin-react" was referenced from the config file in ".eslintrc.js » /node_modules/.pnpm/@umijs[email protected][email protected]/node_modules/@umijs/fabric/dist/eslint.js".

If you still can't figure out the problem, please stop by https://eslint.org/chat/help to chat with the team.

packages/web3/src/connect-panel/index.tsx

Oops! Something went wrong! :(

ESLint: 8.57.1

ESLint couldn't find the plugin "eslint-plugin-react".

(The package "eslint-plugin-react" was not found when loaded as a Node module from the directory "".)

It's likely that the plugin isn't installed correctly. Try reinstalling by running the following:

npm install eslint-plugin-react@latest --save-dev

The plugin "eslint-plugin-react" was referenced from the config file in ".eslintrc.js » /node_modules/.pnpm/@umijs[email protected][email protected]/node_modules/@umijs/fabric/dist/eslint.js".

If you still can't figure out the problem, please stop by https://eslint.org/chat/help to chat with the team.

packages/web3/src/connect-panel/style/index.ts

Oops! Something went wrong! :(

ESLint: 8.57.1

ESLint couldn't find the plugin "eslint-plugin-react".

(The package "eslint-plugin-react" was not found when loaded as a Node module from the directory "".)

It's likely that the plugin isn't installed correctly. Try reinstalling by running the following:

npm install eslint-plugin-react@latest --save-dev

The plugin "eslint-plugin-react" was referenced from the config file in ".eslintrc.js » /node_modules/.pnpm/@umijs[email protected][email protected]/node_modules/@umijs/fabric/dist/eslint.js".

If you still can't figure out the problem, please stop by https://eslint.org/chat/help to chat with the team.

  • 1 others
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate Unit Tests
  • Create PR with Unit Tests
  • Post Copyable Unit Tests in Comment
  • Commit Unit Tests in branch feat/ConnectPanel

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai auto-generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@yutingzhao1991 yutingzhao1991 marked this pull request as draft June 26, 2025 07:56
Copy link

github-actions bot commented Jun 26, 2025

Preview Failed

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🧹 Nitpick comments (5)
packages/web3/src/connect-panel/style/index.ts (1)

20-21: 考虑响应式设计

固定的宽高(240x260)可能在不同屏幕尺寸下表现不佳,建议考虑响应式设计或使用相对单位。

packages/web3/src/connect-panel/index.tsx (2)

2-2: 未使用的导入

导入了 Wallet 类型但未使用,建议移除或考虑重用现有类型定义。

-import type { Wallet } from '@ant-design/web3-common';

7-17: 考虑重用现有的 Wallet 类型

当前的钱包接口定义与现有的 Wallet 类型有重叠,建议考虑扩展现有类型以保持一致性。

packages/web3/src/connect-panel/index.md (2)

15-18: <img> 标签添加 alt 属性以提升可访问性
示例代码中的三处 <img> 标签均缺少 alt 描述,这会降低屏幕阅读器的可读性并影响 SEO。建议补充相应的替代文本。

- icon: <img src="/path/to/metamask.svg" width={64} height={64} />,
+ icon: <img src="/path/to/metamask.svg" width={64} height={64} alt="MetaMask logo" />,

同理,请为 OKX Wallet 与 Add Address 的图标也补充 alt

Also applies to: 24-27, 33-37


45-50: API 表中类型标注过于宽泛
目前 walletsclassNamestyle 的类型写成了 array / string / object,不够精确,容易误导使用者。建议改为更贴近实际的 TypeScript 类型:

  • wallets: WalletItem[]
  • className: string
  • style: React.CSSProperties

这样既能体现组件的类型安全,也与代码实现保持一致。

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 80a3684 and f785b90.

📒 Files selected for processing (6)
  • packages/web3/src/connect-panel/index.md (1 hunks)
  • packages/web3/src/connect-panel/index.ts (1 hunks)
  • packages/web3/src/connect-panel/index.tsx (1 hunks)
  • packages/web3/src/connect-panel/index.zh-CN.md (1 hunks)
  • packages/web3/src/connect-panel/style/index.ts (1 hunks)
  • packages/web3/src/index.ts (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
packages/web3/src/connect-panel/index.tsx (1)
Learnt from: CR
PR: ant-design/ant-design-web3#0
File: .cursor/rules/basic.mdc:0-0
Timestamp: 2025-06-25T00:35:57.367Z
Learning: This project is a React component library built on Ant Design, designed to provide Web3 wallet connection capabilities and common DApp UI components.
🧬 Code Graph Analysis (1)
packages/web3/src/connect-panel/style/index.ts (1)
packages/web3/src/theme/useStyle/index.ts (3)
  • Web3AliasToken (45-64)
  • GenerateStyle (35-38)
  • UseStyleResult (40-43)
🪛 Biome (1.9.4)
packages/web3/src/connect-panel/index.tsx

[error] 26-30: Enforce to have the onClick mouse event with the onKeyUp, the onKeyDown, or the onKeyPress keyboard event.

Actions triggered using mouse events should have corresponding keyboard events to account for keyboard-only navigation.

(lint/a11y/useKeyWithClickEvents)

⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: ci
  • GitHub Check: prepare preview
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: ci
🔇 Additional comments (4)
packages/web3/src/connect-panel/index.ts (1)

1-1: 代码结构良好

遵循了项目的标准重导出模式。

packages/web3/src/index.ts (1)

16-16: 正确集成了新组件

新的 connect-panel 导出遵循了现有的模式,集成方式正确。

packages/web3/src/connect-panel/index.zh-CN.md (1)

1-60: 文档编写完整

中文文档结构清晰,包含了完整的使用示例和 API 说明,有助于开发者理解和使用组件。

packages/web3/src/connect-panel/index.md (1)

53-60: 补充缺失或可选字段说明,保证文档完整
若组件支持更多卡片配置(如 disabledtagdescription 等),应在此表格中同步列出;若没有,也建议明确 actionTextonClick 是否必填,以避免使用者困惑。

[`${token.componentCls}-card`]: {
width: 240,
height: 260,
background: '#fafaff',
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

建议使用设计令牌而不是硬编码颜色

建议使用设计令牌中的颜色值而不是硬编码的 #fafaff,以保持设计系统的一致性。

-        background: '#fafaff',
+        background: token.colorBgLayout,
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
background: '#fafaff',
background: token.colorBgLayout,
🤖 Prompt for AI Agents
In packages/web3/src/connect-panel/style/index.ts at line 22, replace the
hardcoded color value '#fafaff' with the corresponding design token color from
the design system to ensure consistency. Identify the appropriate color token
that matches '#fafaff' and use it instead of the literal hex code.

marginBottom: 12,
},
[`${token.componentCls}-action`]: {
color: '#666',
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

建议使用设计令牌中的文本颜色

建议使用设计令牌中的文本颜色而不是硬编码的 #666

-        color: '#666',
+        color: token.colorTextSecondary,
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
color: '#666',
- color: '#666',
+ color: token.colorTextSecondary,
🤖 Prompt for AI Agents
In packages/web3/src/connect-panel/style/index.ts at line 44, replace the
hardcoded color value '#666' with the corresponding text color from the design
tokens. Locate the appropriate design token for text color in the project's
style or theme files and use that token instead of the fixed hex code to ensure
consistency with the design system.

Comment on lines +26 to +30
<div
key={wallet.key}
className={classNames(`${prefixCls}-card`, hashId)}
onClick={wallet.onClick}
>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

修复无障碍访问问题

卡片元素缺少键盘事件支持,这会影响键盘导航用户的体验。根据静态分析工具的建议,需要添加键盘事件处理。

        <div
          key={wallet.key}
          className={classNames(`${prefixCls}-card`, hashId)}
          onClick={wallet.onClick}
+         onKeyDown={(e) => {
+           if ((e.key === 'Enter' || e.key === ' ') && wallet.onClick) {
+             e.preventDefault();
+             wallet.onClick();
+           }
+         }}
+         tabIndex={0}
+         role="button"
+         aria-label={`${wallet.actionText} ${wallet.name}`}
        >
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<div
key={wallet.key}
className={classNames(`${prefixCls}-card`, hashId)}
onClick={wallet.onClick}
>
<div
key={wallet.key}
className={classNames(`${prefixCls}-card`, hashId)}
onClick={wallet.onClick}
onKeyDown={(e) => {
if ((e.key === 'Enter' || e.key === ' ') && wallet.onClick) {
e.preventDefault();
wallet.onClick();
}
}}
tabIndex={0}
role="button"
aria-label={`${wallet.actionText} ${wallet.name}`}
>
🧰 Tools
🪛 Biome (1.9.4)

[error] 26-30: Enforce to have the onClick mouse event with the onKeyUp, the onKeyDown, or the onKeyPress keyboard event.

Actions triggered using mouse events should have corresponding keyboard events to account for keyboard-only navigation.

(lint/a11y/useKeyWithClickEvents)

🤖 Prompt for AI Agents
In packages/web3/src/connect-panel/index.tsx around lines 26 to 30, the div
element acting as a clickable card lacks keyboard event handlers, which impairs
accessibility for keyboard users. Add appropriate keyboard event handlers such
as onKeyDown or onKeyPress to handle Enter and Space keys, enabling keyboard
navigation and activation of the card. Also, ensure the div has a tabIndex
attribute to make it focusable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature Request] New quick link wallet style

1 participant