Skip to content

Conversation

@Elm1992
Copy link
Contributor

@Elm1992 Elm1992 commented Jul 17, 2025

Description

想用 radix-vue Dialog 自带的效果, 万一拓展新的动画效果用 animationType 也算是留个接口。

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update
  • Please, don't make changes to pnpm-lock.yaml unless you introduce a new test example.

Summary by CodeRabbit

  • New Features

    • Added support for selecting modal animation type, allowing users to choose between "slide" (default) and "scale" effects when opening or closing modals.
    • Updated documentation and provided a demo showcasing both animation options for modals.
  • Documentation

    • Extended modal component documentation with details and examples for the new animation type property.

@Elm1992 Elm1992 requested review from a team, anncwb, jinmao88, mynetfan and vince292007 as code owners July 17, 2025 16:21
@changeset-bot
Copy link

changeset-bot bot commented Jul 17, 2025

⚠️ No Changeset found

Latest commit: 260e45c

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jul 17, 2025

Walkthrough

A new animationType property was introduced to the modal component system, allowing selection between 'slide' and 'scale' animations. This property was added to relevant TypeScript interfaces, Vue components, and documentation. A demonstration component and documentation updates illustrate and describe the new animation options.

Changes

File(s) Change Summary
docs/src/components/common-ui/vben-modal.md Documented new animationType prop, updated props table, and added a demo preview section.
docs/src/demos/vben-modal/animation-type/index.vue Added a new demo Vue component showcasing both slide and scale modal animations.
packages/@core/ui-kit/popup-ui/src/modal/modal-api.ts Added animationType: 'slide' default property to modal state in ModalApi.
packages/@core/ui-kit/popup-ui/src/modal/modal.ts Added optional `animationType?: 'scale'
packages/@core/ui-kit/popup-ui/src/modal/modal.vue Passed animationType prop to DialogContent component in the modal template.
packages/@core/ui-kit/shadcn-ui/src/ui/dialog/DialogContent.vue Added animationType prop, default 'slide'; conditionally applied slide animation classes based on prop value.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant DemoComponent
    participant useVbenModal
    participant Modal
    participant DialogContent

    User->>DemoComponent: Click "Open Slide Modal"
    DemoComponent->>useVbenModal: open({ animationType: 'slide' })
    useVbenModal->>Modal: show modal (animationType='slide')
    Modal->>DialogContent: Pass animationType='slide'
    DialogContent-->>User: Modal appears with slide animation

    User->>DemoComponent: Click "Open Scale Modal"
    DemoComponent->>useVbenModal: open({ animationType: 'scale' })
    useVbenModal->>Modal: show modal (animationType='scale')
    Modal->>DialogContent: Pass animationType='scale'
    DialogContent-->>User: Modal appears with scale animation
Loading

Suggested reviewers

  • mynetfan
  • anncwb

Poem

In the meadow where modals reside,
A rabbit hops with animated pride.
Slide or scale, the choice is yours—
Now dialogs open with magical doors!
Buttons and demos, documentation anew,
AnimationType brings a fresh point of view.
🐇✨

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ 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.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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 generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this 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
Contributor

@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

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 07b64ad and 1a9b050.

📒 Files selected for processing (6)
  • docs/src/components/common-ui/vben-modal.md (2 hunks)
  • docs/src/demos/vben-modal/animation-type/index.vue (1 hunks)
  • packages/@core/ui-kit/popup-ui/src/modal/modal-api.ts (1 hunks)
  • packages/@core/ui-kit/popup-ui/src/modal/modal.ts (1 hunks)
  • packages/@core/ui-kit/popup-ui/src/modal/modal.vue (2 hunks)
  • packages/@core/ui-kit/shadcn-ui/src/ui/dialog/DialogContent.vue (4 hunks)
🧰 Additional context used
🧠 Learnings (4)
📓 Common learnings
Learnt from: mynetfan
PR: vbenjs/vue-vben-admin#5397
File: playground/src/bootstrap.ts:23-30
Timestamp: 2025-01-15T04:29:13.944Z
Learning: In the Vue-Vben-Admin project, commented code in bootstrap.ts showing modal and drawer configuration examples should be preserved as reference documentation, even after moving to CSS variables for z-index management.
docs/src/demos/vben-modal/animation-type/index.vue (3)
Learnt from: mynetfan
PR: vbenjs/vue-vben-admin#5397
File: playground/src/bootstrap.ts:23-30
Timestamp: 2025-01-15T04:29:13.944Z
Learning: In the Vue-Vben-Admin project, commented code in bootstrap.ts showing modal and drawer configuration examples should be preserved as reference documentation, even after moving to CSS variables for z-index management.
Learnt from: ArthurDarkstone
PR: vbenjs/vue-vben-admin#4807
File: docs/src/components/common-ui/vben-vxe-table.md:65-84
Timestamp: 2024-11-05T10:34:13.846Z
Learning: In `docs/src/components/common-ui/vben-vxe-table.md`, the code examples are provided within markdown scripts for documentation and do not require import statements or explicit type annotations.
Learnt from: mynetfan
PR: vbenjs/vue-vben-admin#5013
File: docs/src/components/layout-ui/page.md:31-31
Timestamp: 2024-12-04T04:41:30.161Z
Learning: 在 Vben Admin 项目的 `Page` 组件中,`extra` 内容仅通过 slots 提供,没有对应的 prop 属性。
packages/@core/ui-kit/popup-ui/src/modal/modal.vue (1)
Learnt from: mynetfan
PR: vbenjs/vue-vben-admin#5397
File: playground/src/bootstrap.ts:23-30
Timestamp: 2025-01-15T04:29:13.944Z
Learning: In the Vue-Vben-Admin project, commented code in bootstrap.ts showing modal and drawer configuration examples should be preserved as reference documentation, even after moving to CSS variables for z-index management.
docs/src/components/common-ui/vben-modal.md (4)
Learnt from: ArthurDarkstone
PR: vbenjs/vue-vben-admin#4807
File: docs/src/components/common-ui/vben-vxe-table.md:65-84
Timestamp: 2024-11-05T10:34:13.846Z
Learning: In `docs/src/components/common-ui/vben-vxe-table.md`, the code examples are provided within markdown scripts for documentation and do not require import statements or explicit type annotations.
Learnt from: mynetfan
PR: vbenjs/vue-vben-admin#5397
File: playground/src/bootstrap.ts:23-30
Timestamp: 2025-01-15T04:29:13.944Z
Learning: In the Vue-Vben-Admin project, commented code in bootstrap.ts showing modal and drawer configuration examples should be preserved as reference documentation, even after moving to CSS variables for z-index management.
Learnt from: mynetfan
PR: vbenjs/vue-vben-admin#5013
File: docs/src/components/layout-ui/page.md:31-31
Timestamp: 2024-12-04T04:41:30.161Z
Learning: 在 Vben Admin 项目的 `Page` 组件中,`extra` 内容仅通过 slots 提供,没有对应的 prop 属性。
Learnt from: mynetfan
PR: vbenjs/vue-vben-admin#5013
File: docs/src/components/layout-ui/page.md:23-24
Timestamp: 2024-12-04T04:43:22.179Z
Learning: 在 `docs/src/components/layout-ui/page.md` 的 `Page` 组件中,`title` 和 `description` 属性有意使用 `string|slot` 类型表示法,表示它们可以接受字符串或插槽。
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (8)
  • GitHub Check: Check (ubuntu-latest)
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: Check (windows-latest)
  • GitHub Check: Lint (ubuntu-latest)
  • GitHub Check: Test (windows-latest)
  • GitHub Check: Lint (windows-latest)
  • GitHub Check: post-update (ubuntu-latest)
  • GitHub Check: post-update (windows-latest)
🔇 Additional comments (10)
packages/@core/ui-kit/popup-ui/src/modal/modal.ts (1)

8-12: LGTM! Clean interface addition for animation type support.

The animationType property is properly defined with appropriate type constraints, default value documentation, and consistent Chinese comments.

packages/@core/ui-kit/popup-ui/src/modal/modal-api.ts (1)

62-62: LGTM! Proper default state initialization.

The animationType: 'slide' default value is correctly added to the defaultState object, ensuring consistent behavior when no animation type is specified.

docs/src/components/common-ui/vben-modal.md (2)

59-66: LGTM! Comprehensive documentation for the new animation feature.

The documentation clearly explains both animation types with appropriate descriptions and includes a demo preview for visual demonstration.


124-124: LGTM! Proper props table documentation.

The animationType property is correctly documented in the props table with accurate type information and default value.

packages/@core/ui-kit/popup-ui/src/modal/modal.vue (2)

97-97: LGTM! Proper prop extraction from priority values.

The animationType is correctly extracted from usePriorityValues following the established pattern for other modal properties.


248-248: LGTM! Clean prop forwarding to DialogContent.

The animationType is properly forwarded to the DialogContent component using the correct kebab-case attribute name.

docs/src/demos/vben-modal/animation-type/index.vue (2)

1-19: LGTM! Well-structured demo component setup.

The component properly demonstrates both animation types using separate modal instances with clear, descriptive function names and proper Vue 3 composition API usage.


21-36: LGTM! Clean template implementation with effective demonstration.

The template provides a clear visual demonstration of both animation types with descriptive Chinese labels and well-organized layout using appropriate spacing classes.

packages/@core/ui-kit/shadcn-ui/src/ui/dialog/DialogContent.vue (2)

23-23: LGTM: Well-typed animation prop with sensible default.

The animationType prop is properly typed with a union type and has a sensible default value. This approach prevents breaking changes while enabling the new animation feature.

Also applies to: 37-37


52-52: LGTM: Correct prop exclusion from delegation.

The animationType prop is properly excluded from delegated props, preventing it from being passed to the underlying radix-vue DialogContent component. This is the correct approach for internal props.

Comment on lines +110 to +114
'z-popup bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 w-full p-6 shadow-lg outline-none sm:rounded-xl',
{
'data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-top-[48%]':
animationType === 'slide',
},
Copy link
Contributor

@coderabbitai coderabbitai bot Jul 17, 2025

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix conflicting animation classes.

The current implementation applies zoom animation classes unconditionally while only conditionally applying slide classes. This creates conflicting animations when animationType is 'slide', as both zoom and slide animations will be active simultaneously.

-          'z-popup bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 w-full p-6 shadow-lg outline-none sm:rounded-xl',
+          'z-popup bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 w-full p-6 shadow-lg outline-none sm:rounded-xl',
           {
+            'data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95':
+              animationType === 'scale',
             'data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-top-[48%]':
               animationType === 'slide',
           },
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
'z-popup bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 w-full p-6 shadow-lg outline-none sm:rounded-xl',
{
'data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-top-[48%]':
animationType === 'slide',
},
'z-popup bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 w-full p-6 shadow-lg outline-none sm:rounded-xl',
{
'data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95':
animationType === 'scale',
'data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-top-[48%]':
animationType === 'slide',
},
🤖 Prompt for AI Agents
In packages/@core/ui-kit/shadcn-ui/src/ui/dialog/DialogContent.vue around lines
110 to 114, the zoom animation classes are applied unconditionally, causing
conflicts when animationType is 'slide' because slide animation classes are
conditionally applied. To fix this, make the zoom animation classes conditional
so they only apply when animationType is not 'slide', ensuring only one
animation type is active at a time.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

我并不需要加 ai 提示的这段话,scale 时候没有额外的 class 本来就是走 dialog 自带的效果,以后如果有其他动画,加在这里也不会影响 scale。

Copy link
Contributor

Choose a reason for hiding this comment

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

@Elm1992 理解了!您说得对,scale 动画确实应该使用 dialog 自带的 zoom 效果作为基础动画。当前的实现是有意为之的:

  • scale 动画:使用基础的 zoom-out-95zoom-in-95 类(始终存在)
  • slide 动画:在基础 zoom 效果之上叠加 slide 类来实现滑动效果
  • 未来的动画类型:可以类似地在基础效果上添加条件类

这种设计模式确实很合理,基础动画效果作为默认行为,特定动画类型通过添加额外的条件类来增强效果。感谢您的解释!

  (\   /)
 ( ._.)
o_(")(")  *nods in understanding*

✏️ Learnings added
Learnt from: Elm1992
PR: vbenjs/vue-vben-admin#6537
File: packages/@core/ui-kit/shadcn-ui/src/ui/dialog/DialogContent.vue:110-114
Timestamp: 2025-07-17T16:38:41.877Z
Learning: In the Vue-Vben-Admin DialogContent component, the animation system uses a layered approach: zoom animation classes (zoom-out-95, zoom-in-95) are applied unconditionally as the base effect for scale animation, while specific animation types like 'slide' add conditional classes on top of the base effect. This design allows scale animation to use the dialog's built-in zoom effect and enables future animation types to be added without affecting the scale behavior.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.


🧠 Learnings used
Learnt from: mynetfan
PR: vbenjs/vue-vben-admin#5397
File: playground/src/bootstrap.ts:23-30
Timestamp: 2025-01-15T04:29:13.944Z
Learning: In the Vue-Vben-Admin project, commented code in bootstrap.ts showing modal and drawer configuration examples should be preserved as reference documentation, even after moving to CSS variables for z-index management.

@jinmao88 jinmao88 merged commit 260e45c into vbenjs:main Jul 25, 2025
12 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Aug 25, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants