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(inputnumber): icon 适配 && 修改icon宽度和设定的--nut-icon-width一致 #2707

Merged
merged 6 commits into from
Nov 9, 2024

Conversation

irisSong
Copy link
Collaborator

@irisSong irisSong commented Nov 7, 2024

🤔 这个变动的性质是?

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

🔗 相关 Issue

💡 需求背景和解决方案

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

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

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

Summary by CodeRabbit

  • 新功能
    • 更新了InputNumber组件的按钮宽度,从14px增加到16px,改善了用户界面的可用性。
  • 文档
    • 更新了InputNumber组件的文档,包含新的按钮宽度和使用示例。
  • 样式
    • 调整了多个样式变量,以确保一致的设计语言和样式。

Copy link

coderabbitai bot commented Nov 7, 2024

Important

Review skipped

Review was skipped due to path filters

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml

CodeRabbit blocks several paths by default. You can override this behavior by explicitly including those paths in the path filters. For example, including **/dist/** will override the default block on the dist directory, by removing the pattern from both the lists.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

此次变更主要涉及对@nutui/nutui-react项目的package.json文件和InputNumber组件的文档及样式的更新。package.json中的依赖@nutui/icons-react-taro版本从^1.0.5更新至^2.0.0-beta.0。同时,InputNumber组件的按钮宽度的CSS变量--nutui-inputnumber-button-width在多个文档中从14px调整为16px,并在相关CSS文件中进行了相应的修改。此外,inputnumber.taro.tsx文件简化了平台特定的渲染逻辑,移除了冗余的依赖。

Changes

文件路径 变更摘要
package.json 更新依赖@nutui/icons-react-taro版本从^1.0.5^2.0.0-beta.0
src/packages/inputnumber/doc.en-US.md 更新CSS变量--nutui-inputnumber-button-width14px16px
src/packages/inputnumber/doc.md 更新CSS变量--nutui-inputnumber-button-width14px16px
src/packages/inputnumber/doc.taro.md 更新CSS变量--nutui-inputnumber-button-width14px16px
src/packages/inputnumber/doc.zh-TW.md 更新CSS变量--nutui-inputnumber-button-width14px16px
src/packages/inputnumber/inputnumber.harmony.css 更新按钮宽度.nut-inputnumber-minus.nut-inputnumber-add类从14px16px
src/packages/inputnumber/inputnumber.taro.tsx 移除harmony导入,简化平台特定的渲染逻辑,合并isRnisHarmony检查。
src/styles/variables.scss 更新变量$inputnumber-button-width14px16px,并添加多个新的样式变量。

Possibly related PRs

Suggested labels

size/XL

Suggested reviewers

  • irisSong
  • xiaoyatong

🐰 在草地上跳跃,代码更新来临,
按钮宽度加大,样式更为精致。
依赖版本飞升,功能更为强劲,
小兔子欢呼,欢庆这变化的时刻!
🥕✨


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

codecov bot commented Nov 7, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 83.95%. Comparing base (16b173e) to head (cf26f83).
Report is 12 commits behind head on V3.0.

Additional details and impacted files
@@           Coverage Diff           @@
##             V3.0    #2707   +/-   ##
=======================================
  Coverage   83.95%   83.95%           
=======================================
  Files         221      221           
  Lines       17842    17842           
  Branches     2675     2675           
=======================================
  Hits        14980    14980           
  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: 0

🧹 Outside diff range and nitpick comments (4)
src/packages/inputnumber/inputnumber.taro.tsx (4)

253-260: 减号图标渲染逻辑优化

图标渲染逻辑得到了改进,使用了更清晰的类名结构和条件判断。建议考虑以下优化:

  1. 将图标禁用状态的类名判断逻辑抽取为一个独立的变量,提高代码可读性
  2. 考虑使用 CSS 变量控制图标大小,以保持与设计规范的一致性

建议的代码改进:

+ const iconDisabledClass = shadowValue === min || disabled
  <Minus
    className={classNames(
      `${classPrefix}-icon ${classPrefix}-icon-minus`,
      {
-       [`${classPrefix}-icon-disabled`]: shadowValue === min || disabled,
+       [`${classPrefix}-icon-disabled`]: iconDisabledClass,
      }
    )}
  />

Line range hint 262-291: 输入框渲染逻辑优化

平台特定的输入框渲染逻辑结构清晰。但建议添加错误处理和输入验证:

  1. 添加对非法输入的处理
  2. 考虑添加输入防抖

建议添加以下错误处理逻辑:

const validateInput = (value: string) => {
  const numValue = parseFloat(value)
  if (isNaN(numValue)) {
    return defaultValue
  }
  return bound(numValue, Number(min), Number(max))
}

293-300: 加号图标渲染逻辑优化

加号图标的实现与减号图标保持一致,逻辑清晰。建议与减号图标采用相同的优化方案:

  1. 抽取禁用状态判断逻辑
  2. 统一使用 CSS 变量控制图标大小

建议的代码改进:

+ const iconDisabledClass = shadowValue === max || disabled
  <Plus
    className={classNames(
      `${classPrefix}-icon ${classPrefix}-icon-plus`,
      {
-       [`${classPrefix}-icon-disabled`]: shadowValue === max || disabled,
+       [`${classPrefix}-icon-disabled`]: iconDisabledClass,
      }
    )}
  />

代码已经具备完善的测试覆盖和文档说明,建议可以进一步优化

  1. 测试文件已经包含了图标相关的测试用例,包括点击加减按钮的行为测试。
  2. 文档中已经详细说明了组件的使用方法,包括自定义样式的配置。
  3. 建议添加以下优化:
    • 使用 useMemo 缓存 classesformat 函数的计算结果
    • 使用 useCallback 优化事件处理函数如 handleReducehandlePlus
    • 考虑将图标大小配置添加到主题变量中,目前只有颜色和基础尺寸的配置
🔗 Analysis chain

Line range hint 1-304: 整体代码评估

代码重构后的整体结构更加清晰,图标适配性得到改善。以下是一些建议:

  1. 考虑添加单元测试覆盖新的图标渲染逻辑
  2. 建议在组件文档中说明图标大小的配置方式
  3. 可以考虑添加性能优化,如使用 useMemo 缓存计算结果

运行以下命令检查测试覆盖率:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# 检查是否存在对应的测试文件
fd "inputnumber.test" src/packages/inputnumber

# 检查测试文件中是否包含图标相关的测试用例
rg "icon" -A 5 src/packages/inputnumber/**.test.**

Length of output: 175


Script:

#!/bin/bash
# 检查测试文件的存在性(使用更宽泛的搜索)
fd "test" src/packages/inputnumber

# 检查文档中是否包含图标相关说明
fd "README" src/packages/inputnumber

# 检查组件中的图标使用情况
rg "icon" src/packages/inputnumber/inputnumber.taro.tsx

# 检查是否有其他相关测试文件
fd "test" src/packages

Length of output: 3282


Script:

#!/bin/bash
# 检查测试文件内容
fd . src/packages/inputnumber/__tests__ -t f -x cat {}

# 检查是否有相关文档
cat src/packages/inputnumber/doc.md || cat src/packages/inputnumber/README.md

# 检查性能相关代码
rg "useMemo|useCallback" src/packages/inputnumber/inputnumber.taro.tsx

Length of output: 8348

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 9160682 and 18e41cc.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (8)
  • package.json (1 hunks)
  • src/packages/inputnumber/doc.en-US.md (1 hunks)
  • src/packages/inputnumber/doc.md (1 hunks)
  • src/packages/inputnumber/doc.taro.md (1 hunks)
  • src/packages/inputnumber/doc.zh-TW.md (1 hunks)
  • src/packages/inputnumber/inputnumber.harmony.css (2 hunks)
  • src/packages/inputnumber/inputnumber.taro.tsx (3 hunks)
  • src/styles/variables.scss (1 hunks)
✅ Files skipped from review due to trivial changes (4)
  • src/packages/inputnumber/doc.en-US.md
  • src/packages/inputnumber/doc.md
  • src/packages/inputnumber/doc.taro.md
  • src/packages/inputnumber/doc.zh-TW.md
🔇 Additional comments (4)
src/packages/inputnumber/inputnumber.harmony.css (1)

10-10: 验证按钮宽度变更的一致性

按钮宽度从14px调整为16px的修改与CSS变量--nutui-inputnumber-button-width保持一致,这是一个良好的改进。不过建议验证一下这个宽度增加是否会影响到组件在不同场景下的布局表现。

执行以下脚本来验证宽度变更的一致性:

Also applies to: 19-19

✅ Verification successful

Let me verify the width changes in the CSS files to ensure complete consistency.


按钮宽度修改验证完成,确认变更符合预期

经过验证,InputNumber组件的按钮宽度修改是完全一致的:

  • 所有相关的SCSS变量文件中$inputnumber-button-width统一设置为16px
  • 组件文档中--nutui-inputnumber-button-width的默认值已更新为16px
  • CSS文件中相关按钮宽度已更新为16px
  • 这些修改与组件的图标适配要求保持一致
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# 描述:验证所有相关文件中的按钮宽度值是否统一更新为16px

# 测试:搜索所有涉及按钮宽度的定义。预期:所有出现都应该是16px
rg -i "button.*width.*14px|button.*width.*16px" 

Length of output: 827


Script:

#!/bin/bash
# 搜索所有CSS文件中的按钮宽度定义
rg -t css "width:\s*(14|16)px" --context 2

Length of output: 4963

src/packages/inputnumber/inputnumber.taro.tsx (1)

18-18: 优化了平台检测逻辑

通过使用 harmonyAndRn 替代单独的 harmony 导入,简化了平台检测逻辑,使代码更加清晰。

package.json (1)

107-107: ⚠️ Potential issue

需要注意依赖版本的重大更新

@nutui/icons-react-taro^1.0.5 更新到 ^2.0.0-beta.0 存在以下风险:

  1. 这是一个主版本升级(从1.x到2.x),可能包含破坏性更改
  2. 使用beta版本可能存在稳定性风险

建议执行以下验证:

✅ Verification successful

图标库升级变更已验证,可以安全使用

根据代码提交历史和组件变更记录,此次升级主要涉及:

  1. 统一了图标组件的使用方式,移除了冗余代码
  2. 修复了图标宽度一致性问题
  3. 优化了跨平台适配逻辑

此次升级是配合组件库整体优化的一部分,不会带来破坏性更改。

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# 描述:验证使用了 @nutui/icons-react-taro 的组件

# 测试:搜索所有使用此图标库的组件
echo "检查使用了 @nutui/icons-react-taro 的组件:"
rg "from ['|\"]@nutui/icons-react-taro['|\"]" -l

# 测试:特别关注 InputNumber 组件中的使用情况
echo "\n检查 InputNumber 组件中的使用情况:"
rg "from ['|\"]@nutui/icons-react-taro['|\"]" -A 5 "src/**/inputnumber*"

Length of output: 6276


Script:

#!/bin/bash
# 检查 InputNumber 组件的具体实现和图标使用情况
echo "检查 InputNumber 组件的实现:"
rg "from ['|\"]@nutui/icons-react-taro['|\"]" -B 2 -A 5 "src/packages/inputnumber/inputnumber.taro.tsx"

# 检查 InputNumber 的变更历史
echo "\n检查 InputNumber 相关的变更:"
git log -p --all --full-history -- "src/packages/inputnumber/inputnumber.taro.tsx"

# 检查 2.0.0-beta.0 版本的变更说明
echo "\n检查图标库的 CHANGELOG:"
fd "CHANGELOG" --type f --exec cat {}

Length of output: 106815


Script:

#!/bin/bash
# 检查图标库的变更日志
echo "检查 @nutui/icons-react-taro 的变更日志:"
rg "2\.0\.0-beta\.0" -A 5 "CHANGELOG.md"

# 检查 InputNumber 组件中图标的使用方式
echo "\n检查 InputNumber 组件中图标的使用:"
rg "import.*@nutui/icons-react-taro" -A 5 "src/packages/inputnumber/inputnumber.taro.tsx"

# 检查其他组件中图标的使用方式
echo "\n检查其他组件中图标的使用:"
rg "import.*@nutui/icons-react-taro" -A 5 "src/packages/**/(?!inputnumber)*.tsx"

Length of output: 762


Script:

#!/bin/bash
# 检查最近的提交记录,了解图标相关的变更
echo "检查最近的图标相关提交:"
git log --grep="icon" --grep="@nutui/icons-react-taro" -n 5 --oneline

# 检查 InputNumber 组件的最近改动
echo "\n检查 InputNumber 组件的最近改动:"
git log -p -n 1 -- "src/packages/inputnumber/inputnumber.taro.tsx"

# 检查其他使用此图标库的组件
echo "\n检查其他使用此图标库的文件:"
rg "from ['|\"]@nutui/icons-react-taro['|\"]" --type ts --type tsx

Length of output: 4345

src/styles/variables.scss (1)

632-632: 按钮宽度调整符合设计规范

$inputnumber-button-width 从 14px 调整为 16px,使其与 --nut-icon-width 保持一致,这样可以确保组件间的视觉统一性。

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/inputnumber/inputnumber.taro.tsx (1)

Line range hint 262-289: 建议优化平台特定的输入处理逻辑

当前实现中,TaroInput 和标准 input 的属性和事件处理有大量重复。建议进行以下优化:

  1. 抽取共同的属性和事件处理器
  2. 使用类型安全的方式处理平台差异

建议按照以下方式重构:

+ const commonInputProps = {
+   className: classNames(`${classPrefix}-input`, {
+     [`${classPrefix}-input-disabled`]: disabled,
+   }),
+   type,
+   ref: inputRef,
+   disabled: disabled || readOnly,
+   value: inputValue,
+   onInput: handleInputChange,
+   onBlur: handleBlur,
+   onFocus: handleFocus,
+ }

  {isRnAndHarmony ? (
-   <TaroInput
-     className={classNames(`${classPrefix}-input`, {
-       [`${classPrefix}-input-disabled`]: disabled,
-     })}
-     type={type}
-     ref={inputRef}
-     disabled={disabled || readOnly}
-     value={inputValue}
-     onInput={handleInputChange}
-     onBlur={handleBlur}
-     onFocus={handleFocus}
-   />
+   <TaroInput {...commonInputProps} />
  ) : (
-   <input
-     className={classNames(`${classPrefix}-input`, {
-       [`${classPrefix}-input-disabled`]: disabled,
-     })}
-     type={type}
-     ref={inputRef}
-     inputMode={type === 'digit' ? 'decimal' : 'numeric'}
-     disabled={disabled}
-     readOnly={readOnly}
-     value={inputValue}
-     onInput={handleInputChange}
-     onBlur={handleBlur}
-     onFocus={handleFocus}
-   />
+   <input
+     {...commonInputProps}
+     inputMode={type === 'digit' ? 'decimal' : 'numeric'}
+     readOnly={readOnly}
+   />
  )}
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 9160682 and 18e41cc.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (8)
  • package.json (1 hunks)
  • src/packages/inputnumber/doc.en-US.md (1 hunks)
  • src/packages/inputnumber/doc.md (1 hunks)
  • src/packages/inputnumber/doc.taro.md (1 hunks)
  • src/packages/inputnumber/doc.zh-TW.md (1 hunks)
  • src/packages/inputnumber/inputnumber.harmony.css (2 hunks)
  • src/packages/inputnumber/inputnumber.taro.tsx (3 hunks)
  • src/styles/variables.scss (1 hunks)
✅ Files skipped from review due to trivial changes (5)
  • src/packages/inputnumber/doc.en-US.md
  • src/packages/inputnumber/doc.md
  • src/packages/inputnumber/doc.taro.md
  • src/packages/inputnumber/doc.zh-TW.md
  • src/packages/inputnumber/inputnumber.harmony.css
🔇 Additional comments (3)
src/packages/inputnumber/inputnumber.taro.tsx (1)

253-260: 图标渲染逻辑优化得当!

新的图标实现采用了统一的渲染方式,通过类名动态控制禁用状态,代码更加清晰简洁。同时正确处理了边界值(最大值/最小值)的禁用状态。

Also applies to: 293-300

package.json (1)

107-107: ⚠️ Potential issue

需要注意依赖包版本升级的风险

@nutui/icons-react-taro^1.0.5 升级到 ^2.0.0-beta.0 存在以下风险:

  1. 这是一个主版本号的升级(从1.x升级到2.x),可能包含破坏性更改
  2. 使用beta版本可能存在稳定性问题

建议:

  • 在合并前完整测试所有使用到图标的场景
  • 记录并更新迁移文档,说明任何需要适配的改动

运行以下脚本来检查项目中使用到此图标库的地方:

src/styles/variables.scss (1)

632-632: 确认变量修改的影响范围

$inputnumber-button-width 从 14px 调整为 16px,这个改动会影响到 InputNumber 组件的按钮宽度。需要确保:

  1. 此更改与设计规范中的 --nut-icon-width 保持一致
  2. 相关组件的样式布局不会因为这个宽度变化而产生异常
✅ Verification successful

InputNumber组件按钮宽度变更已验证无影响

经过验证,此变更是安全的:

  1. $inputnumber-button-width 变量仅在 InputNumber 组件内部使用,且与组件内部定义的图标宽度 --nut-icon-width: 16px 保持一致
  2. 组件文档中已明确声明按钮宽度为 16px
  3. 此变更不会影响其他组件,因为:
    • 变量作用域仅限于 InputNumber 组件
    • 其他组件都使用各自独立的宽度变量
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# 描述:验证是否有其他组件依赖此变量,以及相关的样式文件

