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(input): update icon #2711

Merged
merged 1 commit into from
Nov 8, 2024
Merged

Conversation

oasis-cloud
Copy link
Collaborator

@oasis-cloud oasis-cloud commented Nov 8, 2024

🤔 这个变动的性质是?

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

🔗 相关 Issue

💡 需求背景和解决方案

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

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

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

Summary by CodeRabbit

  • 新功能

    • 始终显示 Tips 组件,简化了控制逻辑。
    • 新增 CSS 类 .nut-input-clear,提供新的样式选项。
  • 改进

    • 简化了 Input 组件中清除图标的渲染逻辑。
    • 改进了输入事件处理,确保正确捕获输入值。

Copy link

coderabbitai bot commented Nov 8, 2024

Walkthrough

该拉取请求对多个组件进行了修改,主要集中在简化条件渲染逻辑。Demo13Demo6Demo9组件的条件渲染被移除,确保某些组件始终渲染。Input组件的事件处理逻辑也进行了改进,以更可靠地提取输入值。此外,新增了一个CSS类.nut-input-clear,用于更灵活的样式设置。

Changes

文件路径 变更摘要
src/packages/input/demos/taro/demo13.tsx 移除条件渲染逻辑,确保Tips组件始终渲染。
src/packages/input/demos/taro/demo6.tsx 移除clearIcon的条件渲染,直接赋值为<Close />,并移除不再需要的导入语句。
src/packages/input/demos/taro/demo9.tsx 移除条件渲染逻辑,确保在inputType为'text'时始终渲染Eye图标。
src/packages/input/input.scss 新增CSS类.nut-input-clear,设置flex: 0;以防止在弹性容器中增长或缩小。
src/packages/input/input.taro.tsx 更新onInput事件处理逻辑,确保正确提取输入值,并简化清除图标的条件渲染逻辑。

Possibly related PRs

Suggested labels

size/L, 3.x

Suggested reviewers

  • oasis-cloud
  • Alex-huxiyang

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

codecov bot commented Nov 8, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

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

Additional details and impacted files
@@           Coverage Diff           @@
##             V3.0    #2711   +/-   ##
=======================================
  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 (6)
src/packages/input/demos/taro/demo6.tsx (1)

15-15: 直接使用Close组件作为clearIcon是个好的改进

移除了平台相关的条件判断,使代码更加简洁直观。这种改变:

  • 降低了代码复杂度
  • 提高了可维护性
  • 使组件行为更加一致和可预测

建议考虑添加注释说明自定义图标的使用场景,例如:

 <Input
   clearable
-  clearIcon={<Close />}
+  // 使用自定义清除图标替代默认图标
+  clearIcon={<Close />}
   placeholder="显示清除图标"
   placeholderTextColor="#757575"
 />
src/packages/input/input.scss (1)

51-53: 建议优化清除图标的样式控制

为了更精确地控制清除图标的布局和尺寸,建议考虑添加以下属性:

 .nut-input-clear {
   flex: 0;
+  flex-shrink: 0;
+  display: flex;
+  align-items: center;
+  justify-content: center;
+  min-width: 16px;  /* 确保图标最小尺寸 */
 }
src/packages/input/demos/taro/demo13.tsx (3)

19-19: 建议为 Tips 图标添加提示信息

Tips 图标应该向用户传达某些信息,建议添加 tooltip 或其他提示性内容来提高用户体验。

-        <Tips style={{ marginLeft: pxTransform(10) }} />
+        <Tips 
+          style={{ marginLeft: pxTransform(10) }} 
+          onClick={() => {
+            // 显示提示信息
+          }}
+        />

Line range hint 21-24: 建议增强输入框的可访问性和验证功能

当前输入框缺少必要的验证和可访问性属性。

         <Input
           placeholder="请输入短信验证码"
           placeholderTextColor="#757575"
+          type="number"
+          maxLength={6}
+          aria-label="短信验证码输入框"
+          pattern="[0-9]*"
+          inputMode="numeric"
           style={{ '--nutui-input-padding': '10px' }}
         />

Line range hint 19-38: 建议完善验证码功能的状态管理

组件缺少验证码倒计时和输入值验证的状态管理。

建议:

  1. 添加验证码输入值的状态管理
  2. 实现发送验证码按钮的倒计时功能
  3. 添加验证码验证逻辑

您需要我帮您实现这些功能吗?我可以为您创建一个包含完整状态管理的示例。

src/packages/input/demos/taro/demo9.tsx (1)

37-40: 代码简化改动符合预期!

移除 harmonyAndRn() 条件检查简化了代码逻辑,使组件更易于维护。

不过建议为切换密码可见性的按钮添加无障碍支持。

 <View
   style={{
     display: 'flex',
     marginRight: pxTransform(10),
     alignItems: 'center',
   }}
+  role="button"
+  aria-label={inputType === 'text' ? '隐藏密码' : '显示密码'}
   onClick={() =>
     setInputType(inputType === 'text' ? 'password' : 'text')
   }
 >
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 16b173e and 49a17e7.

📒 Files selected for processing (5)
  • src/packages/input/demos/taro/demo13.tsx (1 hunks)
  • src/packages/input/demos/taro/demo6.tsx (1 hunks)
  • src/packages/input/demos/taro/demo9.tsx (1 hunks)
  • src/packages/input/input.scss (1 hunks)
  • src/packages/input/input.taro.tsx (2 hunks)
🔇 Additional comments (4)
src/packages/input/demos/taro/demo6.tsx (1)

Line range hint 1-21: 代码结构清晰,示例实现合理!

该演示组件通过两个示例很好地展示了Input组件的清除功能:

  1. 使用默认清除图标
  2. 使用自定义清除图标

这种结构使开发者能够清楚地理解不同使用场景。

src/packages/input/input.scss (1)

51-53: 新增的清除图标样式符合规范!

新增的 .nut-input-clear 类通过 flex: 0 确保了清除图标不会在 flex 容器中伸缩,这与组件的设计意图相符。

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

263-263: 清除图标渲染逻辑优化得当

移除了 harmonyAndRn() 检查,简化了条件渲染逻辑,使代码更加清晰和易于维护。当未提供 clearIcon 时,默认使用 MaskClose 组件是个不错的选择。


243-243: 优化了输入事件值的获取逻辑

修改后的事件处理逻辑更符合 Taro 框架的标准实践,优先使用 e.detail 获取输入值。

运行以下脚本验证其他输入组件是否需要类似优化:

@xiaoyatong xiaoyatong merged commit d53f051 into jdf2e:V3.0 Nov 8, 2024
6 checks passed
@coderabbitai coderabbitai bot mentioned this pull request Dec 22, 2024
20 tasks
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