Skip to content

Conversation

@li-jia-nan
Copy link
Member

@li-jia-nan li-jia-nan commented Sep 27, 2025

Summary by CodeRabbit

  • 重构
    • 全面切换为 clsx 进行样式类名组合,覆盖表格主体、表头、虚拟滚动、行信息、展开行等模块;功能与渲染结果保持一致,公开 API 无变更。
  • 文档
    • 示例页面同步替换为 clsx,交互与展示无差异。
  • 杂务
    • 依赖调整:移除 classnames,引入 clsx,并更新依赖关系。

@vercel
Copy link

vercel bot commented Sep 27, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
table Ready Ready Preview Comment Sep 27, 2025 5:34pm

@coderabbitai
Copy link

coderabbitai bot commented Sep 27, 2025

Walkthrough

将依赖与代码中的 classNames 用法统一替换为 clsx:更新 package.json 依赖,批量修改 docs 示例与 src 下各组件、hook、工具中的 className 组合函数,未改动控制流或公开 API。

Changes

Cohort / File(s) Change Summary
依赖调整
package.json
移除依赖 "classnames",新增依赖 "clsx";对外依赖图变更为使用 clsx。
文档示例
docs/examples/animation.tsx, docs/examples/virtual-list-grid.tsx, docs/examples/virtual-list.tsx
将 classNames(...) 替换为 clsx(...);仅影响 className 组合。
表格主体与单元格
src/Body/index.tsx, src/Body/BodyRow.tsx, src/Cell/index.tsx, src/FixedHolder/index.tsx
统一导入 clsx;将所有 classNames/cls(...) 改为 clsx(...);逻辑与渲染结构不变。
表格骨架与容器
src/Table.tsx
用 clsx 替换 classNames;合并 content style 为单一展开对象;不改变行为。
虚拟表格相关
src/VirtualTable/index.tsx, src/VirtualTable/BodyLine.tsx, src/VirtualTable/VirtualCell.tsx
以 clsx 取代 classNames 进行类名合并;无控制流变更。
Hooks 与工具
src/hooks/useRowInfo.tsx, src/utils/expandUtil.tsx, src/stickyScrollBar.tsx
将 classNames 替换为 clsx 用于行、展开图标与滚动条类名计算。

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested reviewers

  • afc163
  • zombieJ
  • MadCcc

Poem

小兔叁跳敲代码,
classNames 悄然挥手 bye~
clsx 轻装上阵来,
行列样式不更改。
依赖一换风更简,
嗖——表格依旧快与帅。 🐇✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed 这个标题简洁明了地概括了移除 classnames 并安装 clsx 的核心改动,与代码中大范围替换 classnames 为 clsx 的内容高度一致。
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch clsx-update

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @li-jia-nan, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request focuses on a performance optimization by migrating from the classnames utility library to clsx. This change aims to reduce bundle size and improve runtime performance when dynamically generating CSS class strings in React components, affecting various parts of the codebase where class names are constructed.

Highlights

  • Dependency Swap: Replaced the classnames library with clsx for improved performance and smaller bundle size.
  • Codebase Update: All instances of classnames and cls function calls across various .tsx files have been updated to use clsx.
  • Package Management: The package.json file has been updated to reflect the uninstallation of classnames and the installation of clsx.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@socket-security
Copy link

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addedclsx@​2.1.11001009678100

View full report

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request replaces the classnames library with clsx for performance improvements. The changes are applied consistently across the codebase, including updating package.json and all usages in the source files and examples. The replacement is correct and I have no further suggestions. This is a good performance enhancement.

@codecov
Copy link

codecov bot commented Sep 27, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.09%. Comparing base (a887d56) to head (c23ff58).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1370      +/-   ##
==========================================
- Coverage   96.11%   96.09%   -0.02%     
==========================================
  Files          57       57              
  Lines        3445     3434      -11     
  Branches      632      632              
==========================================
- Hits         3311     3300      -11     
  Misses        129      129              
  Partials        5        5              

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

Copy link

@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

🧹 Nitpick comments (1)
src/Table.tsx (1)

782-783: 样式合并顺序变更可能改变滚动样式的优先级

