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: support set default props for drawer and modal #5390

Merged
merged 2 commits into from
Jan 14, 2025

Conversation

mynetfan
Copy link
Collaborator

@mynetfan mynetfan commented Jan 14, 2025

Description

添加为弹窗和抽屉设置默认属性的方法。这些方法可以用于定制抽屉、弹窗的统一的默认表现,如不显示全屏按钮、默认可拖动等等。
不同的组件库的默认弹窗层级不同,因此将弹窗和抽屉的默认层级分别设置为各自组件库的默认弹窗层级,而antd的默认层级取了一合适的值,使得其在vxeTable最大化状态下能正常显示且不会遮挡全局提示(message)

close #5387

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.

Checklist

ℹ️ Check all checkboxes - this will indicate that you have done everything in accordance with the rules in CONTRIBUTING.

  • If you introduce new functionality, document it. You can run documentation with pnpm run docs:dev command.
  • Run the tests with pnpm test.
  • Changes in changelog are generated from PR name. Please, make sure that it explains your changes in an understandable manner. Please, prefix changeset messages with feat:, fix:, perf:, docs:, or chore:.
  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

Summary by CodeRabbit

Release Notes

  • New Features

    • Added ability to customize default properties for modal and drawer components across different UI libraries.
    • Introduced centralized configuration for modal and drawer z-index and fullscreen button settings.
  • Documentation

    • Updated documentation for Vben Drawer and Modal components with guidance on customizing default properties.
  • Style

    • Added .ant-message CSS rule with z-index of 1050 for consistent message positioning.

These changes provide more flexibility in configuring UI components and improve overall user interface consistency.

@mynetfan mynetfan requested review from anncwb, vince292007 and a team as code owners January 14, 2025 08:16
Copy link

changeset-bot bot commented Jan 14, 2025

⚠️ No Changeset found

Latest commit: 8a789bf

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

Copy link
Contributor

coderabbitai bot commented Jan 14, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

The pull request introduces new functionality to set default properties for modal and drawer components across multiple applications. The changes involve adding setDefaultDrawerProps and setDefaultModalProps functions to the @vben/common-ui module, which allow developers to configure global default settings for these UI components. These modifications are implemented consistently across different application bootstraps (web-antd, web-ele, web-naive, and playground), with specific z-index values set for the components.

Changes

