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(old-theme): [dropdown,grid,tree] modify incorrect css vars #2551

Merged
merged 1 commit into from
Nov 25, 2024

Conversation

MomoPoppy
Copy link
Collaborator

@MomoPoppy MomoPoppy commented Nov 25, 2024

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

    • Enhanced dropdown button layout with a new minimum width property.
    • Updated hover background colors for grid and tree components to improve visual consistency.
  • Bug Fixes

    • Corrected hover background color references for grid and tree components to ensure proper styling.

Copy link

coderabbitai bot commented Nov 25, 2024

Walkthrough

The changes in this pull request involve updates to the CSS styles for the dropdown, grid, and tree components. Specifically, a new CSS property min-width: auto; has been added to the dropdown button class, while the hover background color variables for both the grid and tree components have been modified to reference a more specific hover color variable. These alterations aim to refine the visual presentation and interaction feedback of the components without affecting their existing functionalities.

Changes

File Path Change Summary
packages/theme/src/dropdown/index.less Added min-width: auto; to .dropdown-prefix-cls__title-button.
packages/theme/src/grid/vars.less Updated --tv-Grid-bg-color-hover from var(--tv-color-bg) to var(--tv-color-bg-hover).
packages/theme/src/tree/vars.less Updated --tv-Tree-node-content-hover-bg-color from var(--tv-color-bg) to var(--tv-color-bg-hover).

Possibly related PRs

Suggested labels

bug

Suggested reviewers

  • zzcr
  • kagol
  • gimmyhehe

Poem

In the garden where dropdowns sway,
A button's width found its way.
With colors that hover, so bright and true,
The tree and grid join the view.
Together they dance, in styles so fine,
A whimsical change, oh how they shine! 🐇✨


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.

@github-actions github-actions bot added the enhancement New feature or request (功能增强) label Nov 25, 2024
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: 1

🧹 Outside diff range and nitpick comments (1)
packages/theme/src/dropdown/index.less (1)

77-79: Consider adding a comment explaining the min-width override.

The button group styling is well-structured with clear variable usage. Consider adding a brief comment explaining why min-width: auto is necessary, as this would help future maintainers understand the intent behind this override.

 .@{dropdown-prefix-cls}__title-button {
   padding: var(--tv-Dropdown-title-button-padding);
   border-right: none;
   border-radius: var(--tv-Dropdown-title-button-border-radius);
+  /* Allow button to shrink based on content */
   min-width: auto;
 }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between cda19dc and 39f0f93.

📒 Files selected for processing (3)
  • packages/theme/src/dropdown/index.less (1 hunks)
  • packages/theme/src/grid/vars.less (1 hunks)
  • packages/theme/src/tree/vars.less (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • packages/theme/src/grid/vars.less
🔇 Additional comments (2)
packages/theme/src/dropdown/index.less (1)

78-78: Verify the layout impact of removing minimum width constraint.

The addition of min-width: auto will allow the title button to shrink below any default minimum width. While this can help prevent unwanted spacing, please verify that:

  1. The button content remains properly visible
  2. The layout works well with different content lengths
  3. The alignment with the caret button is maintained
✅ Verification successful

Based on the search results, I can see that:

  1. The min-width: auto property is already used in several other components in the codebase, including:

    • .dropdown-prefix-cls__title-button (the current change)
    • .button-group-prefix-cls__item in button-group
    • .query-builder-prefix-cls__group-item in query-builder
    • .grid-toolbar-prefix-cls__item in grid-toolbar
    • .badge-prefix-cls__dot in badge
  2. The dropdown component has another button with min-width: 24px which suggests that the layout is already designed to handle different button widths.

  3. The button group component (which is related to this change) specifically uses min-width: auto for its items, indicating this is a consistent pattern for button groups in the design system.

Given this evidence, I can now provide the final response:

The min-width: auto change is consistent with existing patterns

The use of min-width: auto is a well-established pattern in the codebase, particularly in button groups and similar components. This change aligns with how other components handle flexible button widths while maintaining layout integrity.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for any custom min-width overrides or related button width constraints
# that might conflict with this change

# Check for min-width usage in button related styles
rg "min-width" --type less

# Look for button width related variables in theme files
rg "(button|btn).*(width|size)" --type less

Length of output: 28971

packages/theme/src/tree/vars.less (1)

Line range hint 1-108: Well-structured CSS variables with comprehensive documentation

The file maintains excellent documentation standards with:

  • Clear copyright notice
  • Organized variable grouping
  • Bilingual comments for each variable
  • Consistent naming conventions

@@ -34,7 +34,7 @@
// 选中节点背景色
--tv-Tree-node-content-current-bg-color: var(--tv-color-bg-secondary, #ffffff);
// 节点悬浮背景色
--tv-Tree-node-content-hover-bg-color: var(--tv-color-bg, #f5f5f5);
--tv-Tree-node-content-hover-bg-color: var(--tv-color-bg-hover, #f5f5f5);
Copy link

Choose a reason for hiding this comment

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

💡 Codebase verification

Inconsistent hover background color variables need standardization

Several components are still using --tv-color-bg for hover states instead of the semantically correct --tv-color-bg-hover:

  • packages/theme/src/transfer/vars.less: --tv-Transfer-panel-item-hover-bg-color
  • packages/theme/src/pager/vars.less: --tv-Pager-page-item-bg-color-hover
  • packages/theme/src/drop-times/vars.less: --tv-DropTimes-item-select-hover-bg-color
  • packages/theme/src/cascader-node/vars.less: --tv-CascaderNode-selectable-hover-bg-color
  • packages/theme/src/button/vars.less: --tv-Button-bg-color-only-icon-ontext-hover

While this PR correctly updates the Tree component, similar standardization is needed across these other components to maintain consistency in hover state styling.

🔗 Analysis chain

Verify the hover state consistency across components

The change from --tv-color-bg to --tv-color-bg-hover aligns with similar updates in the grid component and provides a more semantically correct variable for hover states.

Let's verify this change is consistent across related components:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for hover background color variables across components
# to ensure consistent usage of --tv-color-bg-hover

# Search for hover background color variables
rg --type=less "hover-bg-color.*tv-color-bg" packages/theme/src/

# Search for any remaining usage of --tv-color-bg in hover contexts
rg --type=less "hover.*tv-color-bg[^-]" packages/theme/src/

Length of output: 3722

@zzcr zzcr merged commit 0eb0078 into opentiny:dev Nov 25, 2024
9 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.

2 participants