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(numberkeyboard): harmony cpp adaption #2799

Open
wants to merge 2 commits into
base: feat_v3.x
Choose a base branch
from

Conversation

Alex-huxiyang
Copy link
Collaborator

@Alex-huxiyang Alex-huxiyang commented Nov 27, 2024

🤔 这个变动的性质是?

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

🔗 相关 Issue

💡 需求背景和解决方案

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

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

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

Summary by CodeRabbit

  • 新功能
    • 更新多个组件至版本3.0.0,可能引入新特性和增强功能。
  • 样式
    • 优化数字键盘组件的布局和响应式设计,增强了头部和侧边栏元素的样式。
  • 改进
    • 调整数字键盘组件的渲染逻辑和属性处理,提升与Taro框架的集成效果。

Copy link

coderabbitai bot commented Nov 27, 2024

Walkthrough

本次更改主要涉及多个组件的版本更新,所有相关组件的版本均已从 2.0.0 更新至 3.0.0。此外,NumberKeyboard 组件在其演示文件中进行了相应的修改,包括对右侧操作的元素类型的更改,以及样式文件中的样式调整,旨在改善组件的布局和响应性。整体上,这些更改提升了组件的功能性和可用性。

Changes

文件路径 更改摘要
src/config.json 更新多个组件的版本,从 2.0.0 更新至 3.0.0,包括 NumberKeyboardRadioRadioGroup 等。
src/packages/numberkeyboard/demos/taro/demo4.tsx Demo4 组件中添加了 View 的导入,将 NumberKeyboardrightActions 属性从 <span> 更改为 <View>
src/packages/numberkeyboard/numberkeyboard.scss 添加和调整 .nut-numberkeyboard 组件的样式,改善了头部和侧边栏的布局及响应性。
src/packages/numberkeyboard/numberkeyboard.taro.tsx 修改 NumberKeyboard 组件,添加新导入,更新默认属性处理,调整渲染方法,使用 pxTransform 处理样式。

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant NumberKeyboard
    participant View

    User->>NumberKeyboard: 触发键盘显示
    NumberKeyboard->>View: 渲染键盘视图
    View->>User: 显示键盘
    User->>NumberKeyboard: 输入数字
    NumberKeyboard->>User: 返回输入结果
Loading

Possibly related PRs

Suggested labels

size/L

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 27, 2024
Copy link

codecov bot commented Nov 27, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 83.99%. Comparing base (6213d88) to head (a5bdba8).
Report is 21 commits behind head on feat_v3.x.

Additional details and impacted files
@@              Coverage Diff              @@
##           feat_v3.x    #2799      +/-   ##
=============================================
+ Coverage      83.98%   83.99%   +0.01%     
=============================================
  Files            221      220       -1     
  Lines          17879    17885       +6     
  Branches        2676     2679       +3     
=============================================
+ Hits           15016    15023       +7     
+ Misses          2858     2857       -1     
  Partials           5        5              

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

@pull-request-size pull-request-size bot added size/M and removed size/S labels Nov 27, 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: 2

🧹 Outside diff range and nitpick comments (3)
src/packages/numberkeyboard/numberkeyboard.scss (2)

29-30: 关闭按钮垂直居中定位的实现方式可以优化

当前实现使用 top: 50%transform: translateY(-50%) 实现垂直居中是可行的,但考虑到性能优化,建议使用 Flexbox 方案。

建议修改如下:

.nut-numberkeyboard-header {
-  position: relative;
+  position: relative;
   display: flex;
   align-items: center;
   
   &-close {
     position: absolute;
     right: 0;
-    top: 50%;
-    transform: translateY(-50%);
+    height: 100%;
+    display: flex;
+    align-items: center;
   }
}

53-58: 建议为条件编译添加说明注释

当前代码使用条件编译来处理不同平台的样式差异,建议添加注释说明 harmony 适配的具体原因和场景。

建议添加如下注释:

+ /* Harmony 平台下使用固定宽度以确保更好的布局稳定性 */
/* #ifdef harmony */
width: 33%;
/* #endif */
+ /* 非 Harmony 平台使用 flex-basis 实现相同效果 */
/* #ifndef harmony */
flex-basis: 33%;
/* #endif */
src/packages/numberkeyboard/numberkeyboard.taro.tsx (1)

9-10: 优化了属性处理和工具函数的使用

引入了 pxTransformmergeProps 工具函数,并使用 mergeProps 替代了之前的展开运算符方式来合并默认属性,这样的改动更加规范和安全。

建议添加对 mergeProps 的类型检查,确保类型安全:

- } = mergeProps(defaultProps, props)
+ } = mergeProps<NumberKeyboardProps>(defaultProps, props)

Also applies to: 54-54

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 9332996 and a5bdba8.

📒 Files selected for processing (4)
  • src/config.json (1 hunks)
  • src/packages/numberkeyboard/demos/taro/demo4.tsx (2 hunks)
  • src/packages/numberkeyboard/numberkeyboard.scss (3 hunks)
  • src/packages/numberkeyboard/numberkeyboard.taro.tsx (5 hunks)
🔇 Additional comments (7)
src/packages/numberkeyboard/demos/taro/demo4.tsx (1)

3-3: 导入语句添加正确!

@tarojs/components 导入 View 组件符合 Taro 的最佳实践。

src/packages/numberkeyboard/numberkeyboard.scss (3)

22-22: 字体大小继承设置正确!

