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(@vben/web-ele): fixed some style issues in dark mode #4298

Merged
merged 1 commit into from
Sep 1, 2024
Merged

Conversation

anncwb
Copy link
Collaborator

@anncwb anncwb commented Sep 1, 2024

Description

fixed #4295

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

  • New Features

    • Added options to control the visibility of cancel and confirm buttons in both the drawer and modal components, enhancing user interaction.
    • Introduced a new Slot component for improved flexibility in UI design.
  • Bug Fixes

    • Enhanced sidebar locking behavior to be conditional based on the sidebar's mixed state, improving user experience.
  • Documentation

    • Updated documentation to reflect the new properties and their functionalities across various components.
  • Chores

    • Cleaned up component templates by removing unnecessary props and simplifying rendering logic for better maintainability.

@anncwb anncwb added the bug Something isn't working label Sep 1, 2024
@anncwb anncwb requested review from vince292007 and a team as code owners September 1, 2024 14:28
Copy link

changeset-bot bot commented Sep 1, 2024

⚠️ No Changeset found

Latest commit: c294ab8

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

Walkthrough

The changes introduce new properties to the useVbenDrawer and useVbenModal components, allowing developers to control the visibility of cancel and confirm buttons. Additionally, modifications were made to various Vue components and APIs, enhancing their functionality and flexibility. The routing configuration was also adjusted, indicating a restructuring of the route definitions without altering their functionality.

Changes

Files Change Summary
docs/src/components/common-ui/vben-drawer.md, docs/src/components/common-ui/vben-modal.md Added showCancelButton and showConfirmButton properties (boolean, default: true) to configuration objects.
packages/@core/ui-kit/layout-ui/src/components/layout-content.vue Replaced <slot> with <Slot> component for enhanced overlay rendering.
packages/@core/ui-kit/layout-ui/src/components/layout-sidebar.vue Introduced conditional logic for locking and unlocking sidebar based on props.isSidebarMixed.
packages/@core/ui-kit/layout-ui/src/vben-layout.vue Modified handleHeaderToggle to use a non-scoped slot for overlay rendering.
packages/@core/ui-kit/popup-ui/src/drawer/drawer-api.ts, packages/@core/ui-kit/popup-ui/src/drawer/drawer.ts Introduced showCancelButton and showConfirmButton properties to DrawerApi and DrawerProps.
packages/@core/ui-kit/popup-ui/src/drawer/drawer.vue, packages/@core/ui-kit/popup-ui/src/modal/modal.vue Added reactive properties for button visibility based on showCancelButton and showConfirmButton.
packages/@core/ui-kit/popup-ui/src/modal/modal-api.ts, packages/@core/ui-kit/popup-ui/src/modal/modal.ts Updated ModalApi and ModalProps to include showCancelButton and showConfirmButton.
packages/@core/ui-kit/shadcn-ui/src/index.ts Expanded exports to include Slot component from radix-vue.
packages/effects/hooks/src/use-design-tokens.ts Enhanced useElementPlusDesignTokens function with theme handling and new helper functions.
packages/effects/layouts/src/basic/content/content-spinner.vue, packages/effects/layouts/src/basic/layout.vue Removed overlayStyle prop from spinner component and simplified rendering logic in layout.
playground/src/router/routes/modules/examples.ts Removed and re-added EllipsisExample route, indicating restructuring without functionality change.

Assessment against linked issues

