Skip to content

feat: support classNames and styles #638

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

Merged
merged 2 commits into from
Mar 21, 2025
Merged

Conversation

thinkasany
Copy link
Contributor

@thinkasany thinkasany commented Mar 20, 2025

Summary by CodeRabbit

  • 新功能

    • 为下拉树选择组件新增了自定义样式与类名的支持,方便用户对界面外观进行个性化定制。
  • Chores

    • 升级关键依赖库至最新补丁版本,以提升整体稳定性和兼容性。

Copy link

vercel bot commented Mar 20, 2025

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

Name Status Preview Comments Updated (UTC)
tree-select ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 21, 2025 3:01am

Copy link

coderabbitai bot commented Mar 20, 2025

Walkthrough

此次更改在 package.json 中更新了 @rc-component/select@rc-component/tree 的补丁版本,同时在 OptionListTreeSelect 组件中增加了 classNamesstyles 属性的支持,这些属性可从上下文传递,以便组件能够自定义样式。此外,TreeSelectContext 接口中新增了 SemanticName 类型及相关属性,以便对传入的样式和类名进行语义化管理。

Changes

文件 变更摘要
package.json 更新依赖:@rc-component/select~1.0.0 升级到 ~1.0.2@rc-component/tree~1.0.0 升级到 ~1.0.1
src/OptionList.tsx、src/TreeSelect.tsx 为组件新增 classNamesstyles 属性,通过上下文或 props 传递,实现组件样式与类名的自定义
src/TreeSelectContext.ts 新增 SemanticName 类型,并扩展 TreeSelectContextProps 接口,添加支持 classNamesstyles 属性

Sequence Diagram(s)

sequenceDiagram
    participant App
    participant TreeSelect
    participant Context
    participant OptionList
    participant Tree

    App->>TreeSelect: 传入 props (classNames, styles)
    TreeSelect->>Context: 创建并传递上下文 (包含 classNames, styles)
    Context->>OptionList: 提供上下文数据
    OptionList->>Tree: 传递 classNames 与 styles 属性
Loading

Possibly related PRs

Poem

我是一只代码园中的小兔子,
跳跃间传递着 class 与 style 的讯息,
补丁升级带来春风般的清新,
上下文中轻盈飞舞的定制梦,
代码世界因我而生动 🐇

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/TreeSelectContext.ts

Oops! Something went wrong! :(

ESLint: 8.57.1

ESLint couldn't find the config "prettier" to extend from. Please check that the name of the config is correct.

The config "prettier" was referenced from the config file in "/.eslintrc.js".

If you still have problems, please stop by https://eslint.org/chat/help to chat with the team.

tests/Select.spec.tsx

Oops! Something went wrong! :(

ESLint: 8.57.1

ESLint couldn't find the config "prettier" to extend from. Please check that the name of the config is correct.

The config "prettier" was referenced from the config file in "/.eslintrc.js".

If you still have problems, please stop by https://eslint.org/chat/help to chat with the team.


📜 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 459a57a and 48d51c5.

📒 Files selected for processing (2)
  • src/TreeSelectContext.ts (2 hunks)
  • tests/Select.spec.tsx (1 hunks)
🧰 Additional context used
🧬 Code Definitions (1)
tests/Select.spec.tsx (1)
examples/basic.tsx (1) (1)
  • render (139-383)
🔇 Additional comments (3)
src/TreeSelectContext.ts (2)

6-6: 清晰的语义化类型定义

通过定义 SemanticName 类型,您为不同 UI 组件部分提供了语义化的命名,这有助于保持样式应用的一致性。该类型的命名具有描述性,值的定义也很清晰,使代码更具可读性。


25-26: 完善的样式和类名支持

添加的 stylesclassNames 属性使组件具有更高的可定制性,允许用户根据语义名称为组件的不同部分应用样式和类名。这种方法比直接应用内联样式更加灵活,也更符合 React 组件的设计原则。通过使用部分记录类型,您还保持了接口的灵活性,使用户可以只定义需要自定义的部分。

tests/Select.spec.tsx (1)

642-707: 完整的样式和类名测试用例

这个测试用例全面验证了 TreeSelect 组件对自定义样式和类名的支持。测试中包含了所有语义化部分(前缀、输入框、后缀、项目和项目标题),并确认了这些自定义样式和类名被正确应用。测试结构清晰,使用了断言来验证类名和样式的应用情况,这确保了组件的样式定制功能按预期工作。

测试数据的准备也很完善,使用了嵌套结构的树数据,这更接近实际使用场景。这种测试不仅验证了功能的正确性,还有助于防止未来的代码修改破坏这一功能。

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

@thinkasany thinkasany changed the title draft feat: support classNames and styles Mar 21, 2025
Copy link

codecov bot commented Mar 21, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.83%. Comparing base (f0d4350) to head (48d51c5).
Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #638   +/-   ##
=======================================
  Coverage   99.83%   99.83%           
=======================================
  Files          16       16           
  Lines         593      593           
  Branches      186      186           
=======================================
  Hits          592      592           
  Misses          1        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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@zombieJ zombieJ merged commit 8ef983a into react-component:master Mar 21, 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