当前将 styles?.content 放在最后:用户样式可覆盖内部的 overflowX/overflowY,这与过去实现(可能内部样式在后)不一定一致。请确认这是否为有意的行为变更;若希望库侧滚动样式始终生效,可将顺序调整为用户样式在前。

备选(仅当需保证内部滚动样式优先生效):

-        style={{ ...scrollXStyle, ...scrollYStyle, ...styles?.content }}
+        style={{ ...styles?.content, ...scrollXStyle, ...scrollYStyle }}
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a887d56 and c23ff58.

📒 Files selected for processing (16)
  • docs/examples/animation.tsx (2 hunks)
  • docs/examples/virtual-list-grid.tsx (2 hunks)
  • docs/examples/virtual-list.tsx (2 hunks)
  • package.json (1 hunks)
  • src/Body/BodyRow.tsx (4 hunks)
  • src/Body/index.tsx (2 hunks)
  • src/Cell/index.tsx (2 hunks)
  • src/FixedHolder/index.tsx (2 hunks)
  • src/Header/Header.tsx (3 hunks)
  • src/Table.tsx (4 hunks)
  • src/VirtualTable/BodyLine.tsx (4 hunks)
  • src/VirtualTable/VirtualCell.tsx (2 hunks)
  • src/VirtualTable/index.tsx (2 hunks)
  • src/hooks/useRowInfo.tsx (2 hunks)
  • src/stickyScrollBar.tsx (2 hunks)
  • src/utils/expandUtil.tsx (3 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2024-11-08T12:53:09.293Z
Learnt from: bbb169
PR: react-component/table#1202
File: src/Table.tsx:903-904
Timestamp: 2024-11-08T12:53:09.293Z
Learning: 在 `src/Table.tsx` 文件的 React 组件 `Table` 中,即使 `bodyScrollLeft` 频繁更新,也需要在 `TableContextValue` 的 `useMemo` 依赖数组中包含 `bodyScrollLeft` 和 `headerCellRefs`,因为每次滚动时重新计算 `TableContextValue` 是解决该问题所必须的。

Applied to files:

  • src/stickyScrollBar.tsx
  • src/Cell/index.tsx
  • src/VirtualTable/index.tsx
  • src/Body/index.tsx
  • src/VirtualTable/BodyLine.tsx
  • src/Body/BodyRow.tsx
  • src/Header/Header.tsx
  • src/Table.tsx
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: test / react component workflow
  • GitHub Check: test / react component workflow
🔇 Additional comments (9)
src/hooks/useRowInfo.tsx (1)

119-120: 替换成 clsx 保持原有行为

clsx 对空值与字符串的处理与先前的 classNames 等价,这里继续安全地合并 rowProps.className,不会引入新的副作用。整体修改符合预期。

src/stickyScrollBar.tsx (1)

199-201: clsx 条件 class 合并正确

clsx 在对象语法下只会在激活时输出 *-active,完全复现了原有 classNames 的逻辑,改动安全。

src/FixedHolder/index.tsx (1)

178-180: clsx 重构覆盖了原逻辑

这里用 clsx 组合默认 className 与可选粘性类,真值判断与之前的 classNames 一致,行为未变。

docs/examples/virtual-list.tsx (1)

26-28: 示例中 clsx 替换无行为差异

条件 class 的写法与旧实现等价,示例仍能正确标记最后一列。

docs/examples/animation.tsx (1)

30-31: 动画示例的 clsx 合并正常

这里合并节点自身与动画附加 class 的逻辑保持一致,clsx 替换后无功能变化。

src/Table.tsx (4)

816-829: clsx 等价替换正确,动态类名映射清晰

对象语法和条件类名在 clsx 中与 classnames 行为一致,改动安全。


836-836: Panel 标题处替换为 clsx 无副作用

与原行为一致,OK。


843-843: 容器 className 使用 clsx 合理

保持了可扩展的外部类名合并。


848-848: Footer Panel 处的 clsx 替换正确

不会影响渲染结果。

@li-jia-nan li-jia-nan merged commit 057acc8 into master Sep 28, 2025
13 checks passed
@li-jia-nan li-jia-nan deleted the clsx-update branch September 28, 2025 06:41
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