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(countup): 分隔符文字颜色支持css变量修改 #2869

Merged
merged 1 commit into from
Dec 18, 2024

Conversation

irisSong
Copy link
Collaborator

@irisSong irisSong commented Dec 18, 2024

🤔 这个变动的性质是?

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

🔗 相关 Issue

💡 需求背景和解决方案

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

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

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

Summary by CodeRabbit

  • 新特性

    • 添加了新的 CSS 变量 --nutui-countup-separator-color,用于自定义计数动画中的分隔符颜色。
    • customTheme 对象中新增属性 nutuiCountupSeparatorColor,允许用户更改分隔符的颜色。
  • 文档

    • 更新了 AnimatingNumbers 组件的文档,包含新的 CSS 变量以增强自定义选项。

Copy link

coderabbitai bot commented Dec 18, 2024

概述

遍历

这个拉取请求主要针对动画数字组件的样式和文档进行了修改。更改包括在 SCSS 文件中更新分隔符颜色、在演示文件中添加自定义主题属性,并在多个语言版本的文档中添加新的 CSS 变量,以增强组件的定制化选项。

变更

文件 变更摘要
src/packages/animatingnumbers/countup.scss 更新 .nut-countup-separator 的颜色属性
src/packages/animatingnumbers/demos/h5/demo2.tsx 添加 nutuiCountupSeparatorColor 属性到自定义主题
src/packages/animatingnumbers/demos/taro/demo2.tsx 添加 nutuiCountupSeparatorColor 属性到自定义主题
src/styles/variables.scss 新增 $countup-separator-color 变量
文档文件 (.md) 添加 --nutui-countup-separator-color CSS 变量

可能相关的 PR

建议标签

3.x

建议审阅者

  • xiaoyatong
  • oasis-cloud

诗歌

数字跳动,色彩飞舞
分隔符闪耀新光芒
代码如诗,样式如梦
兔子微笑,变化无疆 🐰✨


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.

@github-actions github-actions bot added the 2.x Target branch 2.x label Dec 18, 2024
Copy link

codecov bot commented Dec 18, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 84.02%. Comparing base (7489260) to head (22d4c62).
Report is 1 commits behind head on next.

Additional details and impacted files
@@           Coverage Diff           @@
##             next    #2869   +/-   ##
=======================================
  Coverage   84.02%   84.02%           
=======================================
  Files         220      220           
  Lines       17917    17917           
  Branches     2628     2628           
=======================================
  Hits        15055    15055           
  Misses       2857     2857           
  Partials        5        5           

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

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

🔭 Outside diff range comments (2)
src/packages/animatingnumbers/demos/h5/demo2.tsx (1)

Line range hint 13-20: 请注意处理定时器内存泄漏问题

useEffect 中的 setInterval 在组件卸载时需要清理,建议添加清理函数。