从 popup 组件继承字体大小设置,保持了组件间的视觉一致性。


87-89: 侧边栏布局适配设置合理

为 harmony 平台添加的 flex-basis 设置与主体部分保持一致,确保了布局的统一性。


92-92: 侧边栏容器宽度设置正确

设置 width: 100% 确保了侧边栏容器能够正确填充其父容器空间,对于维持布局稳定性很重要。

src/packages/numberkeyboard/numberkeyboard.taro.tsx (2)

91-92: 使用 pxTransform 优化了样式单位转换

将固定像素值改为使用 pxTransform 进行转换,这样能更好地适配不同设备的屏幕尺寸。


127-127: 简化了数字键盘按键的渲染逻辑

使用 Fragment 替代了 View 组件,减少了不必要的 DOM 层级。

src/config.json (1)

Line range hint 569-577: 版本更新看起来符合预期!

NumberKeyboard 组件从 2.0.0 升级到 3.0.0 的版本更新与其他组件的升级模式一致。

运行以下脚本来验证相关文件中的版本一致性:

@@ -15,7 +16,7 @@ const Demo4 = () => {
<NumberKeyboard
visible={visible}
title="标题"
rightActions={<span>Done</span>}
rightActions={<View>Done</View>}
Copy link

Choose a reason for hiding this comment

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

💡 Codebase verification

需要更新 H5 版本的 demo4 示例代码

经过验证,发现 H5 版本的 demo4 中仍在使用 <span>Done</span>,而 Taro 版本已正确使用 <View>Done</View>。建议:

  • 更新 src/packages/numberkeyboard/demos/h5/demo4.tsx 中的代码,将 <span>Done</span> 改为 <div>Done</div>
  • 由于这只是示例代码的改动,不涉及组件 API 变更,无需更新升级指南文档
🔗 Analysis chain

请确认版本升级文档已更新

span 替换为 View 是正确的改动,符合 Taro 组件的使用规范。建议确认以下几点:

  1. 版本升级指南中是否已说明此处 API 的变更
  2. 相关的示例代码是否都已更新
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# 检查版本升级指南和其他示例代码

# 查找版本升级指南
echo "检查版本升级指南..."
rg -l "2.0.0.*3.0.0|NumberKeyboard.*升级|NumberKeyboard.*migration" --type md

# 检查其他示例代码中是否还有使用 span 的地方
echo "检查其他示例代码..."
rg -l "rightActions.*span" --type tsx src/packages/numberkeyboard/demos/

Length of output: 424


Script:

#!/bin/bash
# 检查版本升级指南和其他示例代码

# 查找版本升级指南
echo "检查版本升级指南..."
rg -l "2.0.0.*3.0.0|NumberKeyboard.*升级|NumberKeyboard.*migration" .

# 检查其他示例代码中是否还有使用 span 的地方
echo "检查其他示例代码..."
fd . src/packages/numberkeyboard/demos/ -e ts -e tsx -e jsx -x rg -l "rightActions.*span" {}

Length of output: 861


Script:

#!/bin/bash
# 检查 h5 demo4 中的具体代码
echo "检查 h5 demo4 的代码内容..."
cat src/packages/numberkeyboard/demos/h5/demo4.tsx

# 检查是否存在升级指南文档
echo "检查可能的升级指南文档..."
fd . -e md -x rg -l "NumberKeyboard|数字键盘|组件升级" {}

# 检查其他可能的 demo 文件
echo "检查其他 demo 文件..."
fd . src/packages/numberkeyboard/demos/ -e ts -e tsx -e jsx

Length of output: 1877


Script:

#!/bin/bash
# 检查升级指南文档内容
echo "检查升级指南文档内容..."
cat migrate-from-v2.md

# 检查文档中的相关说明
echo "检查组件文档..."
cat src/packages/numberkeyboard/doc.md

# 检查其他 demo4 的实现
echo "检查 demo4 的其他实现..."
cat src/packages/numberkeyboard/demos/taro/demo4.tsx

Length of output: 29203

Comment on lines +173 to +178
<View
className={`${classPrefix}-header-close`}
onClick={onConfirm}
>
{rightActions || locale.done}
</span>
</View>
Copy link

Choose a reason for hiding this comment

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

💡 Codebase verification

需要统一更新其他文件中的 span 元素

为保持组件的一致性,建议同步更新以下位置的代码:

  • src/packages/numberkeyboard/numberkeyboard.tsx: 将 header-close 中的 span 元素替换为 View 组件
  • src/packages/numberkeyboard/demos/h5/demo4.tsx: 将 rightActions 中的 span 元素替换为 View 组件
🔗 Analysis chain

改进了右侧操作区域的结构

将 span 元素替换为 View 组件,保持了组件的一致性,更符合 Taro 的开发规范。

让我们验证一下这个改动是否在其他地方也保持一致:


Let's examine the specific usage of span in these files to understand the context better.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# 检查是否还有其他使用 span 的地方需要更新
rg -l 'span' src/packages/numberkeyboard/

Length of output: 135


Script:

#!/bin/bash
# Check the context of span usage in these files
echo "=== numberkeyboard.tsx ==="
rg -C 3 'span' src/packages/numberkeyboard/numberkeyboard.tsx

echo -e "\n=== demo4.tsx ==="
rg -C 3 'span' src/packages/numberkeyboard/demos/h5/demo4.tsx

Length of output: 827

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.

1 participant