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

fix(AnimatingNumbers): 多端适配 #2700

Merged
merged 12 commits into from
Nov 21, 2024
Merged

Conversation

irisSong
Copy link
Collaborator

@irisSong irisSong commented Nov 5, 2024

🤔 这个变动的性质是?

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

🔗 相关 Issue

💡 需求背景和解决方案

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

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

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

Summary by CodeRabbit

  • 新功能

    • 更新多个组件的版本,提升功能和性能。
    • 引入新的CSS类,以增强计数动画的视觉效果。
  • 样式

    • 修改计数动画组件的样式,改善视觉一致性和动画效果。
  • 测试

    • 更新计数动画组件的测试用例,简化样式断言。
  • 重构

    • 重命名变量以提高代码可读性,并优化组件的逻辑结构。

Copy link

coderabbitai bot commented Nov 5, 2024

Warning

Rate limit exceeded

@irisSong has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 18 minutes and 12 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between ea6aa32 and f3ddd5b.

Walkthrough

此次更改主要集中在多个组件的版本更新和样式调整上。src/config.json 文件中的多个组件版本从 2.0.0 更新至 3.0.0,包括 AnimatingNumbersAvatarCountDown 等。此外,新增了 tarodoc 属性。测试文件 animatingnumbers.spec.tsx 中的 CSS 样式断言进行了简化,CSS 文件中新增了多个类定义以支持计数动画的样式。组件 CountUp 的实现进行了重构,变量名称进行了更改,确保与 Taro 组件结构的兼容性。

Changes

文件路径 更改摘要
src/config.json 更新多个组件的版本从 2.0.03.0.0,新增 tarodoc 属性。
src/packages/animatingnumbers/__tests__/animatingnumbers.spec.tsx 更新 AnimatingNumbers.CountUp 组件的测试,简化 CSS 样式断言,专注于过渡持续时间。
src/packages/animatingnumbers/animatingnumbers.harmony.css 新增多个 CSS 类定义以支持计数动画的样式。
src/packages/animatingnumbers/countup.scss 修改 .nut-countup-listitem.nut-countup-separator.nut-countup-number 类的样式,增强视觉一致性和动画能力。
src/packages/animatingnumbers/countup.taro.tsx 修改 CountUp 组件,更新导入语句,重命名变量,优化状态检查和样式应用逻辑,确保与 Taro 结构兼容。
src/packages/animatingnumbers/countup.tsx 修改 CountUp 组件,重命名变量,调整过渡样式,增强 JSX 结构的样式特异性。

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant CountUpComponent
    participant AnimationEngine

    User->>CountUpComponent: Trigger count up
    CountUpComponent->>AnimationEngine: Apply transition styles
    AnimationEngine-->>CountUpComponent: Render animated numbers
    CountUpComponent-->>User: Display count up animation
Loading

Possibly related PRs

Suggested reviewers

  • oasis-cloud

Poem

🐰 在数字的舞台上跳跃,
计数的乐章轻声奏响,
新的版本如春风拂面,
动画流畅,样式更佳,
兔子欢呼,庆祝这变化! 🌟


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

@github-actions github-actions bot added the 3.x label Nov 5, 2024
Copy link

codecov bot commented Nov 5, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 83.98%. Comparing base (301a9e0) to head (f3ddd5b).
Report is 32 commits behind head on V3.0.

Additional details and impacted files
@@           Coverage Diff           @@
##             V3.0    #2700   +/-   ##
=======================================
  Coverage   83.98%   83.98%           
=======================================
  Files         221      221           
  Lines       17867    17867           
  Branches     2676     2676           
=======================================
  Hits        15005    15005           
  Misses       2857     2857           
  Partials        5        5           

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


🚨 Try these New Features:

coderabbitai[bot]

This comment was marked as abuse.

@jdf2e jdf2e deleted a comment from coderabbitai bot Nov 6, 2024
@@ -902,7 +902,7 @@
"author": "swag~jun"
},
{
"version": "2.0.0",
"version": "3.0.0",
Copy link
Collaborator

Choose a reason for hiding this comment

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

3.0 标识涵盖鸿蒙适配,这种单独的 v14 适配,和 3.0 标识冲突。需要大家进行方案确认。

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

3.0 标识涵盖鸿蒙适配,这种单独的 v14 适配,和 3.0 标识冲突。需要大家进行方案确认。

已确认

src/packages/animatingnumbers/animatingnumbers.harmony.css Outdated Show resolved Hide resolved
Comment on lines +25 to +32
.nut-countup-number {
display: flex;
flex-direction: column;
align-items: center;
width: auto;
transition: transform 1s ease-in-out;
transform: translate(0, 0);
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

will-change 有可能存在布局影响,慎重考虑

const idx = Number(numerArr[Number(key)])
if (elem) {
const idx = Number(numberArr[Number(key)])
if (elem && typeof idx === 'number' && !Number.isNaN(idx)) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

条件比较多的表达式,可以将其提炼一个概括的变量,便于理解其含义

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

已修改

createSelectorQuery()
.selectAll('.nut-countup-listitem')
.node((numberItems: any) => {
const transformArrCache: string[] = []
const transformArrCache: any[] = []
Copy link
Collaborator

Choose a reason for hiding this comment

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

这里为什么改成了 any 类型?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

已修改

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: 1

🧹 Outside diff range and nitpick comments (4)
src/packages/animatingnumbers/animatingnumbers.harmony.css (4)

1-6: 建议增加响应式支持

基础容器样式实现合理,但建议考虑以下优化:

  1. 考虑在不同屏幕尺寸下的自适应高度
  2. 添加最小宽度限制以确保数字显示完整
.nut-countup-list {
  display: inline-flex;
- height: 32px;
+ min-height: 32px;
  overflow: hidden;
  direction: ltr;
+ min-width: min-content;
}
🧰 Tools
🪛 eslint

[error] 1-1: Parsing error: Declaration or statement expected.


13-18: 建议增加暗黑模式支持

数字样式可以通过 CSS 变量优化暗黑模式适配:

.nut-countup-listitem-number {
  margin: 0 0;
  border-radius: 4px;
- color: #1a1a1a;
+ color: var(--nutui-color-text, #1a1a1a);
  background-color: inherit;
}

19-26: 优化分隔符垂直对齐

建议调整分隔符的垂直对齐方式,使其在视觉上更协调:

.nut-countup-separator {
  display: flex;
  height: 80%;
- align-items: flex-end;
+ align-items: center;
  color: inherit;
  font-size: 18px;
  font-weight: 600;
}

35-41: 建议使用 CSS 变量

为了更好的主题适配,建议使用 CSS 变量:

.nut-countup-number-text {
  height: 32px;
  line-height: 32px;
- color: #1a1a1a;
- font-size: 18px;
- font-weight: 600;
+ color: var(--nutui-color-text, #1a1a1a);
+ font-size: var(--nutui-font-size-large, 18px);
+ font-weight: var(--nutui-font-weight-bold, 600);
}
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between df4f024 and ea6aa32.

📒 Files selected for processing (3)
  • src/packages/animatingnumbers/animatingnumbers.harmony.css (1 hunks)
  • src/packages/animatingnumbers/countup.scss (2 hunks)
  • src/packages/animatingnumbers/countup.taro.tsx (4 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/packages/animatingnumbers/countup.scss
  • src/packages/animatingnumbers/countup.taro.tsx
🧰 Additional context used
📓 Learnings (1)
src/packages/animatingnumbers/animatingnumbers.harmony.css (1)
Learnt from: oasis-cloud
PR: jdf2e/nutui-react#2700
File: src/packages/animatingnumbers/animatingnumbers.harmony.css:25-32
Timestamp: 2024-11-06T05:56:06.800Z
Learning: 在优化 NutUI React 动画性能时,添加 `will-change` 属性可能会对布局产生影响,需要谨慎使用。
🪛 eslint
src/packages/animatingnumbers/animatingnumbers.harmony.css

[error] 1-1: Parsing error: Declaration or statement expected.

🔇 Additional comments (1)
src/packages/animatingnumbers/animatingnumbers.harmony.css (1)

7-12: 代码实现符合预期

列表项容器的样式实现得当,包含了必要的用户交互控制。

Comment on lines +27 to +34
.nut-countup-number {
display: flex;
flex-direction: column;
align-items: center;
width: auto;
transition: transform 1s ease-in-out;
transform: translate(0, 0);
}
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

优化动画性能

考虑到之前的经验,建议通过以下方式优化动画性能:

.nut-countup-number {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: auto;
- transition: transform 1s ease-in-out;
+ transition: transform 1s cubic-bezier(0.23, 1, 0.32, 1);
  transform: translate(0, 0);
+ transform: translate3d(0, 0, 0);
}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
.nut-countup-number {
display: flex;
flex-direction: column;
align-items: center;
width: auto;
transition: transform 1s ease-in-out;
transform: translate(0, 0);
}
.nut-countup-number {
display: flex;
flex-direction: column;
align-items: center;
width: auto;
transition: transform 1s cubic-bezier(0.23, 1, 0.32, 1);
transform: translate3d(0, 0, 0);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants