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: ✨ ToolTip 组件 offset 属性支持数组和对象写法 #625

Merged
merged 2 commits into from
Sep 29, 2024

Conversation

RYGRIT
Copy link
Contributor

@RYGRIT RYGRIT commented Sep 23, 2024

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

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

🔗 相关 Issue

560

💡 需求背景和解决方案

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

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

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

Summary by CodeRabbit

  • 新功能
    • 提升了 Tooltip 组件的 offset 属性,支持多种类型(单个数字、数字数组或对象),并设定了默认值 {x:0, y:0},增强了偏移配置的灵活性。

Copy link

vercel bot commented Sep 23, 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 Sep 24, 2024 0:41am

Copy link

coderabbitai bot commented Sep 23, 2024

Walkthrough

本次变更涉及对 Tooltip 组件的 offset 属性的修改,将其类型从 number 更改为 number[],并指定了默认值 {x:0, y:0}。此外,usePopover 函数的 offset 参数类型也进行了扩展,支持多种格式,包括 numbernumber[] 和包含 xy 属性的对象。最后,tooltipPropsoffset 属性也进行了相应更新,以支持更灵活的配置。

Changes

文件路径 变更摘要
docs/component/tooltip.md offset 属性类型从 number 更改为 number[],默认值更新为 {x:0, y:0}
src/uni_modules/wot-design-uni/components/composables/usePopover.ts offset 参数类型从 number 扩展为 `number
src/uni_modules/wot-design-uni/components/wd-tooltip/types.ts tooltipProps 中的 offset 属性类型更新为 `PropType<number

Possibly related PRs

🐇 在这变化的时刻,
我们的组件更灵活,
offset 变成了数组,
让位置更自由飞舞。
感谢代码的魔法,
让每个细节都闪耀! ✨


Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between ef7416e and 6b4c1b1.

Files selected for processing (1)
  • src/uni_modules/wot-design-uni/components/composables/usePopover.ts (3 hunks)
Files skipped from review as they are similar to previous changes (1)
  • src/uni_modules/wot-design-uni/components/composables/usePopover.ts

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 Sep 23, 2024

Deploy Preview for wot-design-uni ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 6b4c1b1
🔍 Latest deploy log https://app.netlify.com/sites/wot-design-uni/deploys/66f20a5c28e90b0008771835
😎 Deploy Preview https://deploy-preview-625--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: 1

Outside diff range and nitpick comments (3)
src/uni_modules/wot-design-uni/components/wd-tooltip/types.ts (1)

62-67: 代码更改看起来不错,建议稍微调整注释

这个更改很好地实现了PR的目标,允许offset属性接受更灵活的输入类型。代码逻辑正确,类型定义全面。

建议更新属性注释以反映新的类型支持:

  /**
-  * 出现位置的偏移量
-  * 类型:number
+  * 出现位置的偏移量
+  * 类型:number | [number, number] | { x: number, y: number }
   * 默认值:0
   */
docs/component/tooltip.md (1)

160-160: 更新很好,但需要一些小改动

offset 属性的更新增加了灵活性,这是一个很好的改进。然而,有几点需要注意:

  1. $LOWEST_VERSION$ 占位符需要替换为实际的版本号。
  2. 建议在文档中添加使用新输入类型的示例,以帮助用户理解如何使用数组和对象格式的 offset。

建议添加如下示例:

<!-- 使用数组格式 -->
<wd-tooltip :offset="[10, 20]" content="使用数组偏移">
  <wd-button>数组偏移</wd-button>
</wd-tooltip>

<!-- 使用对象格式 -->
<wd-tooltip :offset="{ x: 15, y: 25 }" content="使用对象偏移">
  <wd-button>对象偏移</wd-button>
</wd-tooltip>
Tools
Markdownlint

160-160: Expected: 6; Actual: 8; Too many cells, extra data will be missing
Table column count

(MD056, table-column-count)

src/uni_modules/wot-design-uni/components/composables/usePopover.ts (1)

105-106: 移除不必要的注释代码

注释掉的旧代码可能会造成混淆,降低代码可读性。既然已经有新的实现,建议删除这些不再需要的注释代码。

建议删除以下代码:

- // const offsetX = (verticalX - 17 > 0 ? 0 : verticalX - 25) + offset
- // const offsetY = (horizontalY - 17 > 0 ? 0 : horizontalY - 25) + offset
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between c445bd1 and ef7416e.

Files selected for processing (3)
  • docs/component/tooltip.md (1 hunks)
  • src/uni_modules/wot-design-uni/components/composables/usePopover.ts (3 hunks)
  • src/uni_modules/wot-design-uni/components/wd-tooltip/types.ts (1 hunks)
Additional context used
Markdownlint
docs/component/tooltip.md

160-160: Expected: 6; Actual: 8; Too many cells, extra data will be missing
Table column count

(MD056, table-column-count)

Additional comments not posted (2)
src/uni_modules/wot-design-uni/components/composables/usePopover.ts (2)

2-2: 已正确导入 isObj 函数

引入了 isObj 函数,方便在后续代码中判断 offset 是否为对象,增强了代码的健壮性。


80-80: 请验证 control 函数的所有调用是否已更新为新的 offset 参数类型

control 函数的 offset 参数类型已从 number 扩展为 number | number[] | Record<'x' | 'y', number>。为了确保代码的稳定性,需要确认所有调用 control 函数的地方都已适配新的参数类型,避免类型错误。

运行以下脚本,查找所有对 control 函数的调用,并检查参数使用情况:

@Moonofweisheng Moonofweisheng merged commit 5092c5a into Moonofweisheng:master Sep 29, 2024
6 checks passed
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.

2 participants