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: tab support classnames and styles #786

Merged
merged 2 commits into from
Feb 20, 2025

Conversation

thinkasany
Copy link
Contributor

@thinkasany thinkasany commented Feb 20, 2025

Summary by CodeRabbit

  • 新增功能

    • 添加了用于自定义选项卡内容区域外观的配置选项,允许用户设置样式与样式类。
    • 扩展了组件语义标签,进一步增强了个性化定制能力。
  • 测试

    • 更新了测试用例,验证自定义样式和样式类的应用效果,确保组件外观调整正常显示。

Copy link

vercel bot commented Feb 20, 2025

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

Name Status Preview Comments Updated (UTC)
tabs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 20, 2025 9:16am

Copy link

coderabbitai bot commented Feb 20, 2025

Walkthrough

该变更在 Tabs 组件及其子组件 TabPanelList 中增加了自定义内容的样式和类名支持。通过在各接口中添加新的可选属性(contentStylecontentClassName),Tabs 组件能够将这些属性传递给 TabPanelList,后者再将其应用到 TabPane 上。同时,语义类型 SemanticName 扩展为包含 "content",并在测试用例中增加了验证相关属性的断言。

Changes

文件 变更摘要
src/TabPanelList/index.tsx 添加 contentStylecontentClassNameTabPanelListProps 接口;更新 TabPanestyleclassName 属性以使用新的属性
src/Tabs.tsx 扩展 SemanticName 类型添加 "content";更新 TabsProps 接口添加 contentStylecontentClassName;调整 indicator 属性传递方式
tests/index.test.tsx 测试用例中新增 customStyles.contentcustomClassNames.content,验证内容区域样式和类名

Sequence Diagram(s)

sequenceDiagram
    participant U as 用户
    participant T as Tabs
    participant P as TabPanelList
    participant C as TabPane
    U->>T: 渲染 Tabs 组件
    T->>P: 传递 contentStyle, contentClassName, indicator 等属性
    P->>C: 应用 contentStyle 和 contentClassName
    C-->>P: 渲染内容区域
    P-->>T: 返回渲染结果
    T-->>U: 显示自定义样式的 Tabs
Loading

Possibly related PRs

Suggested reviewers

  • zombieJ

Poem

我是一只小兔,
蹦跳在代码中,
新增的样式和类名,
如春风般温柔轻动,
像报春的花朵闪耀 🐇✨

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/TabNavList/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]_jest@29.7.0_@types[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.

src/Tabs.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]_jest@29.7.0_@types[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.

tests/index.test.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]_jest@29.7.0_@types[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.


📜 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 da71618 and 362e00e.

📒 Files selected for processing (3)
  • src/TabNavList/index.tsx (1 hunks)
  • src/Tabs.tsx (3 hunks)
  • tests/index.test.tsx (2 hunks)
✅ Files skipped from review due to trivial changes (1)
  • src/TabNavList/index.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • tests/index.test.tsx
🔇 Additional comments (3)
src/Tabs.tsx (3)

37-37: 扩展了 SemanticName 类型定义

SemanticName 类型新增了 'content' 和 'header' 选项,这样可以更精细地控制不同部分的样式和类名。


189-189: 优化了 indicator 属性的传递

indicator 属性从 tabNavBarProps 中独立出来传递给子组件,这样的结构更清晰。


215-216:

❓ Verification inconclusive

新增了内容区域的样式自定义支持

通过 contentStylecontentClassName 属性,可以自定义 TabPanelList 的内容区域样式。建议在组件文档中添加这些新属性的使用说明。

请运行以下脚本检查是否有相关的文档更新:


🏁 Script executed:

#!/bin/bash
# 检查是否有相关的文档更新
rg -l "contentStyle|contentClassName" docs/

Length of output: 45


请注意:组件文档中未发现对 contentStylecontentClassName 属性的说明

src/Tabs.tsx 文件的第 215-216 行新增了通过 contentStylecontentClassName 自定义 TabPanelList 内容区域样式的支持,但在 docs/ 目录下未搜索到这两个属性的相关文档更新。请开发者手动核实是否已在其他文档(如 README.md 或组件文档)中补充了这些属性的使用说明;如果未更新,请及时完善文档。


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ 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.
    • 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. (Beta)
  • @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.

Copy link

codecov bot commented Feb 20, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.96%. Comparing base (1bc44a5) to head (362e00e).
Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #786   +/-   ##
=======================================
  Coverage   98.96%   98.96%           
=======================================
  Files          18       18           
  Lines         772      772           
  Branches      227      220    -7     
=======================================
  Hits          764      764           
  Misses          8        8           

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

@zombieJ zombieJ merged commit 7d5b243 into react-component:master Feb 20, 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