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

feat(trendarrow): 多端适配 #2540

Merged
merged 16 commits into from
Nov 8, 2024
Merged

feat(trendarrow): 多端适配 #2540

merged 16 commits into from
Nov 8, 2024

Conversation

Alex-huxiyang
Copy link
Collaborator

@Alex-huxiyang Alex-huxiyang commented Aug 15, 2024

icon已进行占位处理

Summary by CodeRabbit

  • 新功能

    • 更新 TrendArrow 组件的版本到 3.0.0,表示潜在的增强或新功能。
    • 引入新的颜色定义,riseColordropColor 根据条件使用具体的颜色十六进制值。
    • 根据 Taro 框架的要求调整了组件的渲染逻辑,确保平台兼容性。
  • 样式改进

    • 修改 .nut-trendarrow 类的布局样式,优化响应式表现。

@Alex-huxiyang Alex-huxiyang marked this pull request as ready for review August 21, 2024 08:41
Copy link

coderabbitai bot commented Aug 21, 2024

Walkthrough

此次更改更新了src/config.json文件中TrendArrow组件的版本号,从2.0.0修改为3.0.0。该版本更新可能涉及组件的增强或新功能,但具体细节未在差异中提供。文件的其他结构或内容未发生变化,整体配置保持不变。同时,src/packages/trendarrow/trendarrow.taro.tsx文件中的TrendArrow组件进行了多处修改,包括替换HTML元素为Taro组件、更新颜色定义以及修改图标渲染逻辑,以增强与Taro框架的兼容性。

Changes

文件路径 更改摘要
src/config.json 更新“TrendArrow”组件的版本号从“2.0.0”改为“3.0.0”。
src/packages/trendarrow/trendarrow.taro.tsx 添加ViewText组件替换HTML元素,更新颜色定义,修改图标渲染逻辑以兼容Taro框架。

Possibly related PRs

Suggested labels

size/XL, 2.x

Suggested reviewers

  • xiaoyatong

Poem

在草地上跃动的小兔,
代码更新如春风拂,
新版本展翅高飞,
兔子欢呼,乐无边! 🐇✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between d45c48e and 9230ab2.

📒 Files selected for processing (1)
  • src/packages/trendarrow/trendarrow.taro.tsx (4 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/packages/trendarrow/trendarrow.taro.tsx

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.

@Alex-huxiyang Alex-huxiyang changed the base branch from dev-harmony to V3.0 October 25, 2024 10:14
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: 0

🧹 Outside diff range and nitpick comments (1)
src/config.json (1)

需要补充破坏性变更文档

根据检查结果,虽然在 CHANGELOG.md 中有记录优化 TrendArrow 组件的 props (#1150),但从 2.0.0 升级到 3.0.0 的破坏性变更并未详细说明。建议:

  • 在 CHANGELOG.md 中补充 3.0.0 版本的破坏性变更说明
  • 详细列出不兼容的 API 修改内容
  • 提供升级指南,帮助用户从 2.0.0 迁移到 3.0.0
🔗 Analysis chain

Line range hint 1210-1218: 版本号更新需要确认破坏性变更文档

版本号从 2.0.0 升级到 3.0.0 表明存在破坏性变更。根据语义化版本规范,主版本号的变更意味着不向下兼容的 API 修改。

请确认以下内容:

  1. 是否已更新 CHANGELOG.md 文档
  2. 是否已在文档中说明不兼容的变更

Let's check the content of CHANGELOG.md to verify if breaking changes are documented.


Let's check for any recent commits or PRs related to TrendArrow to understand the breaking changes better.


Let's check the actual PR content to understand the changes better.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# 检查是否存在 CHANGELOG 或升级指南文档
echo "查找 CHANGELOG 和升级指南文档..."
fd -t f -e md -e MD "CHANGELOG|UPGRADING|MIGRATION"

Length of output: 123


Script:

#!/bin/bash
# 检查 CHANGELOG.md 中关于 TrendArrow 组件的最新变更记录
echo "检查 CHANGELOG.md 中的 TrendArrow 相关内容..."
rg -A 5 -B 5 "TrendArrow|趋势箭头" CHANGELOG.md

Length of output: 519


Script:

#!/bin/bash
# 检查最近的提交记录中关于 TrendArrow 的变更
echo "检查最近的 TrendArrow 相关提交..."
git log --grep="TrendArrow\|趋势箭头" -n 5 --pretty=format:"%h %s"

# 检查组件源文件的变更历史
echo -e "\n\n检查 TrendArrow 组件文件的变更历史..."
fd -t f "TrendArrow" -x git log -p -n 1 {}

Length of output: 325


Script:

#!/bin/bash
# 查找 TrendArrow 组件的源文件
echo "查找 TrendArrow 组件文件..."
fd "TrendArrow" -t f

# 检查组件的具体实现
echo -e "\n检查组件实现..."
ast-grep --pattern 'export $_ class TrendArrow {
  $$$
}'

Length of output: 168

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between fe2f903 and 6474c89.

📒 Files selected for processing (1)
  • src/config.json (1 hunks)

Copy link

codecov bot commented Oct 30, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 83.95%. Comparing base (7515810) to head (9230ab2).
Report is 13 commits behind head on V3.0.

Additional details and impacted files
@@           Coverage Diff           @@
##             V3.0    #2540   +/-   ##
=======================================
  Coverage   83.95%   83.95%           
=======================================
  Files         221      221           
  Lines       17849    17849           
  Branches     2679     2679           
=======================================
  Hits        14986    14986           
  Misses       2858     2858           
  Partials        5        5           

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

@oasis-cloud oasis-cloud added the 3.x label Nov 1, 2024
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 (1)
src/packages/trendarrow/trendarrow.taro.tsx (1)

119-135: 优化条件渲染逻辑

当前实现存在以下问题:

  1. 使用了不必要的Fragment包裹
  2. 条件渲染逻辑可以更简洁

建议简化实现:

- <>
-   {riseIcon ||
-     (harmonyAndRn() ? (
-       <Text>⬆️</Text>
-     ) : (
-       <TriangleUp color={calcIconProps.color} />
-     ))}
- </>
+ {riseIcon || (
+   harmonyAndRn() ? (
+     <Text>⬆️</Text>
+   ) : (
+     <TriangleUp color={calcIconProps.color} />
+   )
+ )}

同样的优化也适用于降序图标的渲染逻辑。

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 4c00b59 and da9e6bc.

📒 Files selected for processing (1)
  • src/packages/trendarrow/trendarrow.taro.tsx (3 hunks)
🧰 Additional context used
🪛 Biome
src/packages/trendarrow/trendarrow.taro.tsx

[error] 118-139: Avoid using unnecessary Fragment.

A fragment is redundant if it contains only one child, or if it is the child of a html element, and is not a keyed fragment.
Unsafe fix: Remove the Fragment

(lint/complexity/noUselessFragments)

🔇 Additional comments (3)
src/packages/trendarrow/trendarrow.taro.tsx (3)

3-3: 导入Taro组件以支持多端适配

引入@tarojs/components中的ViewText组件是正确的做法,这符合Taro框架的最佳实践。


101-106: 正确使用了Taro的基础组件

将HTML元素替换为Taro的ViewText组件是正确的改动,这样可以确保在各端表现一致。

Also applies to: 110-114


121-122: 验证emoji在不同平台的兼容性

使用emoji作为图标替代方案需要确保在所有目标平台上都能正确显示。

需要我帮您编写相关的平台兼容性测试用例吗?

Also applies to: 130-131

src/packages/trendarrow/trendarrow.taro.tsx Outdated Show resolved Hide resolved
Copy link
Collaborator

@oasis-cloud oasis-cloud left a comment

Choose a reason for hiding this comment

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

改一下 review 内容

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

🧹 Outside diff range and nitpick comments (1)
src/packages/trendarrow/trendarrow.taro.tsx (1)

Line range hint 117-122: 需要回退图标实现

根据之前的讨论,当前的图标实现需要等待Icon适配后再进行修改。建议暂时回退这部分改动。

建议暂时使用以下实现:

- {rateTrend.current ? (
-   <>{riseIcon || <TriangleUp color={calcIconProps.color} />}</>
- ) : (
-   <>{dropIcon || <TriangleDown color={calcIconProps.color} />}</>
- )}
+ // TODO: 等待Icon适配后再实现
+ <Text>{rateTrend.current ? '↑' : '↓'}</Text>
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between da9e6bc and d45c48e.

📒 Files selected for processing (1)
  • src/packages/trendarrow/trendarrow.taro.tsx (4 hunks)
🧰 Additional context used
📓 Learnings (1)
src/packages/trendarrow/trendarrow.taro.tsx (1)
Learnt from: oasis-cloud
PR: jdf2e/nutui-react#2540
File: src/packages/trendarrow/trendarrow.taro.tsx:29-30
Timestamp: 2024-11-06T02:16:07.069Z
Learning: 在`TrendArrow`组件(`src/packages/trendarrow/trendarrow.taro.tsx`)中,CSS变量在鸿蒙系统(Harmony OS)中可能未被完全支持,导致兼容性问题。因此,使用硬编码的十六进制颜色值可以确保在鸿蒙系统上的正确显示。
🔇 Additional comments (2)
src/packages/trendarrow/trendarrow.taro.tsx (2)

3-3: 导入和颜色定义的修改符合要求

  1. 新增的Taro组件导入确保了多端兼容性
  2. 使用十六进制颜色值而不是CSS变量的修改是正确的,这样可以确保在鸿蒙系统上正常显示

Also applies to: 28-29


100-105: 组件结构调整合理

使用ViewText替换原有的HTML元素是正确的改动,这确保了组件在多端环境下的一致性表现。

Also applies to: 109-113

@Alex-huxiyang
Copy link
Collaborator Author

改一下 review 内容

done

@xiaoyatong
Copy link
Collaborator

1、自定义icon 可以支持了
2、样式变量的处理,区分下端

@pull-request-size pull-request-size bot added size/S and removed size/M labels Nov 7, 2024
@Alex-huxiyang
Copy link
Collaborator Author

1、自定义icon 可以支持了 2、样式变量的处理,区分下端

已调整

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