建议修改如下:

  useEffect(() => {
-   setInterval(() => {
+   const timer = setInterval(() => {
      setEndNumer(
        `${Math.floor(Math.random() * 999999)}.${Math.floor(
          Math.random() * 89 + 10
        )}`
      )
    }, 3000)
+   return () => clearInterval(timer)
  }, [])
src/packages/animatingnumbers/demos/taro/demo2.tsx (1)

Line range hint 13-20: 同样需要处理定时器内存泄漏问题

此处存在与 H5 版本相同的内存泄漏隐患,需要在 useEffect 中清理 setInterval

建议修改如下:

  useEffect(() => {
-   setInterval(() => {
+   const timer = setInterval(() => {
      setEndNumer(
        `${Math.floor(Math.random() * 999999)}.${Math.floor(
          Math.random() * 89 + 10
        )}`
      )
    }, 3000)
+   return () => clearInterval(timer)
  }, [])
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7489260 and 22d4c62.

📒 Files selected for processing (8)
  • src/packages/animatingnumbers/countup.scss (1 hunks)
  • src/packages/animatingnumbers/demos/h5/demo2.tsx (1 hunks)
  • src/packages/animatingnumbers/demos/taro/demo2.tsx (1 hunks)
  • src/packages/animatingnumbers/doc.en-US.md (1 hunks)
  • src/packages/animatingnumbers/doc.md (1 hunks)
  • src/packages/animatingnumbers/doc.taro.md (1 hunks)
  • src/packages/animatingnumbers/doc.zh-TW.md (1 hunks)
  • src/styles/variables.scss (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • src/styles/variables.scss
🔇 Additional comments (5)
src/packages/animatingnumbers/countup.scss (1)

28-28: 分隔符颜色变量的使用符合预期!

将分隔符颜色从固定值改为使用 $countup-separator-color 变量是个很好的改进,这样能够通过 CSS 变量灵活地自定义颜色。

src/packages/animatingnumbers/demos/h5/demo2.tsx (1)

10-10: 主题配置更新正确!

新增的 nutuiCountupSeparatorColor 配置项正确使用了 CSS 变量 --nutui-color-primary,展示了分隔符颜色的自定义能力。

src/packages/animatingnumbers/demos/taro/demo2.tsx (1)

10-10: 主题配置与 H5 版本保持一致!

Taro 版本中新增的 nutuiCountupSeparatorColor 配置与 H5 版本保持一致,这很好。

src/packages/animatingnumbers/doc.md (1)

56-56: 文档更新清晰完整!

新增的CSS变量命名规范,默认值设置合理,与组件其他样式变量保持一致。

src/packages/animatingnumbers/doc.zh-TW.md (1)

56-56: 繁体中文文档同步更新正确!

新增的CSS变量在繁体中文文档中翻译准确,格式规范。

@@ -53,3 +53,4 @@ import { AnimatingNumbers } from '@nutui/nutui-react-taro'
| \--nutui-countup-lr-margin | 每个数字的margin | `0` |
| \--nutui-countup-bg-color | 每个数字块的背景色 | `inherit` |
| \--nutui-countup-color | 每个数字块的字色 | `$color-title` |
| \--nutui-countup-separator-color | 分隔符的字体颜色 | `$color-title` |
Copy link

Choose a reason for hiding this comment

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

💡 Codebase verification

需要更新样式实现以支持新的CSS变量

经过验证发现:

  1. 文档中已添加了 --nutui-countup-separator-color 变量的说明
  2. Demo 文件中已经在使用该变量
  3. 但在 SCSS 实现中仍然使用的是 $countup-separator-color 变量,需要更新为新的 CSS 变量

建议:

  • 在 SCSS 文件中更新分隔符颜色的实现,使用 var(--nutui-countup-separator-color) 替代 $countup-separator-color
🔗 Analysis chain

Taro文档更新完整,建议验证实现!

新增的CSS变量文档更新正确。建议确认以下几点:

  1. Taro版本的样式实现是否已同步更新
  2. 相关demo是否已更新使用新变量
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# 检查Taro版本的实现和demo
rg --type=scss "nutui-countup-separator-color" src/packages/animatingnumbers/
rg --type=typescript "nutuiCountupSeparatorColor" src/packages/animatingnumbers/demos/taro/

Length of output: 233


Script:

#!/bin/bash
# Check implementation and demo files
rg "nutui-countup-separator-color" src/packages/animatingnumbers/
rg "nutuiCountupSeparatorColor" src/packages/animatingnumbers/

Length of output: 800


Script:

#!/bin/bash
# Check the SCSS implementation
fd -e scss . src/packages/animatingnumbers/ -x cat {}

Length of output: 877

@@ -53,3 +53,4 @@ The component provides the following CSS variables, which can be used to customi
| \--nutui-countup-lr-margin | margin of item | `0` |
| \--nutui-countup-bg-color | background color of item | `inherit` |
| \--nutui-countup-color | color of item | `$color-title` |
| \--nutui-countup-separator-color | The font color of the separator | `$color-title` |
Copy link

Choose a reason for hiding this comment

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

💡 Codebase verification

需要同步更新中文文档

根据验证结果,分隔符颜色的 CSS 变量已在繁体中文(zh-TW)和 Taro 版本文档中更新,但中文(zh-CN)文档缺失。请添加相应的中文文档更新。

  • 需要在 src/packages/animatingnumbers/doc.zh-CN.md 文件中添加对应的 CSS 变量说明
  • CSS 变量表格中应包含 nutui-countup-separator-color 的中文说明
🔗 Analysis chain

文档更新正确且完整

新增的 CSS 变量文档符合组件的命名规范,描述清晰,默认值设置合理。

运行以下脚本验证其他语言版本的文档是否同步更新:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# 描述:检查其他语言版本的文档是否包含相同的 CSS 变量定义

# 搜索所有语言版本的文档文件
fd "doc\.(zh-CN|zh-TW|taro)\.md$" src/packages/animatingnumbers/ --exec rg -l "nutui-countup-separator-color"

Length of output: 194


Script:

#!/bin/bash
# 检查中文文档是否存在
fd "doc\.zh-CN\.md$" src/packages/animatingnumbers/

# 如果存在,检查其内容中的 CSS 变量表格部分
fd "doc\.zh-CN\.md$" src/packages/animatingnumbers/ --exec cat

Length of output: 118

@oasis-cloud oasis-cloud merged commit 4713330 into jdf2e:next Dec 18, 2024
6 checks passed
@coderabbitai coderabbitai bot mentioned this pull request Jan 2, 2025
20 tasks
@irisSong irisSong deleted the next-countup branch January 7, 2025 02:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2.x Target branch 2.x size/S
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants