Skip to content

Comments

feat(QRCode): support ConfigProvider#52172

Merged
thinkasany merged 6 commits intoant-design:nextfrom
thinkasany-forks:cp-qrcode
Apr 10, 2025
Merged

feat(QRCode): support ConfigProvider#52172
thinkasany merged 6 commits intoant-design:nextfrom
thinkasany-forks:cp-qrcode

Conversation

@thinkasany
Copy link
Member

🤔 This is a ...

  • 🆕 New feature

🔗 Related Issues

📝 Change Log

Language Changelog
🇺🇸 English feat: ConfigProvider support qrcode
🇨🇳 Chinese feat: ConfigProvider 支持 qrcode 组件的配置

@bolt-new-by-stackblitz
Copy link

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@github-actions
Copy link
Contributor

github-actions bot commented Dec 30, 2024

Preview is ready

@github-actions
Copy link
Contributor

github-actions bot commented Dec 30, 2024

👁 Visual Regression Report for PR #52172 Passed ✅

🎯 Target branch: next (0a50c71)
📖 View Full Report ↗︎
📖 Alternative Report ↗︎

🎊 Congrats! No visual-regression diff found.

@petercat-assistant
Copy link

Walkthrough

This pull request introduces a new feature to the ConfigProvider component, adding support for QRCode configuration. This enhancement allows developers to customize QRCode components through ConfigProvider, enabling the application of common properties such as class names and styles.

Changes

File Summary
components/config-provider/context.ts Added QRCodeProps import and defined QRcodeConfig type for QRCode customization.
components/config-provider/index.en-US.md, components/config-provider/index.zh-CN.md Updated documentation to include QRCode configuration options.
components/config-provider/index.tsx Integrated QRcodeConfig into ConfigProviderProps and updated component logic to support QRCode customization.
components/qr-code/tests/index.test.tsx Added tests to verify QRCode customization through class names and styles.
components/qr-code/demo/_semantic.tsx Introduced a demo showcasing semantic DOM usage with QRCode.
components/qr-code/index.en-US.md, components/qr-code/index.zh-CN.md Added documentation for semantic DOM related to QRCode.
components/qr-code/index.tsx Enhanced QRCode component to support classNames and styles from ConfigProvider.
components/qr-code/interface.ts Extended QRCodeProps to include classNames and styles for customization.

'className' | 'style' | 'styles' | 'classNames'
>;

export type QRcodeConfig = ComponentStyleConfig & Pick<QRCodeProps, 'classNames' | 'styles'>;

Choose a reason for hiding this comment

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

Ensure that the QRcodeConfig type correctly extends ComponentStyleConfig and includes only the necessary properties from QRCodeProps. This helps maintain type safety and clarity.

@thinkasany thinkasany mentioned this pull request Dec 30, 2024
@pkg-pr-new
Copy link

pkg-pr-new bot commented Dec 30, 2024

More templates

npm i https://pkg.pr.new/ant-design/ant-design/antd@52172

commit: 5b71cdf

@codecov
Copy link

codecov bot commented Dec 30, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (0a50c71) to head (5b71cdf).
Report is 1 commits behind head on next.

Additional details and impacted files
@@            Coverage Diff            @@
##              next    #52172   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          781       781           
  Lines        14133     14134    +1     
  Branches      3722      3722           
=========================================
+ Hits         14133     14134    +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

