nutui-react icon indicating copy to clipboard operation
nutui-react copied to clipboard

refactor: 重构引入的css transition 库

Open xiaoyatong opened this issue 8 months ago • 2 comments

🤔 这个变动的性质是?

  • [ ] 新特性提交
  • [ ] 日常 bug 修复
  • [ ] 站点、文档改进
  • [ ] 演示代码改进
  • [ ] 组件样式/交互改进
  • [ ] TypeScript 定义更新
  • [x] 包体积优化
  • [ ] 性能优化
  • [ ] 功能增强
  • [ ] 国际化改进
  • [x] 重构
  • [ ] 代码风格优化
  • [ ] 测试用例
  • [ ] 分支合并
  • [ ] 其他改动(是关于什么的改动?)

🔗 相关 Issue

💡 需求背景和解决方案

☑️ 请求合并前的自查清单

⚠️ 请自检并全部勾选全部选项。⚠️

  • [ ] 文档已补充或无须补充
  • [ ] 代码演示已提供或无须提供
  • [ ] TypeScript 定义已补充或无须补充
  • [ ] fork仓库代码是否为最新避免文件冲突
  • [ ] Files changed 没有 package.json lock 等无关文件

Summary by CodeRabbit

  • 新功能

    • 新增了用于管理 CSS 动画过渡的组件,包括 CSSTransition 和 Transition,支持更灵活的动画控制和生命周期回调。
    • 引入了全局配置项,可用于统一控制 CSS 动画的启用状态。
    • 提供了新的 PropTypes 校验工具和强制触发重排的实用函数,提升动画兼容性和开发体验。
  • 依赖变更

    • 新增 dom-helpers 依赖。

xiaoyatong avatar May 24 '25 13:05 xiaoyatong

Walkthrough

本次更改将 Overlay 组件中的 CSSTransition 实现由外部库 react-transition-group 替换为本地自定义实现,并在 src/utils/css-transition/ 目录下引入了一套完整的 CSS 过渡工具组件与相关工具函数、类型定义和配置。同时,package.json 新增了 dom-helpers 依赖。

Changes

文件/文件组 变更摘要
package.json 新增依赖:[email protected]
src/packages/overlay/overlay.taro.tsx
src/packages/overlay/overlay.tsx
CSSTransition 引入路径从外部库切换为本地 @/utils/css-transition/CSSTransition
src/utils/css-transition/CSSTransition.tsx 新增自定义 CSSTransition 组件,支持字符串/对象形式类名与生命周期回调
src/utils/css-transition/Transition.tsx 新增 Transition 组件,支持完整的过渡状态管理与生命周期钩子
src/utils/css-transition/TransitionGroupContext.tsx 新增过渡组上下文,管理挂载状态
src/utils/css-transition/config.ts 新增配置文件,导出 { disabled: false }
src/utils/css-transition/utils/PropTypes.js 新增 PropTypes 校验工具,校验超时与类名结构
src/utils/css-transition/utils/reflow.ts 新增 forceReflow 工具函数,强制浏览器重排
src/utils/css-transition/index.ts 新增索引文件,统一导出本地过渡相关组件与配置

Sequence Diagram(s)

sequenceDiagram
    participant Overlay
    participant CSSTransition
    participant Transition
    participant DOM

    Overlay->>CSSTransition: 渲染时传递过渡相关 props
    CSSTransition->>Transition: 包装生命周期回调与状态
    Transition->>DOM: 根据状态添加/移除 CSS 类名,触发动画
    Transition-->>CSSTransition: 通知过渡阶段变化
    CSSTransition-->>Overlay: 过渡完成后回调

Suggested reviewers

  • oasis-cloud

Poem

🐇
代码如风过,组件自转新,
过渡自家写,动画更灵敏。
状态分明现,类名巧变身,
兔子舞耳朵,代码添欢欣!

✨ 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.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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 generate sequence diagram to generate a sequence diagram of the changes in 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.

coderabbitai[bot] avatar May 24 '25 13:05 coderabbitai[bot]

1 @xiaoyatong 现在有些弹窗偶发的无法弹出,需要重新进入小程序才能恢复,不知道这个能不能解决?

Ryan-CW-Code avatar Sep 19 '25 08:09 Ryan-CW-Code