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(dropdown-item): [dropdown] fix issues for v-auto-tip and add effect attr #2283

Merged

Conversation

MomoPoppy
Copy link
Collaborator

@MomoPoppy MomoPoppy commented Oct 16, 2024

…ct attr

PR

PR Checklist

Please check if your PR fulfills the following requirements:

  • The commit message follows our Commit Message Guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • Other... Please describe:

What is the current behavior?

Issue Number: N/A

What is the new behavior?

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

Summary by CodeRabbit

  • New Features
    • Introduced a new effect property for dropdown items, allowing for enhanced tooltip customization.
  • Improvements
    • Updated tooltip behavior to conditionally apply based on the presence of getTip, improving flexibility and user experience.
  • Version Update
    • Incremented version of the @opentiny/vue-dropdown-item package from 3.18.0 to 3.18.1.

Copy link

coderabbitai bot commented Oct 16, 2024

Walkthrough

The pull request introduces changes to the dropdownItemProps object by adding a new property called effect, which is a string with a default value of 'light'. Additionally, it modifies the tipPosition property for improved formatting. In the pc.vue file, updates are made to the template and script sections, particularly regarding the v-auto-tip directive, which now conditionally applies based on the presence of getTip. The props array is also updated to include the new effect property.

Changes

File Path Change Summary
packages/vue/src/dropdown-item/src/index.ts Added effect property to dropdownItemProps and modified tipPosition formatting.
packages/vue/src/dropdown-item/src/pc.vue Updated template and script to conditionally apply v-auto-tip and included effect in props.
packages/vue/src/dropdown-item/package.json Updated version from 3.18.0 to 3.18.1.

Possibly related PRs

Suggested labels

bug, enhancement

Suggested reviewers

  • zzcr

🐰 In the dropdown where tips do play,
A new effect brightens the way!
With lightness and flair,
Tooltips now care,
Enhancing our Vue, come what may! 🌟


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between d95191f and f4011f3.

📒 Files selected for processing (1)
  • packages/vue/src/dropdown-item/package.json (2 hunks)
✅ Files skipped from review due to trivial changes (1)
  • packages/vue/src/dropdown-item/package.json

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

@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 (3)
packages/vue/src/dropdown-item/src/index.ts (1)

88-90: Approve addition of effect property, but documentation needed.

The new effect property has been successfully added to dropdownItemProps. This appears to introduce a new customization option for dropdown items, which is a good enhancement.

However, to ensure proper usage and maintainability:

  1. Please add a comment explaining the purpose of this property.
  2. Document the possible values it can take (e.g., 'light', 'dark', etc.).
  3. If applicable, update the component's documentation to reflect this new property.

Consider adding a comment like this above the property:

  /**
   * The visual effect of the dropdown item.
   * Possible values: 'light' (default), 'dark', etc.
   */
  effect: {
    type: String,
    default: 'light'
  }
packages/vue/src/dropdown-item/src/pc.vue (2)

16-16: Improved tooltip flexibility and customization.

The changes to the v-auto-tip directive enhance the component's flexibility by conditionally applying the tooltip based on the presence of getTip. The addition of effect and placement properties also improves customization options.

Consider extracting the tooltip configuration object into a computed property for better readability and maintainability. For example:

<script setup>
// ...
const tooltipConfig = computed(() => 
  getTip ? { always: true, content: getTip, effect, placement: tipPosition } : false
)
</script>

<template>
  <li v-auto-tip="tooltipConfig" ...>
    <!-- ... -->
  </li>
</template>

This approach would make the template cleaner and allow for easier testing and modification of the tooltip configuration.


99-100: New 'effect' prop added and improved readability.

The addition of the 'effect' prop and the separation of props onto individual lines improve the component's customization options and code readability.

Consider enhancing the prop definitions by using the full object notation for better type checking and documentation:

props: {
  // ... other props
  tipPosition: {
    type: String,
    default: 'top'
  },
  effect: {
    type: String,
    default: 'light',
    validator: (value) => ['light', 'dark'].includes(value)
  }
}

This approach provides better type checking, default values, and allows for value validation, improving the robustness of the component.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 7561208 and d95191f.

📒 Files selected for processing (2)
  • packages/vue/src/dropdown-item/src/index.ts (1 hunks)
  • packages/vue/src/dropdown-item/src/pc.vue (2 hunks)
🧰 Additional context used
🔇 Additional comments (3)
packages/vue/src/dropdown-item/src/index.ts (2)

87-87: LGTM: Improved formatting for tipPosition property.

The tipPosition property has been moved to its own line, which improves the overall readability of the dropdownItemProps object. This change is purely cosmetic and doesn't affect functionality.


87-90: Overall assessment: Good improvements, minor documentation needed.

The changes to this file are minimal and focused, improving both functionality and readability:

  1. The formatting change for tipPosition enhances code readability.
  2. The addition of the effect property introduces a new customization option for dropdown items.

These changes align well with the PR objectives of fixing issues and adding attributes to the dropdown component. The only recommendation is to add documentation for the new effect property to ensure clear understanding and proper usage.

packages/vue/src/dropdown-item/src/pc.vue (1)

Line range hint 1-111: Overall assessment: Improvements align with PR objectives.

The changes made to the dropdown item component successfully address the issues related to v-auto-tip and add the effect attribute as intended. The modifications enhance the component's flexibility and customization options, which aligns well with the PR objectives.

Key improvements:

  1. Conditional application of the tooltip based on getTip.
  2. Addition of effect and placement properties for tooltip customization.
  3. New effect prop for additional styling options.

While the changes are generally good, consider implementing the suggested improvements:

  1. Extract the tooltip configuration into a computed property for better maintainability.
  2. Enhance prop definitions with full object notation for improved type checking and documentation.

These refinements will further improve the component's robustness and maintainability.

@@ -13,7 +13,7 @@
<template>
<!-- TINY-TODO: tiny-dropdown-menu__item命名不规范,后续统一有个迭代去掉 -->
<li
v-auto-tip="{ always: true, content: getTip, effect: 'dark', placement: tipPosition }"
v-auto-tip="getTip ? { always: true, content: getTip, effect, placement: tipPosition } : false"
Copy link
Member

Choose a reason for hiding this comment

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

升级下这个组件包的版本号,这样才可以用github-action去发包

@zzcr zzcr merged commit cf5f8ea into opentiny:release-3.18.0 Oct 17, 2024
5 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