File Change Summary
apps/*/src/bootstrap.ts Added imports and configuration for setDefaultDrawerProps and setDefaultModalProps
packages/@core/ui-kit/popup-ui/src/drawer/index.ts Updated exports to include setDefaultDrawerProps
packages/@core/ui-kit/popup-ui/src/drawer/use-drawer.ts Added DEFAULT_DRAWER_PROPS and setDefaultDrawerProps function
packages/@core/ui-kit/popup-ui/src/modal/index.ts Updated exports to include setDefaultModalProps
packages/@core/ui-kit/popup-ui/src/modal/use-modal.ts Added DEFAULT_MODAL_PROPS and setDefaultModalProps function
packages/styles/src/antd/index.css Added .ant-message z-index rule
docs/src/components/common-ui/*.md Added documentation for configuring default modal and drawer properties

Assessment against linked issues

Objective Addressed Explanation
Fix drawer/modal visibility after vxetable fullscreen

Possibly related PRs

Suggested labels

feature

Suggested reviewers

  • anncwb
  • vince292007

Poem

🐰 Modals and drawers, now with grace,
Z-index dancing in their space,
Configuration's magical art,
Giving UI components a smart start!
Hop along, code so bright! 🌟


📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 736bc88 and 8a789bf.

📒 Files selected for processing (1)
  • docs/src/components/common-ui/vben-modal.md (1 hunks)

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 generate docstrings to generate docstrings for this PR. (Beta)
  • @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

🧹 Nitpick comments (3)
apps/web-ele/src/bootstrap.ts (1)

26-34: Consider centralizing z-index management.

While the implementation is correct, managing z-index values across different applications can become maintenance overhead. Consider:

  1. Creating a shared configuration for z-index values
  2. Using CSS custom properties (variables) for z-index management
  3. Documenting the z-index hierarchy in the codebase
packages/styles/src/antd/index.css (1)

58-60: LGTM! Consider documenting z-index layers.

The z-index value of 1050 for .ant-message is appropriately chosen to ensure messages appear above regular components while working with maximized vxeTable.

Consider maintaining a documentation of z-index layers in a constants file or documentation to help track the visual hierarchy of components:

// src/constants/zIndex.ts
export const Z_INDEX = {
  MESSAGE: 1050,
  MODAL: 1000,
  // ... other z-index values
} as const;
docs/src/components/common-ui/vben-drawer.md (1)

58-58: Enhance the documentation with an example.

The documentation addition is helpful but could be more effective with a concrete example.

Consider adding a code example:

- 如果抽屉的默认行为不符合你的预期,可以在`src\bootstrap.ts`中修改`setDefaultDrawerProps`的参数来设置默认的属性,如默认隐藏全屏按钮,修改默认ZIndex等。
+ 如果抽屉的默认行为不符合你的预期,可以在`src\bootstrap.ts`中修改`setDefaultDrawerProps`的参数来设置默认的属性:
+ 
+ ```ts
+ // src/bootstrap.ts
+ setDefaultDrawerProps({
+   fullscreenButton: false,  // 默认隐藏全屏按钮
+   zIndex: 2000,            // 修改默认ZIndex
+ });
+ ```
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 5965755 and 736bc88.

📒 Files selected for processing (11)
  • apps/web-antd/src/bootstrap.ts (2 hunks)
  • apps/web-ele/src/bootstrap.ts (2 hunks)
  • apps/web-naive/src/bootstrap.ts (2 hunks)
  • docs/src/components/common-ui/vben-drawer.md (1 hunks)
  • docs/src/components/common-ui/vben-modal.md (1 hunks)
  • packages/@core/ui-kit/popup-ui/src/drawer/index.ts (1 hunks)
  • packages/@core/ui-kit/popup-ui/src/drawer/use-drawer.ts (2 hunks)
  • packages/@core/ui-kit/popup-ui/src/modal/index.ts (1 hunks)
  • packages/@core/ui-kit/popup-ui/src/modal/use-modal.ts (2 hunks)
  • packages/styles/src/antd/index.css (1 hunks)
  • playground/src/bootstrap.ts (2 hunks)
🔇 Additional comments (9)
packages/@core/ui-kit/popup-ui/src/modal/index.ts (1)

3-3: LGTM! Clean export addition.

The export statement correctly exposes the new setDefaultModalProps function while maintaining the existing useVbenModal export.

packages/@core/ui-kit/popup-ui/src/drawer/index.ts (1)

3-3: LGTM! Consistent with modal implementation.

The export statement follows the same pattern as the modal implementation, maintaining consistency across components.

apps/web-naive/src/bootstrap.ts (2)

4-8: LGTM! Clean import organization.

The imports are well-organized and grouped appropriately from the @vben/common-ui module.


26-34: Consider translating Chinese comments to English.

While the implementation is correct, consider translating the Chinese comments to English for better maintainability in an international codebase:

-  // 设置弹窗的默认配置
+  // Set default modal configuration
-  // 设置抽屉的默认配置
+  // Set default drawer configuration

Also, verify that the z-index value of 2000 is appropriate for the Naive UI ecosystem:

✅ Verification successful

Consider translating Chinese comments to English for better maintainability

While the implementation is correct, consider translating the Chinese comments to English:

-  // 设置弹窗的默认配置
+  // Set default modal configuration
-  // 设置抽屉的默认配置
+  // Set default drawer configuration

The z-index value of 2000 is appropriate as it's consistently used across the codebase for similar UI components.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for any z-index declarations in Naive UI related files
rg -i "z-?index.*2000" --type ts --type vue

Length of output: 73


Script:

#!/bin/bash
# Search for z-index declarations with value 2000
rg -i "z-?index.*2000"

# Search for Naive UI configuration files
fd -e ts -e js naive

# Search for any z-index related constants or configurations in Naive UI files
rg -i "z-?index" -g "*naive*"

Length of output: 311

apps/web-antd/src/bootstrap.ts (1)

26-34: Verify z-index alignment with Ant Design's layering system.

The z-index value of 1020 seems specific to Ant Design. Please verify that this value aligns with Ant Design's z-index hierarchy to ensure proper layering with other components:

Also, consider translating the Chinese comments to English for consistency:

-  // 设置弹窗的默认配置
+  // Set default modal configuration
-  // 设置抽屉的默认配置
+  // Set default drawer configuration
✅ Verification successful

Z-index value of 1020 is correctly aligned with Ant Design's layering system

The z-index hierarchy in the code follows Ant Design's conventions:

  • System messages: 1050
  • Modal/Drawer: 1020
  • Layout elements: 150-200

This ensures proper component layering and interaction.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for Ant Design related z-index declarations
rg -i "z-?index.*1020" --type ts --type vue

# Look for any Ant Design configuration files that might define z-index values
fd -e ts -e js -e json antd.*config

Length of output: 113


Script:

#!/bin/bash
# Search for z-index declarations in the codebase
rg -i "z-?index" -A 2 -B 2

# Search for Modal and Drawer component configurations
ast-grep --pattern 'Modal {
  $$$
}'

ast-grep --pattern 'Drawer {
  $$$
}'

# Look for any config files
fd -e ts -e js -e json "config"

Length of output: 30343

packages/@core/ui-kit/popup-ui/src/drawer/use-drawer.ts (2)

24-28: LGTM! Clean implementation of default drawer props.

The implementation follows Vue's reactive patterns and ensures proper type safety.


77-81: Verify prop merging precedence.

The order of spread operations ensures correct precedence:

  1. Default props (lowest priority)
  2. Injected options
  3. Direct options (highest priority)
packages/@core/ui-kit/popup-ui/src/modal/use-modal.ts (1)

20-24: LGTM! Consistent implementation with drawer default props.

The implementation follows the same pattern as the drawer implementation, ensuring consistency across components.

playground/src/bootstrap.ts (1)

27-35: Verify z-index consistency across applications.

The z-index value (1020) differs from other applications (2000). This might lead to inconsistent behavior when these components are used together.

Consider:

  1. Using a consistent z-index across all applications
  2. Documenting why different values are needed if this is intentional

Run this script to check z-index usage across the codebase:

✅ Verification successful

Z-index values are framework-specific and intentional

The different z-index values (1020 vs 2000) are intentionally set based on the UI framework being used:

  • Ant Design based apps use 1020
  • Element Plus and Naive UI based apps use 2000

This is consistent with the framework-specific design patterns and the documentation explicitly supports customizing these values in bootstrap.ts.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check z-index values used across bootstrap files
echo "Checking z-index values in bootstrap files:"
rg -A 2 "setDefaultModalProps|setDefaultDrawerProps" | rg "zIndex:"

Length of output: 550


Script:

#!/bin/bash
# Check framework dependencies and potential documentation
echo "Checking package.json files for UI framework versions:"
fd package.json --exec grep -l "ant-design\|naive-ui\|element-plus" {} \; --exec cat {}

echo -e "\nChecking for z-index related documentation:"
rg -i "z-index|zindex" -g "README.md" -g "*.md"

Length of output: 7802

docs/src/components/common-ui/vben-modal.md Outdated Show resolved Hide resolved
@mynetfan mynetfan merged commit e1c503e into vbenjs:main Jan 14, 2025
13 checks passed
@mynetfan mynetfan deleted the feat/popover-default-config branch January 14, 2025 09:11
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.

Bug:点击vxetable的全屏后,再点击编辑弹窗和drawer都不显示
1 participant