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(cascader): [cascader,tooltip] cascader selection drop-down panel dark theme adaptation #2970

Merged
merged 6 commits into from
Mar 3, 2025

Conversation

lcy0620
Copy link
Collaborator

@lcy0620 lcy0620 commented Feb 26, 2025

… dark theme adaptation

PR

feat(cascader): [cascader,tooltip] cascader selection drop-down panel dark theme adaptation
解决级联选择下拉面板背景色暗黑主题适配
解决tooltip demo自设置样式在黑白主题下的适配

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

  • Style
    • Updated hover effects for tooltip elements to provide refined visual feedback.
    • Enhanced menu and search input appearances by adopting dynamic theming for backgrounds.
    • Changed the hover background color for Cascader items to use a dynamic CSS variable.
    • Adjusted the hover background color of the .ellipsis class for improved tooltip visibility.
  • Tests
    • Modified the rendering and assertions for the empty state of the Cascader component to reflect updated class names.
    • Simplified textbox selection process in tests for more reliable interactions.
    • Updated tooltip theme tests to improve button interaction methods.

@lcy0620 lcy0620 requested a review from zzcr February 26, 2025 07:26
Copy link

coderabbitai bot commented Feb 26, 2025

Walkthrough

This pull request updates the styling in several Vue and Less files. In two tooltip components, the hover background color for the .ellipsis class is changed from #f1f1f1 to #c0c0c0. In the Cascader theme Less file, a fixed white background is replaced with a CSS variable, and a new variable-based background is added for the search input. Additionally, the input’s placeholder behavior in a Vue Cascader component has been modified to simplify its logic. No public API declarations were affected.

Changes

File(s) Change Summary
examples/.../tooltip/control-composition-api.vue, examples/.../tooltip/control.vue Updated the hover background color for the .ellipsis class from #f1f1f1 to #c0c0c0.
packages/.../cascader/index.less Replaced the static #fff background with var(--tv-Cascader-dropdown-bg-color) for the cascader menu and added background: var(--tv-Input-bg-color) for the search input.
packages/.../cascader/src/pc.vue Modified the logic for setting the input element’s model-value and placeholder attributes based on the states of multiple and filterable.
packages/.../cascader/__tests__/cascader.test.tsx Modified the rendering of the empty slot in tests to include a class name and updated assertions to reflect this change.
packages/.../cascader/vars.less Updated the hover background color variable for the Cascader item from a fixed color #f5f7fa to var(--tv-color-bg-hover).
packages/.../cascader-menu/vars.less Changed the border color variable from a static #f5f5f5 to var(--tv-color-border-divider), enhancing theming capabilities.
examples/.../tooltip/theme.spec.js Updated the method of accessing tooltip buttons by first locating a parent element with the class .box.

Possibly related PRs

Suggested reviewers

  • zzcr
  • shenjunjian

Poem

I hop through lines of vibrant code,
Where colors shift on each abode.
Hover states shine in a brand new light,
Cascading hues that feel just right.
A rabbit cheers in ASCII delight—coding with pure insight! 🐇✨

Warning

There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

examples/sites/demos/pc/app/tooltip/theme.spec.js

Oops! Something went wrong! :(

ESLint: 8.57.1

ESLint couldn't find the plugin "eslint-plugin-vue".

(The package "eslint-plugin-vue" was not found when loaded as a Node module from the directory "".)

It's likely that the plugin isn't installed correctly. Try reinstalling by running the following:

npm install eslint-plugin-vue@latest --save-dev

The plugin "eslint-plugin-vue" was referenced from the config file in ".eslintrc.js » @antfu/eslint-config » @antfu/eslint-config-vue".

If you still can't figure out the problem, please stop by https://eslint.org/chat/help to chat with the team.

✨ Finishing Touches
  • 📝 Generate Docstrings

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.
  • @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.

@github-actions github-actions bot added the enhancement New feature or request (功能增强) label Feb 26, 2025
Copy link

Walkthrough

This PR introduces a dark theme adaptation for the cascader selection drop-down panel and tooltip demo. It modifies the background colors to ensure compatibility with both dark and light themes.

Changes

Files Summary
examples/sites/demos/pc/app/tooltip/control-composition-api.vue, examples/sites/demos/pc/app/tooltip/control.vue Changed hover background color from #f1f1f1 to #c0c0c0 for better dark theme adaptation.
packages/theme/src/cascader/index.less Updated background color to use CSS variables for theme adaptation. Added background color for input elements.
packages/vue/src/cascader/src/pc.vue Removed dynamic placeholder assignment based on present tags.

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

🧹 Nitpick comments (1)
packages/theme/src/cascader/index.less (1)

119-121: Dark Theme Dropdown Background Update

Updating the background property for the cascader menu to use the theme variable var(--tv-Cascader-dropdown-bg-color) instead of a fixed color is a good move for dark mode compatibility.
Suggestion: For stylistic consistency, consider adding a space after the colon (i.e., background: var(--tv-Cascader-dropdown-bg-color);).

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between e48a0d3 and 371b845.

📒 Files selected for processing (4)
  • examples/sites/demos/pc/app/tooltip/control-composition-api.vue (1 hunks)
  • examples/sites/demos/pc/app/tooltip/control.vue (1 hunks)
  • packages/theme/src/cascader/index.less (2 hunks)
  • packages/vue/src/cascader/src/pc.vue (0 hunks)
💤 Files with no reviewable changes (1)
  • packages/vue/src/cascader/src/pc.vue
✅ Files skipped from review due to trivial changes (2)
  • examples/sites/demos/pc/app/tooltip/control.vue
  • examples/sites/demos/pc/app/tooltip/control-composition-api.vue
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: PR E2E Test (pnpm test:e2e3)
🔇 Additional comments (2)
packages/theme/src/cascader/index.less (2)

17-19: Dynamic CSS Variable Prefix Assignment

The use of the ~ operator to dynamically assign prefix class names (e.g., @{css-prefix}cascader) is an excellent approach. This increases maintainability and ensures that theme-specific adjustments propagate consistently across components.


312-314: Search Input Background Theming

Changing the search input’s background to var(--tv-Input-bg-color) aligns the component styling with the overall theme adaptation strategy and improves dark theme support.
Minor note: Verify that the spacing and formatting conform to the project's style guidelines.

@zzcr zzcr requested a review from shenjunjian February 26, 2025 08:05
@lcy0620 lcy0620 changed the title feat(cascader): [cascader,tooltip] cascader selection drop-down panel dark theme adaptation feat(cascader): [cascader] cascader selection drop-down panel dark theme adaptation Feb 26, 2025
@lcy0620 lcy0620 changed the title feat(cascader): [cascader] cascader selection drop-down panel dark theme adaptation feat(cascader): [cascader,tooltip] cascader selection drop-down panel dark theme adaptation Mar 3, 2025
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

🧹 Nitpick comments (1)
packages/theme/src/cascader-menu/vars.less (1)

17-17: Dynamic Theming for CascaderMenu Border Color

Changing the border color from a fixed value to var(--tv-color-border-divider) is an excellent approach for dynamic theming and dark mode compatibility. This update makes the component's styling cohesive with the global theme settings. One minor suggestion is to consider adding a fallback value (e.g., var(--tv-color-border-divider, #f5f5f5)) to ensure consistent appearance in environments where the variable might not be defined.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between fe836ae and 859ae99.

📒 Files selected for processing (2)
  • examples/sites/demos/pc/app/tooltip/theme.spec.js (1 hunks)
  • packages/theme/src/cascader-menu/vars.less (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: PR E2E Test (pnpm test:e2e3)
🔇 Additional comments (3)
examples/sites/demos/pc/app/tooltip/theme.spec.js (3)

8-9: Improved test robustness with more specific button selection

The change to locate buttons within the .box container improves test reliability by ensuring the correct buttons are targeted, which is especially important for theme testing where multiple similar buttons might exist on the page.


12-12: Consistent selector approach maintains test coherence

This change follows the same pattern as the previous one, using the parent container to locate the Light-themed button, ensuring consistent selector strategy throughout the theme-related test cases.


15-28:

❓ Verification inconclusive

Verify if remaining button selectors need similar updates

The remaining button selectors (normal, warning, error, info, success) are still accessed directly from the page object, while Dark and Light buttons now use the tooltipBtn locator. Consider whether these should also use the same locator pattern for consistency.


🏁 Script executed:

#!/bin/bash
# Check if other theme buttons also exist outside the .box container
# which would justify why they don't need the same locator approach

echo "Checking the tooltip theme demo structure..."
cat $(fd -t f "theme.vue" --full-path examples/sites/demos/pc/app/tooltip) || echo "Theme demo file not found"

# Also check the HTML structure to understand button organization
rg -A 5 -B 5 "<button.*Dark" examples/sites/demos/pc/app/tooltip/

Length of output: 1610


Consistency in Button Selector Locators

The dark and light tooltip tests already use the dedicated tooltipBtn locator, but the normal, warning, error, info, and success buttons are still accessed directly via page.getByRole('button', …). Please verify whether these selectors should also be updated to use the same locator pattern for better consistency. If there’s a specific reason to treat these buttons differently, please document the deviation.

@zzcr zzcr merged commit 378e573 into dev Mar 3, 2025
12 of 15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request (功能增强)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants