feat(QRCode): support ConfigProvider#52172
Conversation
|
|
👁 Visual Regression Report for PR #52172 Passed ✅
🎊 Congrats! No visual-regression diff found.
|
WalkthroughThis 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
|
| 'className' | 'style' | 'styles' | 'classNames' | ||
| >; | ||
|
|
||
| export type QRcodeConfig = ComponentStyleConfig & Pick<QRCodeProps, 'classNames' | 'styles'>; |
There was a problem hiding this comment.
Ensure that the QRcodeConfig type correctly extends ComponentStyleConfig and includes only the necessary properties from QRCodeProps. This helps maintain type safety and clarity.
More templates
commit: |
Codecov ReportAll modified and coverable lines are covered by tests ✅
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. 🚀 New features to boost your workflow:
|
components/qr-code/interface.ts
Outdated
| statusRender?: (info: StatusRenderInfo) => ReactNode; | ||
| classNames?: { | ||
| root?: string; | ||
| mask?: string; |
There was a problem hiding this comment.
感觉有点少,比如 icon,还有 qrcode 本体(Canvas or SVG) 都没有
📝 WalkthroughSummary by CodeRabbit
Walkthrough此次修改在配置提供者中增加了对 QR 码组件配置的新类型和相关文档更新。新增了 Changes
Possibly related PRs
Suggested reviewers
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms (11)
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
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
📒 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 >?
(parse)
[error] 127-127: Unexpected token. Did you mean {'>'} or >?
(parse)
[error] 127-128: Unexpected token. Did you mean {'>'} or >?
(parse)
[error] 128-128: Unexpected token. Did you mean {'>'} or >?
(parse)
[error] 128-128: Unexpected token. Did you mean {'>'} or >?
(parse)
[error] 128-128: Unexpected token. Did you mean {'>'} or >?
(parse)
[error] 128-128: Unexpected token. Did you mean {'>'} or >?
(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: 导出类型定义以供外部使用导出
QRCodeProps和QRProps类型,方便其他组件或外部使用这些类型定义。
36-37: 支持 classNames 和 styles 属性添加了
classNames和styles属性,使 QR 码组件支持更灵活的样式定制,与其他组件保持一致。
99-111: 更新类名和样式处理逻辑更新了类名和样式的处理逻辑,整合了从 ConfigProvider 上下文获取的配置,使组件能够响应全局配置。新的
rootClassNames和rootStyle变量替代了之前的实现。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>?(parse)
[error] 127-127: Unexpected token. Did you mean
{'>'}or>?(parse)
[error] 127-128: Unexpected token. Did you mean
{'>'}or>?(parse)
[error] 128-128: Unexpected token. Did you mean
{'>'}or>?(parse)
[error] 128-128: Unexpected token. Did you mean
{'>'}or>?(parse)
[error] 128-128: Unexpected token. Did you mean
{'>'}or>?(parse)
[error] 128-128: Unexpected token. Did you mean
{'>'}or>?(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<...>'.
Bundle ReportChanges will increase total bundle size by 316 bytes (0.01%) ⬆️. This is within the configured threshold ✅ Detailed changes
Affected Assets, Files, and Routes:view changes for bundle: antd.min-array-pushAssets Changed:
Files in
Files in
|
|
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:
Just let me know what you need! (_/)
|
please review again~ |
|
@coderabbitai, review again. CodeRabbit |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: 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
ImplementationThe PR follows Ant Design's established component styling pattern by:
ConclusionThis 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! |
|
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
Implementation QualityYour implementation follows Ant Design's established patterns by:
ConclusionThis 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: 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
Implementation DetailsThe changes follow the same pattern used for other components in Ant Design:
ConclusionThis 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: '遮罩层元素', |
There was a problem hiding this comment.
按照 Image 的名称的话,这个可能叫 cover 会更好一些
components/qr-code/style/index.ts
Outdated
| * @descEN Mask background color of QRCode | ||
| */ | ||
| QRCodeCoverBackgroundColor: string; | ||
| /** @deprecated Please use `QRCodeCoverBackgroundColor` instead */ |



🤔 This is a ...
🔗 Related Issues
📝 Change Log