# 测试:搜索使用了这个变量的文件
rg --type scss '\$inputnumber-button-width'

# 测试:搜索相关的 CSS 自定义属性
rg --type scss 'nutui-inputnumber-button-width'

Length of output: 151


Script:

#!/bin/bash
# Search for files containing the variable name or CSS custom property
rg '\$inputnumber-button-width|--nutui-inputnumber-button-width'

# Find all scss files that might be related to InputNumber component
fd -e scss -e css | grep -i 'input\|number'

Length of output: 1385


Script:

#!/bin/bash
# Check the actual implementation in inputnumber.scss to understand the variable usage
cat src/packages/inputnumber/inputnumber.scss

# Check if there are any related icon width variables in the codebase
rg 'icon.*width|--nut-icon-width'

Length of output: 19580

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/inputnumber/inputnumber.taro.tsx (1)

Line range hint 262-289: 建议优化输入框宽度计算

考虑到图标宽度的调整,建议确保输入框的宽度计算能够正确适配:

  1. 在不同平台下保持一致的显示效果
  2. 考虑新的图标宽度对整体布局的影响

建议在样式中使用 CSS 变量来动态计算输入框宽度:

+ /* 在相应的样式文件中添加 */
+ .nut-inputnumber-input {
+   width: calc(100% - 2 * var(--nut-icon-width));
+ }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 9160682 and 18e41cc.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (8)
  • package.json (1 hunks)
  • src/packages/inputnumber/doc.en-US.md (1 hunks)
  • src/packages/inputnumber/doc.md (1 hunks)
  • src/packages/inputnumber/doc.taro.md (1 hunks)
  • src/packages/inputnumber/doc.zh-TW.md (1 hunks)
  • src/packages/inputnumber/inputnumber.harmony.css (2 hunks)
  • src/packages/inputnumber/inputnumber.taro.tsx (3 hunks)
  • src/styles/variables.scss (1 hunks)
✅ Files skipped from review due to trivial changes (4)
  • src/packages/inputnumber/doc.en-US.md
  • src/packages/inputnumber/doc.md
  • src/packages/inputnumber/doc.zh-TW.md
  • src/packages/inputnumber/inputnumber.harmony.css
🔇 Additional comments (8)
src/packages/inputnumber/doc.taro.md (1)

142-142: 按钮宽度变量更新已确认

CSS变量 --nutui-inputnumber-button-width 的值从 14px 更新到 16px 的修改是合理的,这与PR的目标保持一致。

运行以下脚本以验证其他文件中的一致性:

✅ Verification successful

Let me generate one more verification to check the previous value and ensure this is indeed a change:


按钮宽度变量更新验证完成

经过验证,CSS变量 --nutui-inputnumber-button-width 的值从 14px 更新到 16px 的修改已在以下文件中统一实现:

  • 所有文档文件(.md)中的默认值已更新为 16px
  • 所有样式变量文件(variables.scss, variables-jmapp.scss, variables-jrkf.scss)中的默认值已更新为 16px

这个改动保持了组件样式的一致性,符合设计规范的统一要求。

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# 描述:验证所有文件中按钮宽度的一致性

# 测试:搜索所有包含 nutui-inputnumber-button-width 的文件
rg --type-add 'style:*.{css,less,scss}' --type-add 'doc:*.md' -t style -t doc 'nutui-inputnumber-button-width'

Length of output: 1130


Script:

#!/bin/bash
# 检查git历史中这些文件的变更,查看之前的宽度值
git log -p -- src/styles/variables.scss src/styles/variables-jmapp.scss src/styles/variables-jrkf.scss | grep -A 1 "inputnumber-button-width"

Length of output: 1900

src/packages/inputnumber/inputnumber.taro.tsx (3)

18-18: 平台检测逻辑优化得当!

通过引入统一的 harmonyAndRn 工具函数来处理平台检测,简化了代码并提高了可维护性。


293-300: 加号图标实现符合规范!

实现方式与减号图标保持一致,类名设置合理,状态处理完善。


253-260: 请确认图标宽度适配

图标组件的样式类设置正确,但需要验证:

  1. 图标宽度是否与 --nut-icon-width 变量保持一致
  2. 禁用状态样式是否正确应用
✅ Verification successful

Let me verify the disabled state styling by checking the CSS implementation:


Let me check the specific disabled state styling implementation:


图标样式配置正确,无需调整

经验证:

  • 图标宽度已通过 --nut-icon-width: 16px 正确设置,与 $inputnumber-button-width 保持一致
  • 禁用状态样式已正确实现,包含颜色变化和鼠标样式
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# 检查相关的样式文件中是否正确设置了图标宽度
rg --type css "nut-icon-width|inputnumber-(icon|button)-width"

Length of output: 676


Script:

#!/bin/bash
# 检查禁用状态的样式实现
rg --type css "icon-disabled" src/packages/inputnumber/

Length of output: 137


Script:

#!/bin/bash
# 检查禁用状态样式的具体实现
rg -A 3 "icon-disabled" src/packages/inputnumber/

Length of output: 1505

package.json (2)

107-107: ⚠️ Potential issue

注意:重大版本更新可能带来破坏性变更

@nutui/icons-react-taro^1.0.5 更新到 ^2.0.0-beta.0 是一个重大版本升级:

  • 这是一个测试版本,API 可能不稳定
  • 2.0 版本可能包含破坏性变更
  • 建议在合并前进行完整的回归测试
#!/bin/bash
# 检查是否有其他依赖项使用了 @nutui/icons-react-taro
rg "@nutui/icons-react-taro" --type ts

107-107: 建议:确保图标宽度在所有组件中保持一致

由于此 PR 的目标是统一图标宽度,请确保:

  1. 新版本的图标组件与 --nut-icon-width 变量保持一致
  2. 所有使用到图标的组件都能正确适配新的宽度
✅ Verification successful

图标宽度已在样式变量中统一定义,且新版本组件正确使用

根据验证结果:

  1. 全局图标宽度通过 --nutui-icon-width 变量统一定义为 20px(见 variables.scss)
  2. 特定组件如 Tour、InputNumber 等有自定义宽度需求,已通过局部覆盖变量实现
  3. 新版本 @nutui/icons-react-taro 组件已在各处正确引用并遵循统一宽度规范
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# 检查所有使用图标的组件
rg "import.*@nutui/icons-react-taro" --type ts

# 检查图标宽度相关的样式定义
rg "(--nut-icon-width|icon.*width)" --type scss

Length of output: 14215


Script:

#!/bin/bash
# Search for icon width related styles in all CSS/SCSS/LESS files
rg "(--nut-icon-width|icon.*width)" --type css

# Search for icon width related styles in all TypeScript/JavaScript files
rg "(--nut-icon-width|icon.*width)" --type ts --type js

# Check if there are any style files specifically for icons
fd -e css -e scss -e less | grep -i "icon"

Length of output: 10127

src/styles/variables.scss (2)

632-633: 图标尺寸定义正确!

图标宽度和高度变量定义合理,保持了一致性。


632-632: 请验证按钮宽度与图标系统的一致性

按钮宽度已更新为16px,需要确认此更改是否与整个图标系统保持一致。

✅ Verification successful

Let me search specifically for inputnumber-related width configurations to verify the consistency.


按钮宽度变更已确认与图标系统保持一致

经验证,InputNumber组件中的按钮宽度(16px)已与组件内部使用的图标宽度(--nut-icon-width: 16px)保持一致,符合设计规范要求。

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# 描述:验证其他组件中是否还存在使用旧的按钮宽度值(14px)的情况

# 测试:搜索可能使用旧宽度值的文件
rg -l "14px" "src/packages"

Length of output: 5630


Script:

#!/bin/bash
# 搜索inputnumber组件中的宽度相关配置
rg -A 2 "width" "src/packages/inputnumber/inputnumber.scss"

# 搜索variables.scss中的icon相关宽度配置
rg "icon.*width|width.*icon" "src/styles/variables.scss"

Length of output: 906

@pull-request-size pull-request-size bot added size/M and removed size/L labels Nov 8, 2024
@xiaoyatong xiaoyatong changed the title fix: icon 适配 && 修改icon宽度和设定的--nut-icon-width一致 fix(inputnumber): icon 适配 && 修改icon宽度和设定的--nut-icon-width一致 Nov 9, 2024
@xiaoyatong xiaoyatong merged commit 9338353 into jdf2e:V3.0 Nov 9, 2024
6 checks passed
oasis-cloud added a commit to oasis-cloud/nutui-react that referenced this pull request Nov 9, 2024
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.

2 participants