statusRender?: (info: StatusRenderInfo) => ReactNode;
classNames?: {
root?: string;
mask?: string;
Copy link
Member

Choose a reason for hiding this comment

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

感觉有点少,比如 icon,还有 qrcode 本体(Canvas or SVG) 都没有

Copy link
Member Author

Choose a reason for hiding this comment

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

还不确定后面会不会换回去库,这个任务先晚点处理,优先做其他的。
image

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Apr 9, 2025

📝 Walkthrough

Summary by CodeRabbit

  • 新功能

    • 扩展了二维码组件的配置选项,支持自定义类名和样式,并可通过配置提供器传递二维码相关设置。
    • 新增语义预览示例,支持中英文本地化展示二维码效果。
  • 文档

    • 更新了 API 文档,补充了二维码组件说明,并恢复了传输组件的相关描述。
  • 样式

    • 优化了二维码组件的样式合并逻辑,并更新了部分样式令牌以替换旧属性。

Walkthrough

此次修改在配置提供者中增加了对 QR 码组件配置的新类型和相关文档更新。新增了 QRcodeConfig 类型、更新了 ConfigProviderProps 接口以及 QR 码组件的配置处理逻辑。同时,API 文档(包括中英文文档)中新增了 qrcode 条目,并恢复了 transfer 组件的说明。此外,还引入了一个示例组件展示语义 DOM,及测试用例以验证自定义样式和类名的应用。总体上,修改集中在配置类型扩展和文档示例上。

Changes

文件 修改描述
components/config-provider/context.ts 新增 QRcodeConfig 类型声明,扩展 ComponentStyleConfig 并选择 QRCodeProps 中的 classNamesstyles 属性。
components/config-provider/index.tsx 更新 ConfigProviderProps 接口,增加 qrcode?: QRcodeConfig 配置,并在 Provider children 中传递该配置。
components/config-provider/index.en-US.md
components/config-provider/index.zh-CN.md
API 文档更新:新增 qrcode 组件条目及属性,同时恢复 transfer 组件的文档说明。
components/qr-code/interface.ts 新增类型 SemanticName('root'
components/qr-code/index.tsx 替换 useContextuseComponentConfig 钩子,更新合并逻辑,改进了类名和样式的应用方式。
components/qr-code/index.en-US.md
components/qr-code/index.zh-CN.md
文档新增 “Semantic DOM” 部分,引用 demo 示例文件展示组件语义化结构。
components/qr-code/tests/index.test.tsx 新增测试用例,验证 QRCode 组件对自定义样式和类名的应用效果。
components/qr-code/demo/_semantic.tsx 新增 React 示例组件,用于展示 QR 码组件的语义 DOM 预览。

Possibly related PRs

Suggested reviewers

  • zombieJ

Poem

我是兔儿轻跳来,
新代码闪烁似星灿。
配置灵动添新彩,
语义之美跃眼前。
测试验证稳妥在,
代码世界更欢畅!


📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between c324f7c and 5b71cdf.

📒 Files selected for processing (1)
  • components/qr-code/style/index.ts (4 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • components/qr-code/style/index.ts
⏰ Context from checks skipped due to timeout of 90000ms (11)
  • GitHub Check: test-react-legacy (18, 2/2)
  • GitHub Check: test-react-legacy (18, 1/2)
  • GitHub Check: test-react-latest (dom, 2/2)
  • GitHub Check: test lib/es module (es, 2/2)
  • GitHub Check: test-react-latest (dom, 1/2)
  • GitHub Check: test lib/es module (es, 1/2)
  • GitHub Check: build
  • GitHub Check: visual-diff snapshot (2/2)
  • GitHub Check: visual-diff snapshot (1/2)
  • GitHub Check: build preview
  • GitHub Check: build

🪧 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.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @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 generate unit testing code.
    • @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.

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 resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @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.

@thinkasany thinkasany changed the base branch from feature to next April 9, 2025 06:53
@coderabbitai coderabbitai bot requested a review from zombieJ April 9, 2025 07:09
Copy link
Contributor

@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: 2

♻️ Duplicate comments (2)
components/qr-code/demo/_semantic.tsx (1)

9-9: 请确保字符串与通用命名一致

根据过去的评论,建议使用标准化的描述文本。

-    root: '根元素',
+    root: '根元素',
components/config-provider/context.ts (1)

275-275: QRcodeConfig类型定义清晰

QRcodeConfig类型正确地扩展了ComponentStyleConfig并从QRCodeProps中提取了classNames和styles属性,保持了类型安全和一致性。

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 31efd7f and 5f518af.

📒 Files selected for processing (10)
  • components/config-provider/context.ts (2 hunks)
  • components/config-provider/index.en-US.md (1 hunks)
  • components/config-provider/index.tsx (4 hunks)
  • components/config-provider/index.zh-CN.md (1 hunks)
  • components/qr-code/__tests__/index.test.tsx (1 hunks)
  • components/qr-code/demo/_semantic.tsx (1 hunks)
  • components/qr-code/index.en-US.md (1 hunks)
  • components/qr-code/index.tsx (3 hunks)
  • components/qr-code/index.zh-CN.md (1 hunks)
  • components/qr-code/interface.ts (2 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (3)
components/qr-code/index.tsx (1)
components/qr-code/interface.ts (1)
  • QRProps (8-8)
components/qr-code/interface.ts (1)
components/qr-code/index.tsx (2)
  • QRCodeProps (16-16)
  • QRProps (16-16)
components/qr-code/demo/_semantic.tsx (1)
.dumi/components/TemplateSemanticPreview.tsx (1)
  • locales (6-25)
🪛 Biome (1.9.4)
components/qr-code/index.tsx

[error] 120-120: Expected a statement but instead found '<<<<<<< HEAD'.

Expected a statement here.

(parse)


[error] 127-127: Unexpected token. Did you mean {'>'} or &gt;?

(parse)


[error] 127-127: Unexpected token. Did you mean {'>'} or &gt;?

(parse)


[error] 127-128: Unexpected token. Did you mean {'>'} or &gt;?

(parse)


[error] 128-128: Unexpected token. Did you mean {'>'} or &gt;?

(parse)


[error] 128-128: Unexpected token. Did you mean {'>'} or &gt;?

(parse)


[error] 128-128: Unexpected token. Did you mean {'>'} or &gt;?

(parse)


[error] 128-128: Unexpected token. Did you mean {'>'} or &gt;?

(parse)

🪛 GitHub Actions: Publish Any Commit
components/qr-code/index.tsx

[error] 44-44: error TS2339: Property 'className' does not exist on type 'ComponentReturnType'.


[error] 45-45: error TS2339: Property 'style' does not exist on type 'ComponentReturnType'.


[error] 48-48: error TS2345: Argument of type '"qrcode"' is not assignable to parameter of type 'keyof ConfigComponentProps'.


[error] 107-107: error TS2339: Property 'root' does not exist on type 'object | Partial<Record<SemanticName, string>> | SplitterSemanticClassNames | Partial<Record<SemanticName, string>> | ... 42 more ... | Partial<...>'.


[error] 116-116: error TS2339: Property 'root' does not exist on type 'object | Partial<Record<SemanticName, CSSProperties>> | Partial<Record<keyof SplitterSemanticClassNames, CSSProperties>> | ... 43 more ... | Partial<...>'.


[error] 130-130: error TS2339: Property 'mask' does not exist on type 'object | Partial<Record<SemanticName, string>> | SplitterSemanticClassNames | Partial<Record<SemanticName, string>> | ... 42 more ... | Partial<...>'.


[error] 134-134: error TS2339: Property 'mask' does not exist on type 'object | Partial<Record<SemanticName, CSSProperties>> | Partial<Record<keyof SplitterSemanticClassNames, CSSProperties>> | ... 43 more ... | Partial<...>'.

⏰ Context from checks skipped due to timeout of 90000ms (8)
  • GitHub Check: test-react-latest (dom, 2/2)
  • GitHub Check: test-react-latest (dom, 1/2)
  • GitHub Check: test-react-legacy (18, 2/2)
  • GitHub Check: test-react-legacy (18, 1/2)
  • GitHub Check: visual-diff snapshot (2/2)
  • GitHub Check: build preview
  • GitHub Check: visual-diff snapshot (1/2)
  • GitHub Check: size
🔇 Additional comments (21)
components/qr-code/index.zh-CN.md (1)

65-67: 文档新增了语义DOM部分,增强了组件的可访问性

这个新增的语义DOM部分很有用,它通过引用示例文件向用户展示了QRCode组件的DOM结构,这有助于理解组件的语义化标记和配置。

components/qr-code/index.en-US.md (1)

64-67: 文档新增了语义DOM部分,增强了组件的可访问性

这个新增的语义DOM部分很有用,它通过引用示例文件向用户展示了QRCode组件的DOM结构,这有助于理解组件的语义化标记和配置。

components/qr-code/demo/_semantic.tsx (2)

7-16: 良好的本地化实现

本地化对象的实现清晰明了,分别定义了中英文的根元素和遮罩层元素描述。


18-31: 组件实现清晰,演示了QRCode的语义结构

App组件使用了SemanticPreview来展示QRCode组件的语义结构,并设置了loading状态以展示遮罩层。这是一个很好的示例,向用户展示了如何通过ConfigProvider配置QRCode组件的样式和类名。

components/config-provider/context.ts (1)

40-40: 正确导入QRCodeProps类型

导入QRCodeProps类型用于后续QRcodeConfig类型定义,这是必要的步骤。

components/config-provider/index.tsx (4)

69-69: 导入必要的 QRcodeConfig 类型

导入 QRcodeConfig 类型用于 ConfigProvider 对 QRCode 组件的配置支持,符合其他组件的配置模式。


256-256: 为 ConfigProviderProps 接口添加 QRCode 配置项

将 QRCode 组件配置添加到 ConfigProviderProps 接口中,使开发者能够通过 ConfigProvider 全局配置 QRCode 组件。


405-405: 在 ProviderChildren 组件中解构 qrcode 属性

从 props 中解构 qrcode 属性,使其可在组件内部使用,遵循了组件参数处理的一致模式。


514-514: 将 qrcode 配置添加到 baseConfig 对象中

将 qrcode 配置添加到 baseConfig 对象中,确保配置能被正确传递给子组件。

components/qr-code/__tests__/index.test.tsx (1)

193-218: 添加自定义样式和类名的测试用例

新增测试用例验证 QRCode 组件能正确应用自定义样式和类名,测试覆盖了 root 和 mask 两个语义化 DOM 元素。测试用例设计合理,覆盖了类名和样式的应用检查。

components/qr-code/interface.ts (2)

22-22: 定义 QRCode 组件的语义化名称类型

新增 SemanticName 类型定义了 QRCode 组件的语义化 DOM 元素名称,目前只包含 'root' 和 'mask'。

考虑扩展语义化 DOM 元素,如之前评论提到的 'icon' 和 QR 码本体(Canvas 或 SVG)。这将提供更精细的样式自定义控制。


35-36: 为 QRCodeProps 接口添加语义化样式支持

新增 classNames 和 styles 属性使 QRCode 组件支持语义化样式定制,遵循了 Ant Design 组件的一致设计模式。

components/config-provider/index.zh-CN.md (2)

174-174: 添加 QRCode 组件的配置文档

为 ConfigProvider 文档添加了 QRCode 组件的配置说明,包括 className、style、classNames 和 styles 属性,并提供了指向语义化 DOM 的链接。


175-175: 恢复 Transfer 组件的配置文档

恢复了之前移除的 Transfer 组件配置文档,确保文档的完整性。

components/config-provider/index.en-US.md (2)

172-172: 添加 QR 码组件的配置支持

新增的 QR 码配置项与 API 文档其他组件保持一致,提供了常见的样式属性。这符合 PR 的目标:使 ConfigProvider 支持 QR 码组件的配置。


173-173: 恢复了 transfer 组件的配置说明

此行恢复了之前被移除的 transfer 组件配置项,确保文档的完整性。

components/qr-code/index.tsx (5)

1-1: 使用 useComponentConfig 代替直接使用 ConfigContext

使用 useComponentConfig 钩子函数替代了直接使用 ConfigContext,是更好的实践方式,使代码更加清晰和可维护。

Also applies to: 13-14


15-15: 导出类型定义以供外部使用

导出 QRCodePropsQRProps 类型,方便其他组件或外部使用这些类型定义。


36-37: 支持 classNames 和 styles 属性

添加了 classNamesstyles 属性,使 QR 码组件支持更灵活的样式定制,与其他组件保持一致。


99-111: 更新类名和样式处理逻辑

更新了类名和样式的处理逻辑,整合了从 ConfigProvider 上下文获取的配置,使组件能够响应全局配置。新的 rootClassNamesrootStyle 变量替代了之前的实现。

Also applies to: 113-121

🧰 Tools
🪛 GitHub Actions: Publish Any Commit

[error] 107-107: error TS2339: Property 'root' does not exist on type 'object | Partial<Record<SemanticName, string>> | SplitterSemanticClassNames | Partial<Record<SemanticName, string>> | ... 42 more ... | Partial<...>'.


124-136: 更新 DOM 结构中的类名和样式应用

更新了主 div 和遮罩 div 的类名和样式应用,使组件能够正确应用从 ConfigProvider 传递的配置。

🧰 Tools
🪛 Biome (1.9.4)

[error] 127-127: Unexpected token. Did you mean {'>'} or &gt;?

(parse)


[error] 127-127: Unexpected token. Did you mean {'>'} or &gt;?

(parse)


[error] 127-128: Unexpected token. Did you mean {'>'} or &gt;?

(parse)


[error] 128-128: Unexpected token. Did you mean {'>'} or &gt;?

(parse)


[error] 128-128: Unexpected token. Did you mean {'>'} or &gt;?

(parse)


[error] 128-128: Unexpected token. Did you mean {'>'} or &gt;?

(parse)


[error] 128-128: Unexpected token. Did you mean {'>'} or &gt;?

(parse)

🪛 GitHub Actions: Publish Any Commit

[error] 130-130: error TS2339: Property 'mask' does not exist on type 'object | Partial<Record<SemanticName, string>> | SplitterSemanticClassNames | Partial<Record<SemanticName, string>> | ... 42 more ... | Partial<...>'.


[error] 134-134: error TS2339: Property 'mask' does not exist on type 'object | Partial<Record<SemanticName, CSSProperties>> | Partial<Record<keyof SplitterSemanticClassNames, CSSProperties>> | ... 43 more ... | Partial<...>'.

coderabbitai[bot]
coderabbitai bot previously approved these changes Apr 9, 2025
@codecov
Copy link

codecov bot commented Apr 9, 2025

Bundle Report

Changes will increase total bundle size by 316 bytes (0.01%) ⬆️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
antd.min-array-push 3.73MB 316 bytes (0.01%) ⬆️

Affected Assets, Files, and Routes:

view changes for bundle: antd.min-array-push

Assets Changed:

Asset Name Size Change Total Size Change (%)
antd-with-locales.min.js 158 bytes 2.05MB 0.01%
antd.min.js 158 bytes 1.68MB 0.01%

Files in antd-with-locales.min.js:

  • ./components/config-provider/context.ts → Total Size: 1.52kB

  • ./components/qr-code/style/index.ts → Total Size: 1.99kB

Files in antd.min.js:

  • ./components/qr-code/style/index.ts → Total Size: 1.99kB

  • ./components/config-provider/context.ts → Total Size: 1.52kB

@thinkasany
Copy link
Member Author

@coderabbitai

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Apr 9, 2025

Tip

For best results, initiate chat on the files or code changes.

@thinkasany Hi there! I noticed you tagged me but didn't include a specific question or request.

I see this PR adds QRCode support to the ConfigProvider component, allowing for customization of QRCode styling through the ConfigProvider. The changes look comprehensive, including type definitions, updated component logic, documentation, and tests.

How can I help you with this PR? I can:

  • Provide more detailed code analysis
  • Generate additional test cases
  • Help optimize the implementation
  • Create documentation examples
  • Assist with any specific questions you have

Just let me know what you need!

(_/)
(•ㅅ•)
/

🔍 Curiously awaiting your instructions!

@thinkasany
Copy link
Member Author

Tip

For best results, initiate chat on the files or code changes.

@thinkasany Hi there! I noticed you tagged me but didn't include a specific question or request.

I see this PR adds QRCode support to the ConfigProvider component, allowing for customization of QRCode styling through the ConfigProvider. The changes look comprehensive, including type definitions, updated component logic, documentation, and tests.

How can I help you with this PR? I can:

  • Provide more detailed code analysis
  • Generate additional test cases
  • Help optimize the implementation
  • Create documentation examples
  • Assist with any specific questions you have

Just let me know what you need!

(_/) (•ㅅ•) /

🔍 Curiously awaiting your instructions!

please review again~

@thinkasany
Copy link
Member Author

thinkasany commented Apr 9, 2025

@coderabbitai, review again. CodeRabbit
CodeRabbit — Internal error occurred during review

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Apr 9, 2025

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Let's get a better understanding of the PR changes
echo "### Examining PR changes"
git log -1
echo ""

# Check the changes to the config-provider context file
echo "### Changes to config-provider/context.ts"
cat components/config-provider/context.ts | grep -A 10 QRcodeConfig

# Check the changes to the QRCode component
echo "### Changes to QRCode component interface"
cat components/qr-code/interface.ts | grep -A 10 SemanticName

# Check the test coverage for the QRCode component
echo "### Tests for QRCode component"
cat components/qr-code/__tests__/index.test.tsx | grep -A 30 "should apply custom styles"

# Check the implementation of how ConfigProvider is used in QRCode
echo "### How ConfigProvider is used in QRCode"
cat components/qr-code/index.tsx | grep -A 10 useComponentConfig

# Check the documentation updates
echo "### Documentation updates for QRCode component"
cat components/qr-code/index.en-US.md | grep -A 5 "Semantic DOM"

Length of output: 3961


@thinkasany I've reviewed your PR that adds QRCode support to ConfigProvider, and it looks well-implemented! Here's my review:

Strengths

  • Well-typed: The QRcodeConfig type and SemanticName additions follow Ant Design's typing patterns
  • Proper integration: Using useComponentConfig hook connects QRCode properly to the ConfigProvider
  • Good test coverage: The test case for custom styles thoroughly verifies both class names and style properties
  • Documentation: Added the "Semantic DOM" section with proper example

Implementation

The PR follows Ant Design's established component styling pattern by:

  1. Defining semantic elements ('root' and 'mask')
  2. Supporting both direct props and ConfigProvider customization
  3. Using the component config hook system

Conclusion

This is a solid implementation that brings QRCode in line with other components in the library that can be styled through ConfigProvider. The changes are minimal but effective, adding valuable functionality without unnecessary complexity.

The PR is ready to be merged from a code quality perspective. Great job!

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Apr 9, 2025

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

@thinkasany I've thoroughly reviewed your PR that adds QRCode support to ConfigProvider. This is a comprehensive and well-executed implementation:

Strengths

  • Well-structured types:

    • The SemanticName type properly identifies the QRCode component parts ('root' and 'mask')
    • QRcodeConfig follows Ant Design's pattern for component configuration
  • Proper integration with ConfigProvider:

    • Uses the useComponentConfig hook following the established pattern
    • Correctly merges styles and classNames from both props and context
  • Complete test coverage:

    • Test case verifies both custom class names and style properties are applied
    • Validates styling for both root and mask elements
  • Documentation updates:

    • Added "Semantic DOM" sections in both English and Chinese
    • Created semantic demo component for reference

Implementation Quality

Your implementation follows Ant Design's established patterns by:

  1. Defining clear semantic elements
  2. Supporting configuration through both direct props and ConfigProvider
  3. Maintaining consistent typing patterns with the rest of the library
  4. Updating documentation in all relevant files

Conclusion

This PR successfully extends ConfigProvider to support QRCode component styling in a clean, type-safe manner that matches Ant Design's conventions. The integration is seamless and the changes are focused on exactly what's needed.

The code is ready for merging. Nice work!


🏁 Script executed:

#!/bin/bash
# Let's examine the main files modified in this PR to understand the changes better

# Check the QRCode interface changes
echo "### QRCode Interface Changes"
cat components/qr-code/interface.ts

# Check the ConfigProvider context changes
echo "### ConfigProvider Context Changes"
cat components/config-provider/context.ts

# Check the QRCode component implementation
echo "### QRCode Component Implementation"
cat components/qr-code/index.tsx

# Check the new tests added
echo "### QRCode Tests"
cat components/qr-code/__tests__/index.test.tsx

# Check the ConfigProvider implementation changes
echo "### ConfigProvider Implementation Changes"
cat components/config-provider/index.tsx

# Check the documentation changes
echo "### QRCode Documentation - English"
cat components/qr-code/index.en-US.md

# Check the documentation changes in Chinese
echo "### QRCode Documentation - Chinese"
cat components/qr-code/index.zh-CN.md

# Check the semantic demo
echo "### QRCode Semantic Demo"
cat components/qr-code/demo/_semantic.tsx

Length of output: 56558


@thinkasany I've completed a thorough review of your PR that adds QRCode support to ConfigProvider. This is an excellent implementation that follows Ant Design's established patterns perfectly.

Key Strengths

  • Well-designed type structure: The SemanticName type and extended QRCodeProps interface follow Ant Design's conventions for semantic styling

  • Proper ConfigProvider integration: The implementation correctly uses the useComponentConfig hook and merges styles/classNames from both props and context

  • Complete semantic structure: Clearly defined 'root' and 'mask' elements with appropriate styling support

  • Thorough test coverage: The tests verify that custom styles and classNames are correctly applied to all semantic elements

  • Well-documented: Added "Semantic DOM" section to documentation and created a helpful demo component

Implementation Details

The changes follow the same pattern used for other components in Ant Design:

  1. Define semantic elements ('root' and 'mask')
  2. Create a config type that extends ComponentStyleConfig
  3. Add the config type to ConfigProviderProps
  4. Use useComponentConfig in the component to access the configuration
  5. Properly merge styles and classNames from both props and context

Conclusion

This PR is well-implemented, fully tested, and properly documented. It brings the QRCode component in line with other components that support styling through ConfigProvider, enhancing the component's flexibility and consistency with the rest of the library.

The code is ready to be merged. Great work!

const locales = {
cn: {
root: '根元素',
mask: '遮罩层元素',
Copy link
Member

Choose a reason for hiding this comment

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

 按照 Image 的名称的话,这个可能叫 cover 会更好一些

coderabbitai[bot]
coderabbitai bot previously approved these changes Apr 9, 2025
coderabbitai[bot]
coderabbitai bot previously approved these changes Apr 9, 2025
coderabbitai[bot]
coderabbitai bot previously approved these changes Apr 10, 2025
* @descEN Mask background color of QRCode
*/
QRCodeCoverBackgroundColor: string;
/** @deprecated Please use `QRCodeCoverBackgroundColor` instead */
Copy link
Member

Choose a reason for hiding this comment

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

不是 Component Token 可以直接删了

@thinkasany thinkasany merged commit f3cebe3 into ant-design:next Apr 10, 2025
40 checks passed
@coderabbitai coderabbitai bot mentioned this pull request Aug 11, 2025
4 tasks
@Wxh16144 Wxh16144 changed the title feat: ConfigProvider support qrcode feat(QRCode): support ConfigProvider Nov 28, 2025
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.

3 participants