Objective Addressed Explanation
Bug: 样式bug (Issue #4295) Changes do not directly address the reported style issues.
Ensure the code is up to date.
Check that this is a concrete bug. The changes do not resolve the specific bug reported.

🐰 In the meadow, hopping with glee,
New buttons appear, oh what joy to see!
Cancel and confirm, now easy to find,
With each little change, we’re ever so kind.
So let’s celebrate, with a twirl and a hop,
For the UI is brighter, and we’ll never stop! 🌼


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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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.

@anncwb anncwb merged commit 3f2dcb8 into main Sep 1, 2024
13 checks passed
@anncwb anncwb deleted the bugfix/4295 branch September 1, 2024 14:33
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

Commits

Files that changed from the base of the PR and between 67f3d63 and c294ab8.

Files selected for processing (17)
  • docs/src/components/common-ui/vben-drawer.md (1 hunks)
  • docs/src/components/common-ui/vben-modal.md (1 hunks)
  • packages/@core/ui-kit/layout-ui/src/components/layout-content.vue (2 hunks)
  • packages/@core/ui-kit/layout-ui/src/components/layout-sidebar.vue (1 hunks)
  • packages/@core/ui-kit/layout-ui/src/vben-layout.vue (1 hunks)
  • packages/@core/ui-kit/popup-ui/src/drawer/drawer-api.ts (1 hunks)
  • packages/@core/ui-kit/popup-ui/src/drawer/drawer.ts (1 hunks)
  • packages/@core/ui-kit/popup-ui/src/drawer/drawer.vue (2 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/index.ts (1 hunks)
  • packages/effects/hooks/src/use-design-tokens.ts (2 hunks)
  • packages/effects/layouts/src/basic/content/content-spinner.vue (1 hunks)
  • packages/effects/layouts/src/basic/layout.vue (1 hunks)
  • packages/effects/layouts/src/widgets/preferences/blocks/toggle-item.vue (1 hunks)
  • playground/src/router/routes/modules/examples.ts (2 hunks)
Files skipped from review due to trivial changes (2)
  • packages/effects/layouts/src/widgets/preferences/blocks/toggle-item.vue
  • playground/src/router/routes/modules/examples.ts
Additional comments not posted (27)
packages/@core/ui-kit/shadcn-ui/src/index.ts (1)

2-2: LGTM!

The code change is approved. Exporting the Slot component from the radix-vue package is a good addition, as it provides developers with easy access to this commonly used component from the Radix UI library.

packages/effects/layouts/src/basic/content/content-spinner.vue (1)

11-11: Simplification of Spinner Component

The removal of the overlayStyle prop simplifies the component, which aligns with the PR's objective to fix style issues by potentially standardizing the appearance. However, this change reduces the flexibility for custom styling. Ensure that this simplification does not negatively impact other areas where the VbenSpinner is used, especially in contexts that might have relied on custom styling provided by overlayStyle.

Verification successful

No Negative Impact from overlayStyle Removal

The removal of the overlayStyle prop from the VbenSpinner component does not negatively impact other components or styles. The search results confirm that no other instances of VbenSpinner rely on the overlayStyle prop, ensuring that the simplification aligns with the PR's objectives without causing issues elsewhere.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that the removal of `overlayStyle` does not negatively impact other components or styles.

# Test: Search for other occurrences of `VbenSpinner` to ensure they do not rely on `overlayStyle`.
rg --type vue -A 5 $'VbenSpinner'

Length of output: 60


Script:

#!/bin/bash
# Description: Verify that the removal of `overlayStyle` does not negatively impact other components or styles.

# Find all .vue files and search for occurrences of `VbenSpinner`.
fd --extension vue --exec rg 'VbenSpinner' {}

Length of output: 269

packages/@core/ui-kit/layout-ui/src/components/layout-content.vue (2)

58-60: Approve the use of the Slot component in the template.

The introduction of the Slot component enhances styling flexibility, particularly for overlays in dark mode. Ensure that the overlayStyle is correctly computed and applied as intended.

Verification successful

overlayStyle is correctly computed and applied in the codebase.

The overlayStyle is defined in use-content-style.ts and used in layout-content.vue, confirming its correct application in the template changes. No further action is required.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the correct application of overlayStyle.

# Test: Search for the overlayStyle usage in the project to ensure it's correctly applied.
rg "overlayStyle" --type vue

Length of output: 56


Script:

#!/bin/bash
# Description: Verify the correct application of overlayStyle.

# Test: Search for the overlayStyle usage in the project without specifying file type.
rg "overlayStyle"

# Additionally, use ast-grep to search for overlayStyle in Vue files.
ast-grep --lang vue --pattern '$_ = overlayStyle'

Length of output: 944


8-8: Verify the import path for the Slot component.

Ensure that the Slot component is correctly imported from @vben-core/shadcn-ui. This is crucial for the new functionality to work as expected.

Verification successful

Import path for the Slot component is correct.

The Slot component is correctly imported from @vben-core/shadcn-ui, as it is re-exported from radix-vue within the package. This setup ensures that the component is available for use as intended. No further action is needed.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the existence of the Slot component in the specified package.

# Test: Search for the Slot component definition in the specified package.
fd Slot.vue packages/@vben-core/shadcn-ui/components

Length of output: 182


Script:

#!/bin/bash
# Description: Search for the Slot.vue file across the entire repository to locate its correct path.

# Test: Use fd to find the Slot.vue file.
fd Slot.vue

Length of output: 13


Script:

#!/bin/bash
# Description: Search for the Slot component definition in JavaScript or TypeScript files across the repository.

# Test: Use rg to find the Slot component definition.
rg 'Slot' --type js --type ts --type vue -A 3

Length of output: 73


Script:

#!/bin/bash
# Description: Search for the Slot component definition in JavaScript and TypeScript files across the repository.

# Test: Use rg to find the Slot component definition, focusing on export statements.
rg 'export.*Slot' --type js --type ts -A 3

Length of output: 139

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

53-62: Approve the addition of showCancelButton and showConfirmButton.

The new properties showCancelButton and showConfirmButton have been added to the DrawerProps interface. These properties are optional and default to true, which is a good practice as it maintains backward compatibility. The documentation comments are clear and informative.

It's important to verify that the integration of these new properties in the UI does not introduce any new style issues, especially in dark mode, as the PR aims to address style inconsistencies.

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

39-40: LGTM!

The code changes are approved for the following reasons:

  • The addition of showCancelButton and showConfirmButton properties to the defaultState object enhances the functionality of the drawer by allowing it to display cancel and confirm buttons by default.
  • This modification improves user experience by providing users with more interactive options when the drawer is open, facilitating user actions directly within the drawer interface.
  • The changes are consistent with the existing code and follow the same naming convention and initialization pattern as other properties in the defaultState object.
  • The changes do not introduce any syntax errors or type mismatches.
packages/@core/ui-kit/popup-ui/src/modal/modal-api.ts (1)

43-44: Approve the addition of showCancelButton and showConfirmButton.

The changes to introduce showCancelButton and showConfirmButton with default values set to true are aligned with the PR's objectives to enhance user interaction within modals. This allows for a more flexible and user-friendly interface where developers can opt to show or hide these buttons based on the application's needs.

Please ensure that these new properties are properly integrated with the UI components that utilize the ModalApi class, particularly in contexts where the modal's appearance is critical, such as in dark mode scenarios described in the issue.

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

77-77: LGTM!

The new showCancelButton property is a useful addition to the component API. It allows the user to control the visibility of the cancel button, enhancing the component's customizability.


78-78: LGTM!

Similar to the showCancelButton property, the new showConfirmButton property is a valuable addition to the component API. It allows the user to control the visibility of the confirm button, further enhancing the component's flexibility.

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

87-88: Document the new properties clearly and ensure alignment with PR objectives.

The addition of showCancelButton and showConfirmButton properties to the useVbenModal configuration is well-documented. These properties allow developers to control the visibility of the modal's buttons, enhancing flexibility and user interaction based on specific use cases.

However, it's important to ensure that these changes align with the overall objectives of the PR, which focuses on fixing style issues in dark mode. If these properties impact the modal's appearance in dark mode, this should be explicitly mentioned to clarify their relevance to the PR's goals.

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

57-58: Effective use of reactive properties for UI control.

The introduction of showCancelButton and showConfirmButton using usePriorityValue effectively enhances the dynamic control of UI elements based on the component's state or props. This change aligns well with the PR's objectives to improve UI responsiveness and control.


172-176: Improved UI flexibility and functionality with conditional rendering.

The conditional rendering of the cancel and confirm buttons based on showCancelButton and showConfirmButton is correctly implemented. This approach not only enhances the UI's responsiveness but also provides flexibility through the use of slots for button labels, allowing easy customization or localization. The binding of event handlers to drawerApi methods ensures proper functionality.

Also applies to: 182-186

packages/@core/ui-kit/layout-ui/src/components/layout-sidebar.vue (2)

220-222: LGTM!

The code changes are approved. The conditional locking of the sidebar based on the isSidebarMixed prop aligns with the expected behavior described in the AI-generated summary.


228-230: LGTM!

The code changes are approved. The conditional unlocking of the sidebar based on the isSidebarMixed prop aligns with the expected behavior described in the AI-generated summary.

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

72-72: LGTM!

The code changes are approved. The new showCancelButton property is correctly initialized using the usePriorityValue function to control the visibility of the cancel button.


73-73: LGTM!

The code changes are approved. The new showConfirmButton property is correctly initialized using the usePriorityValue function to control the visibility of the confirm button.


Line range hint 243-260: LGTM!

The code changes are approved. The rendering of the cancel and confirm buttons is now conditional based on the showCancelButton and showConfirmButton properties, respectively. These changes enhance the modal's flexibility by allowing developers to control the presence of these buttons dynamically, improving the component's configurability and user interaction capabilities.

packages/effects/layouts/src/basic/layout.vue (1)

298-299: Simplified rendering logic for the loading spinner.

The changes to the LayoutContentSpinner component simplify the template by removing the :overlay-style prop. This should enhance clarity and maintainability. The condition for displaying the spinner remains unchanged, ensuring that the loading behavior is preserved.

Please verify the visual impact of these changes, especially in dark mode, to ensure that the removal of the :overlay-style prop does not introduce new style issues.

packages/effects/hooks/src/use-design-tokens.ts (7)

163-163: Addition of usePreferences hook.

The addition of the usePreferences hook allows the function to access user preferences, specifically the theme setting. This is crucial for applying the correct styles based on the theme.


166-168: Introduction of getCssVariableValueRaw function.

This new helper function simplifies the process of fetching CSS variable values directly from the root styles. It enhances code readability and maintainability by centralizing the retrieval logic.


171-171: Refactor of getCssVariableValue to use the new helper function.

Refactoring this function to use getCssVariableValueRaw improves the separation of concerns by isolating the raw value retrieval. This change makes the code cleaner and easier to manage.


188-188: Dynamic handling of --el-border-color-hover.

The assignment of --el-border-color-hover based on the accent color in dark mode is a targeted fix that addresses the hover style issues mentioned in the PR description. This ensures that hover styles are visually consistent in dark mode.


218-220: Conditional assignment based on theme for --el-color-primary-light-9.

This conditional logic ensures that the color value adapts to the theme, using the accent color in dark mode. It's a smart use of reactive programming to handle theme changes dynamically.


239-241: Use of --accent for --el-fill-color-light.

Applying the accent color to --el-fill-color-light enhances the thematic consistency across the UI components, aligning with the dark mode adjustments.


241-241: Consistent text color assignments.

The use of --foreground for text colors ensures consistency and readability across different themes. This is a good practice in theme design to maintain visual harmony.

packages/@core/ui-kit/layout-ui/src/vben-layout.vue (2)

537-538: Review the changes to the overlay template structure.

The changes to the overlay template structure involve moving from a scoped slot to a non-scoped slot. This simplifies the slot usage but removes the direct style binding from the parent component. It's important to ensure that this change does not negatively impact the visual presentation and behavior of the overlay, especially in dark mode contexts where style issues are being addressed.

Verify that the removal of overlayStyle binding does not introduce any regressions in the overlay's appearance and functionality. This can be done by visually inspecting the overlay in different scenarios and checking if any related styles are defined elsewhere that might compensate for the removed binding.


537-538: Approve the changes to handleHeaderToggle.

The implementation of handleHeaderToggle is straightforward and correctly handles the sidebar visibility based on the device type. It properly uses Vue's event system to manage state changes, which is crucial for maintaining consistency across the component.

Ensure that the integration of this function with other components (especially those related to the sidebar and mobile responsiveness) is tested thoroughly to avoid any regressions.

Comment on lines +78 to +87
/**
* 是否显示取消按钮
* @default true
*/
showCancelButton?: boolean;
/**
* 是否显示确认按钮
* @default true
*/
showConfirmButton?: boolean;
Copy link
Contributor

Choose a reason for hiding this comment

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

Approve the addition of showCancelButton and showConfirmButton.

The changes to the ModalProps interface introduce showCancelButton and showConfirmButton properties, enhancing the modal's flexibility and customization. Both properties are optional and default to true, ensuring backward compatibility.

It's recommended to add unit tests to verify that the modal behaves correctly with these properties set to different values. Would you like assistance in setting up these tests?

kkfive pushed a commit to kkfive/vue-vben-admin that referenced this pull request Sep 14, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Oct 4, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug: 样式bug
1 participant