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: 🐛 修复直接使用title插槽不设置closeText时不显示title插槽内容,新增radius属性,header插槽 #760

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

icjs-cc
Copy link

@icjs-cc icjs-cc commented Dec 5, 2024

🤔 这个 PR 的性质是?(至少选择一个)

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

🔗 相关 Issue

💡 需求背景和解决方案

在开发过程中,只设置title插槽的情况下,插槽不生效,由于判断条件只判断title值和closeText值导致该BUG,增加slots.title的判断解决该问题;某种情况下弹出框需要设置radius因此加入radius属性,解决某些产品UI弹出框的一致性;在使用组件过程中发现title插槽不满足需求,高度有限制,在实际使用过程中需要在NumberKeyboard顶部设置一些其他元素,例如输入框、用户基础信息等,因此加入header插槽,增加组件的拓展性。

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

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

  • 文档已补充或无须补充
  • 代码演示已提供或无须提供
  • TypeScript 定义已补充或无须补充

Summary by CodeRabbit

  • 新特性

    • 支持自定义键盘顶部的 header 插槽。
    • 引入 random-key-order 属性以增强安全性。
    • 更新 extra-key 属性,支持多个额外键的数组形式。
    • 新增 radius 属性以自定义背景圆角。
  • 文档

    • 更新了 wd-number-keyboard 组件的文档,增加了新特性和使用示例。

Copy link

vercel bot commented Dec 5, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
wot-design-uni ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 5, 2024 2:48am

Copy link

coderabbitai bot commented Dec 5, 2024

Walkthrough

此次更改主要集中在wd-number-keyboard组件的文档和实现上。文档更新包括新特性、使用示例、属性和事件的说明,以及样式信息的补充。同时,组件的实现也进行了相应的修改,新增了header插槽和random-key-order属性,并更新了extra-key属性以支持数组。此外,组件中引入了新的radius属性,允许自定义背景角半径,从而增强了组件的灵活性和可定制性。

Changes

文件路径 更改摘要
docs/component/number-keyboard.md 更新文档以添加新特性(header插槽、random-key-order属性、增强的extra-key属性),提供多个使用示例,更新属性和事件表,添加样式信息。
src/uni_modules/wot-design-uni/components/wd-number-keyboard/types.ts numberKeyboardProps中添加新属性radius,更新导入语句以包含numericProp
src/uni_modules/wot-design-uni/components/wd-number-keyboard/wd-number-keyboard.vue 添加:custom-style属性,更新模板以包含header插槽,增加rootStyle计算属性,改进键处理逻辑。

Possibly related PRs

Suggested reviewers

  • Moonofweisheng

兔子在草地上跳跃,
数字键盘新变化,
插槽、属性齐更新,
自定义样式真精彩!
让我们一起欢庆吧! 🐇✨


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.

Copy link

netlify bot commented Dec 5, 2024

Deploy Preview for wot-design-uni ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit de3bbbb
🔍 Latest deploy log https://app.netlify.com/sites/wot-design-uni/deploys/67511417bd43360008f12529
😎 Deploy Preview https://deploy-preview-760--wot-design-uni.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

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 (2)
src/uni_modules/wot-design-uni/components/wd-number-keyboard/wd-number-keyboard.vue (1)

76-82: 圆角样式实现可以优化

当前实现方式正确,但建议添加单位验证以提高代码健壮性。

建议如下修改:

 const rootStyle = computed(() => {
   const style: Record<string, string | number> = {}
   if (isDef(props.radius)) {
+    const radius = String(props.radius).includes('px') ? props.radius : `${props.radius}px`
-    style['border-radius'] = `${addUnit(props.radius)} ${addUnit(props.radius)} 0 0`
+    style['border-radius'] = `${radius} ${radius} 0 0`
     style['overflow'] = 'hidden'
   }
   return `${objToStyle(style)};`
 })
docs/component/number-keyboard.md (1)

246-246: header 插槽文档需要补充

建议为 header 插槽添加更详细的说明和使用示例。

建议添加以下内容:

| name   | 说明 | 类型 | 最低版本 |
| ------ | ---- | ---- | -------- |
| title  | 标题 | -    | 1.2.12   |
-| header | 顶部 | -    |         |
+| header | 顶部区域,可用于放置输入框等自定义内容 | - | 1.2.13 |
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 356cb4a and de3bbbb.

📒 Files selected for processing (3)
  • docs/component/number-keyboard.md (1 hunks)
  • src/uni_modules/wot-design-uni/components/wd-number-keyboard/types.ts (2 hunks)
  • src/uni_modules/wot-design-uni/components/wd-number-keyboard/wd-number-keyboard.vue (3 hunks)
🔇 Additional comments (4)
src/uni_modules/wot-design-uni/components/wd-number-keyboard/types.ts (1)

78-82: 类型定义看起来不错!

radius 属性的类型定义正确,并且使用了 numericProp 来确保类型安全。

src/uni_modules/wot-design-uni/components/wd-number-keyboard/wd-number-keyboard.vue (3)

14-14: 新增的 header 插槽实现正确

header 插槽的位置合理,可以让用户自定义键盘顶部的内容。


71-74: 标题显示逻辑优化得当

通过 useSlots() 检查 title 插槽的存在性,修复了之前的问题。现在即使没有设置 closeText,title 插槽的内容也能正确显示。


Line range hint 89-98: 随机数组打乱算法实现正确

使用 Fisher-Yates 洗牌算法来随机打乱数组,实现方式安全可靠。

@icjs-cc
Copy link
Author

icjs-cc commented Dec 5, 2024

image

目前基于实际项目中的需求改进该组件,希望作者支持下哈~

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant