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: semantic support content、body #922

Merged
merged 2 commits into from
Mar 19, 2025
Merged

Conversation

thinkasany
Copy link
Contributor

@thinkasany thinkasany commented Mar 14, 2025

Summary by CodeRabbit

  • 新功能
    • 为选择器组件增加了对自定义样式和类名的支持,提升了弹出层、主体和内容区的外观定制能力。
  • 测试
    • 更新了测试用例,确保选择器组件正确应用自定义样式和类名。

Copy link

vercel bot commented Mar 14, 2025

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

Name Status Preview Comments Updated (UTC)
picker ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 19, 2025 3:50am

Copy link

coderabbitai bot commented Mar 14, 2025

Walkthrough

本次变更主要是为 Picker 组件系统添加对样式(styles)和类名(classNames)的支持。更新涉及 PickerInput、PickerPanel 以及相关上下文接口,通过在 context 对象中引入新的属性,并同步更新 memo 化依赖项,确保样式信息能动态传递给子组件。同时更新了 SemanticStructure 类型以支持更多语义,同时扩展了测试用例以验证这些新功能。

Changes

文件路径 变更摘要
src/PickerInput/RangePicker.tsx
src/PickerInput/SinglePicker.tsx
src/PickerInput/context.tsx
在 RangePicker 和 SinglePicker 中添加了 stylesclassNames 到 context;更新了 context 类型定义(PickerContextProps)以支持这两个新属性,并调整了 useMemo 依赖项。
src/PickerPanel/PanelBody.tsx
src/PickerPanel/context.ts
src/PickerPanel/index.tsx
修改 Panel 组件对 context 的消费方式,更新了相关接口(PickerHackContextProps)和 memo 化逻辑,以接收并使用 stylesclassNames 属性,提升样式动态处理能力。
src/interface.tsx 扩展了 SemanticStructure 类型,从 'popup' 扩展为 `'popup'
tests/picker.spec.tsx 测试用例更新:移除了原有的 classNames.popup 测试,新增了 support classNames and styles 测试,验证 DayPicker 组件上自定义类名和样式的应用。

Sequence Diagram(s)

sequenceDiagram
    participant P as Picker组件
    participant C as PickerContext.Provider
    participant S as 子组件
    P->>C: 提供包含 prefixCls, styles, classNames 的 context
    C->>S: 传递 context,子组件消费并应用样式
Loading

Possibly related PRs

Poem

噢,我跳跃在代码的草原上,🐰
新加入的样式如鲜花盛放,
classNames 编织起梦幻的网,
每一行代码都是跳动的心,
在开发的世界里,我欢快歌唱。
让变更闪耀,让设计飞扬。
Happy coding!🌸

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.

src/PickerPanel/PanelBody.tsx

Oops! Something went wrong! :(

ESLint: 8.57.1

Error: Cannot read config file: /.eslintrc.js
Error: Cannot find module '@umijs/fabric/dist/eslint'
Require stack:

  • /.eslintrc.js
  • /node_modules/.pnpm/@eslint+eslintrc@2.1.4/node_modules/@eslint/eslintrc/dist/eslintrc.cjs
  • /node_modules/.pnpm/eslint@8.57.1/node_modules/eslint/lib/cli-engine/cli-engine.js
  • /node_modules/.pnpm/eslint@8.57.1/node_modules/eslint/lib/eslint/eslint.js
  • /node_modules/.pnpm/eslint@8.57.1/node_modules/eslint/lib/eslint/index.js
  • /node_modules/.pnpm/eslint@8.57.1/node_modules/eslint/lib/cli.js
  • /node_modules/.pnpm/eslint@8.57.1/node_modules/eslint/bin/eslint.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:1248:15)
    at Function.resolve (node:internal/modules/helpers:145:19)
    at Object. (/.eslintrc.js:2:21)
    at Module._compile (node:internal/modules/cjs/loader:1546:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1691:10)
    at Module.load (node:internal/modules/cjs/loader:1317:32)
    at Module._load (node:internal/modules/cjs/loader:1127:12)
    at TracingChannel.traceSync (node:diagnostics_channel:315:14)
    at wrapModuleLoad (node:internal/modules/cjs/loader:217:24)
    at Module.require (node:internal/modules/cjs/loader:1339:12)
src/interface.tsx

Oops! Something went wrong! :(

ESLint: 8.57.1

Error: Cannot read config file: /.eslintrc.js
Error: Cannot find module '@umijs/fabric/dist/eslint'
Require stack:

  • /.eslintrc.js
  • /node_modules/.pnpm/@eslint+eslintrc@2.1.4/node_modules/@eslint/eslintrc/dist/eslintrc.cjs
  • /node_modules/.pnpm/eslint@8.57.1/node_modules/eslint/lib/cli-engine/cli-engine.js
  • /node_modules/.pnpm/eslint@8.57.1/node_modules/eslint/lib/eslint/eslint.js
  • /node_modules/.pnpm/eslint@8.57.1/node_modules/eslint/lib/eslint/index.js
  • /node_modules/.pnpm/eslint@8.57.1/node_modules/eslint/lib/cli.js
  • /node_modules/.pnpm/eslint@8.57.1/node_modules/eslint/bin/eslint.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:1248:15)
    at Function.resolve (node:internal/modules/helpers:145:19)
    at Object. (/.eslintrc.js:2:21)
    at Module._compile (node:internal/modules/cjs/loader:1546:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1691:10)
    at Module.load (node:internal/modules/cjs/loader:1317:32)
    at Module._load (node:internal/modules/cjs/loader:1127:12)
    at TracingChannel.traceSync (node:diagnostics_channel:315:14)
    at wrapModuleLoad (node:internal/modules/cjs/loader:217:24)
    at Module.require (node:internal/modules/cjs/loader:1339:12)
tests/picker.spec.tsx

Oops! Something went wrong! :(

ESLint: 8.57.1

Error: Cannot read config file: /.eslintrc.js
Error: Cannot find module '@umijs/fabric/dist/eslint'
Require stack:

  • /.eslintrc.js
  • /node_modules/.pnpm/@eslint+eslintrc@2.1.4/node_modules/@eslint/eslintrc/dist/eslintrc.cjs
  • /node_modules/.pnpm/eslint@8.57.1/node_modules/eslint/lib/cli-engine/cli-engine.js
  • /node_modules/.pnpm/eslint@8.57.1/node_modules/eslint/lib/eslint/eslint.js
  • /node_modules/.pnpm/eslint@8.57.1/node_modules/eslint/lib/eslint/index.js
  • /node_modules/.pnpm/eslint@8.57.1/node_modules/eslint/lib/cli.js
  • /node_modules/.pnpm/eslint@8.57.1/node_modules/eslint/bin/eslint.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:1248:15)
    at Function.resolve (node:internal/modules/helpers:145:19)
    at Object. (/.eslintrc.js:2:21)
    at Module._compile (node:internal/modules/cjs/loader:1546:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1691:10)
    at Module.load (node:internal/modules/cjs/loader:1317:32)
    at Module._load (node:internal/modules/cjs/loader:1127:12)
    at TracingChannel.traceSync (node:diagnostics_channel:315:14)
    at wrapModuleLoad (node:internal/modules/cjs/loader:217:24)
    at Module.require (node:internal/modules/cjs/loader:1339:12)

Tip

⚡🧪 Multi-step agentic review comment chat (experimental)
  • We're introducing multi-step agentic chat in review comments. This experimental feature enhances review discussions with the CodeRabbit agentic chat by enabling advanced interactions, including the ability to create pull requests directly from comments.
    - To enable this feature, set early_access to true under in the settings.

📜 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 4a8fe32 and 7e317f7.

📒 Files selected for processing (3)
  • src/PickerPanel/PanelBody.tsx (2 hunks)
  • src/interface.tsx (1 hunks)
  • tests/picker.spec.tsx (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/PickerPanel/PanelBody.tsx
🧰 Additional context used
🧬 Code Definitions (1)
tests/picker.spec.tsx (2)
docs/examples/customize.tsx (1) (1)
  • render (103-175)
tests/util/commonUtil.tsx (1) (1)
  • DayPicker (168-173)
🔇 Additional comments (3)
src/interface.tsx (2)

284-284: 扩展 SemanticStructure 类型定义以增强样式自定义支持

根据变更,SemanticStructure 类型现在包含了 'popup''popupBody''popupContent' 三个值,为组件的语义化结构提供了更细粒度的样式控制能力。这与之前的评论提问相符,并使样式和类名可以更精确地应用于弹出层的不同部分。


331-332: 新增 styles 和 classNames 属性以支持语义化样式定制

这两个新属性允许用户为不同的语义结构部分(如 popup、popupBody 和 popupContent)分别定制样式和类名。这种设计遵循了组件库常见的样式自定义模式,既增强了组件的可定制性,又保持了代码结构的清晰。

tests/picker.spec.tsx (1)

1352-1373: 完善测试用例以验证样式和类名的自定义功能

新增的测试用例验证了 Picker 组件对自定义样式和类名的支持,包括 popup、popupBody 和 popupContent 三个语义部分。测试检查了类名的正确应用以及样式属性的生效,这与 interface.tsxSemanticStructure 类型的扩展对应,确保了新功能的正确实现。

测试用例结构清晰,覆盖了所有新增的语义结构,是一个很好的单元测试示例。

✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 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 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.

@@ -281,7 +281,7 @@ export type Components<DateType extends object = any> = Partial<
>;

// ========================= Picker =========================
export type SemanticStructure = 'popup';
export type SemanticStructure = 'popup' | 'body' | 'content';
Copy link
Member

Choose a reason for hiding this comment

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

popupBody & popupContent?

@@ -281,7 +281,7 @@ export type Components<DateType extends object = any> = Partial<
>;

// ========================= Picker =========================
export type SemanticStructure = 'popup';
export type SemanticStructure = 'popup' | 'popupBody' | 'popupContent';
Copy link
Member

Choose a reason for hiding this comment

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

Header 和 Footer 要不要一起加了,另外还有个问题是 DateTime 这种组合是怎么处理的?
截屏2025-03-19 14 21 46

Copy link
Contributor Author

Choose a reason for hiding this comment

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

calendar 的header是内部自定义的,好像只需要content、body 就足够完成 calendar 的语义化了。 当时看到 日历组件比较复杂,还没想到比较好的解法,想着也先往后放放,先把好做的都做掉先。
https://github.com/ant-design/ant-design/pull/53159/files#diff-841e97dfb23daba72a34ee15810c8b36da6464eba16e120739ec6c9636f94fb2L287

Copy link

codecov bot commented Mar 19, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.79%. Comparing base (4f14121) to head (7e317f7).
Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #922   +/-   ##
=======================================
  Coverage   98.79%   98.79%           
=======================================
  Files          64       64           
  Lines        2651     2652    +1     
  Branches      736      710   -26     
=======================================
+ Hits         2619     2620    +1     
  Misses         29       29           
  Partials        3        3           

☔ 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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@zombieJ zombieJ merged commit 74b0494 into react-component:master Mar 19, 2025
9 checks passed
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.

2 participants