Skip to content

fix: stack case #1247

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 1 commit into from
Mar 10, 2025
Merged

fix: stack case #1247

merged 1 commit into from
Mar 10, 2025

Conversation

zombieJ
Copy link
Member

@zombieJ zombieJ commented Mar 10, 2025

Summary by CodeRabbit

  • 新特性

    • 优化了表格展示,调整了部分列的宽度与固定列配置,使整体布局更均衡。
    • 新增了自定义阴影偏移设置,提升滚动过程中固定部分的视觉效果。
  • 重构

    • 改进了粘性定位和阴影计算的逻辑,确保交互体验更加稳定流畅。

Copy link

vercel bot commented Mar 10, 2025

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

Name Status Preview Comments Updated (UTC)
table ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 10, 2025 11:47am

Copy link

coderabbitai bot commented Mar 10, 2025

Walkthrough

本次变更更新了表格示例中列宽和固定属性的配置,调整了部分列的宽度以及固定属性设置。同时,在 Cell 组件中新增了用于控制固定阴影偏移的属性,并在辅助函数与接口中增加了对应的列宽信息。这些改动均不改变已有公开实体的声明,而是扩展了功能配置和阴影计算逻辑。

Changes

File(s) Change Summary
docs/.../scrollXY.tsx 调整列宽(如:从100降至60、80,增加或移除 width 属性)及修改部分列为 fixed: 'start'
src/Cell/index.tsx, src/utils/fixUtil.ts CellPropsFixedInfo 中新增 offsetFixedStartShadowoffsetFixedEndShadow,更新阴影显示及计算逻辑
src/hooks/useStickyOffsets.ts, src/interface.ts 新增 widths 属性,用于传递和描述列宽数据

Sequence Diagram(s)

sequenceDiagram
  participant U as 用户
  participant T as 表格组件
  participant S as useStickyOffsets Hook
  participant C as Cell 组件
  participant F as fixUtil 工具
  U->>T: 滚动表格
  T->>S: 提供列宽信息,计算粘性偏移
  S-->>T: 返回 {start, end, widths}
  T->>C: 传递 Cell 属性(包含偏移量)
  C->>F: 计算固定阴影偏移
  F-->>C: 返回计算后的 offsetFixedStartShadow/offsetFixedEndShadow
  C->>T: 渲染带阴影效果的单元格
Loading

Possibly related PRs

Suggested reviewers

  • afc163

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.

docs/examples/scrollXY.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.

src/Cell/index.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.

src/hooks/useStickyOffsets.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.

  • 2 others

📜 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 2e6d4f2 and 2a7e6e9.

📒 Files selected for processing (5)
  • docs/examples/scrollXY.tsx (1 hunks)
  • src/Cell/index.tsx (3 hunks)
  • src/hooks/useStickyOffsets.ts (1 hunks)
  • src/interface.ts (1 hunks)
  • src/utils/fixUtil.ts (3 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: test / react component workflow
🔇 Additional comments (10)
src/interface.ts (1)

136-136: 良好地扩展 StickyOffsets 接口以包含列宽信息

StickyOffsets 接口添加 widths 属性是一个良好的改进,它允许在处理固定列和阴影计算时能够访问列宽信息。这有助于实现更精确的阴影偏移计算。

src/hooks/useStickyOffsets.ts (1)

35-35: 正确地实现了 widths 属性

useStickyOffsets 函数返回的对象中添加 widths: colWidths 很好地实现了接口更改,确保了列宽信息能够被传递到需要它的组件中。

docs/examples/scrollXY.tsx (1)

7-12: 优化列宽和固定属性配置

对列配置进行的调整能够更好地展示固定列和阴影效果:

  • 减小了第一列宽度(从100到60),并设置为固定列
  • 调整了第二列宽度(从100到80),并设置为固定列
  • 增加了第三列宽度(从100到120)
  • 保持第四列宽度不变,但设置为固定列
  • 移除了第五列和第六列的宽度定义,使其能够自适应

这些变更配合新增的阴影偏移功能,提供了更真实的用例场景,有助于测试各种列宽组合下的表现。

src/Cell/index.tsx (3)

44-45: 增加了阴影偏移控制属性

CellProps 接口添加 offsetFixedStartShadowoffsetFixedEndShadow 属性,可以更灵活地控制固定列阴影的显示。这是一个很好的改进,有助于解决固定列阴影的精确控制问题。


112-113: 正确解构新增的属性

从 props 中正确解构了新增的阴影偏移属性,确保它们可以在组件内部使用。


153-154: 改进了阴影显示逻辑

在阴影显示计算中使用新的偏移属性,使阴影的显示与隐藏更加精确。这解决了之前可能存在的阴影显示不准确的问题,尤其是在不同宽度列组合的情况下。

Also applies to: 158-159

src/utils/fixUtil.ts (4)

15-19: 接口扩展清晰明了

新增的 offsetFixedStartShadowoffsetFixedEndShadow 属性定义明确,注释清晰地说明了它们的用途。这种接口扩展方式符合良好的代码演进实践,通过添加可选属性来增强功能而不破坏现有代码。


49-50: 代码初始化更明确

fixedStartShadowfixedEndShadow 的初始化从隐式改为显式的 false 赋值,提高了代码的可读性和可维护性。这样的修改有助于防止潜在的未定义值问题。


66-83: 阴影偏移计算逻辑完善

新增的阴影偏移计算逻辑实现得当,通过遍历列来累加非固定列的宽度,分别计算起始和结束位置的阴影偏移量。这种实现能够准确反映滚动位置与阴影显示之间的关系。

代码中的两个循环逻辑清晰,分别处理了固定起始列和固定结束列的场景,条件判断也很合理。


90-92: 返回对象包含新增属性

将计算得到的阴影偏移值包含在返回对象中,使这些新属性能够被函数调用者正确获取和使用。这是对之前修改的自然延伸,确保了接口的完整性。

✨ Finishing Touches
  • 📝 Generate Docstrings

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

Copy link

codecov bot commented Mar 10, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.03%. Comparing base (2e6d4f2) to head (2a7e6e9).
Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1247   +/-   ##
=======================================
  Coverage   98.02%   98.03%           
=======================================
  Files          76       76           
  Lines        7391     7412   +21     
  Branches     1138     1145    +7     
=======================================
+ Hits         7245     7266   +21     
  Misses        140      140           
  Partials        6        6           

☔ 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 c7f774c into master Mar 10, 2025
12 checks passed
@zombieJ zombieJ deleted the fix-stack branch March 10, 2025 11:51
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.

1 participant