Skip to content

Conversation

@Youyou-smiles
Copy link
Collaborator

@Youyou-smiles Youyou-smiles commented Mar 27, 2025

fix(button): [button] Adapt to dark themes

Summary by CodeRabbit

  • Style
    • Updated button appearances to refine visual feedback.
    • Streamlined handling of disabled button states by repositioning background styling.
    • Enhanced SVG icon color behavior across default, hover, and disabled states.
    • Introduced new styles and variables for icon-only button variants, improving consistency and visual clarity.

@coderabbitai
Copy link

coderabbitai bot commented Mar 27, 2025

Walkthrough

This pull request updates the button component styles by modifying the CSS for handling disabled states and enhancing SVG icon fill colors. A new style for buttons with the is-only-icon class is introduced, and several new CSS variables related to icon colors and backgrounds are added to support these changes. There are no alterations to exported or public entities.

Changes

File(s) Change Summary
packages/…/button/index.less Added styles for is-only-icon class, modified SVG icon fill colors for various states, and adjusted handling of disabled button styles.
packages/…/button/vars.less Introduced new variables for icon colors and backgrounds for buttons that are icon-only, including hover and disabled states.

Possibly related PRs

Suggested reviewers

  • zzcr

Poem

I'm just a bunny with a hop in my stride,
Celebrating buttons that now shine wide.
No more dull disabled hues in sight,
New icon colors dance with bright light.
Hoppy code, smooth styles — let's all unite! 🐰✨


📜 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 f0bcc84 and 338d7db.

📒 Files selected for processing (1)
  • packages/theme/src/button/index.less (6 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/theme/src/button/index.less
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: PR E2E Test (pnpm test:e2e3)

🪧 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 plan to trigger planning for file edits and PR creation.
  • @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 bug Something isn't working enhancement New feature or request (功能增强) labels Mar 27, 2025
@petercat-assistant
Copy link

Walkthrough

This pull request updates the button component to adapt to dark themes by modifying CSS variables and styles. It introduces new color variables for button states and adjusts the styling for icons and borders to ensure proper appearance in dark mode.

Changes

Files Summary
packages/theme/src/button/index.less Updated styles for button states, including disabled, loading, and active states. Added new SVG fill rules for icons in different button states.
packages/theme/src/button/vars.less Introduced new CSS variables for button colors in dark themes, including icon colors and hover states.

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/button/vars.less (1)

347-352: Refine Only-Icon Background and Hover Variables

The updates introducing

  • --tv-Button-bg-color-only-icon (for the icon color in non-bordered only-icon buttons), and
  • --tv-Button-bg-color-only-icon-ontext-hover along with
  • --tv-Button-bg-color-only-icon-hover (for hover states)

lend more granular control over the visual behavior of icon-only buttons. Please review the naming consistency and verify that these settings deliver the expected visual results under dark theme conditions.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 1a05bd6 and 52272ae.

📒 Files selected for processing (2)
  • packages/theme/src/button/index.less (5 hunks)
  • packages/theme/src/button/vars.less (3 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: PR E2E Test (pnpm test:e2e3)
🔇 Additional comments (8)
packages/theme/src/button/index.less (5)

5-6: Verify Prefix Variable Interpolation

The use of tilde (~) for string interpolation in the definitions of @button-prefix-cls and @svg-prefix-cls ensures that the values are treated as literal strings with dynamic prefixes. Please confirm that this syntax behaves consistently across your build environments and integrates well with dark theme adjustments.


226-229: Update Disabled State Styling for Dark Themes

In the disabled state block, the explicit background-color property has been removed, leaving the styling to rely on the text, border, and icon color variables. This is in line with the objective to adapt the button styling for dark themes. Please verify that the new color values (set via --tv-Button-text-color-disabled, --tv-Button-border-color-disabled, and --tv-Button-icon-color-disabled) provide sufficient contrast and accessibility in dark modes.


269-271: Set Default SVG Icon Color for Only-Icon Buttons

The added rules for the default state of only-icon buttons—specifically setting the SVG fill with var(--tv-Button-color-only-icon-default)—ensure that only-icon buttons use the newly defined variable. Please double-check that this color delivers proper visual contrast in dark themes.


277-279: Apply Hover Styling for Only-Icon Buttons

The hover state for only-icon buttons now updates the SVG fill to use var(--tv-Button-color-only-icon-default-hover). This change should help maintain consistent icon feedback when users hover over buttons. Ensure that the hover color works harmoniously within dark theme contexts.


343-349: Enhance Disabled-Only-Icon Text Button Hover Behavior

The new styling block for .@{button-prefix-cls}--text.is-disabled adds a hover rule that sets the SVG fill to var(--tv-Button-disabled-color-only-icon-hover). This nicely differentiates the disabled state on hover. Please validate that this interaction style remains clear and accessible in both light and dark themes.

packages/theme/src/button/vars.less (3)

332-335: Introduce New Only-Icon Default Color Variables

The new variables

  • --tv-Button-color-only-icon-default
  • --tv-Button-color-only-icon-default-hover

provide dedicated control over the icon colors for only-icon buttons in their default and hover states. This change enhances theme adaptability. Ensure that these colors have been tested for adequate contrast in dark themes.


355-356: Define Disabled-Only-Icon Hover Color

The variable --tv-Button-disabled-color-only-icon-hover now explicitly controls the icon color when a button is disabled and hovered. Confirm that this color meets accessibility contrast requirements, particularly in dark theme scenarios.


364-365: Update Mixed-Layout Icon Color

The refreshed variable --tv-Button-color-icon-svg is now in use to standardize the icon color across mixed-layout buttons. This change should ensure visual consistency. Please confirm its integration with dark theme palettes.

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 (4)
packages/theme/src/button/vars.less (4)

334-337: Clarify Default Icon Color Commenting
The comments on these lines both state "仅图标且default主题时, 图标颜色." To improve clarity, consider explicitly distinguishing between the default state and the hover state. For example, one comment could mention "默认状态图标颜色" and the other "悬浮状态图标颜色."


347-352: Review Naming and Comment Consistency for Icon-Only Button Background Variables
The new variables—--tv-Button-bg-color-only-icon, --tv-Button-bg-color-only-icon-ontext-hover, and --tv-Button-bg-color-only-icon-hover—have comments that mix references to “图标色” and “背景色” in the hover state. Please verify that the variable names and comments accurately describe their intended roles (e.g., whether each is meant to control background color or the icon color for icon-only buttons when there is no border). Consider updating the comments or renaming variables if necessary for consistency.


355-356: Correct Typographical Error in Disabled Icon Color Comment
The comment on line 355 contains what appears to be a typo: "禁用事的图标色" should likely be "禁用时的图标色."


366-367: Update Comment for Mixed Layout Icon Variable
The comment on line 366 states "混排有边框和无边框时,图标右边距," which suggests a margin. However, the variable name --tv-Button-color-icon-svg indicates that it defines an icon color. Please update the comment to accurately reflect that it controls the icon color in mixed layouts.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 52272ae and f0bcc84.

📒 Files selected for processing (2)
  • packages/theme/src/button/index.less (5 hunks)
  • packages/theme/src/button/vars.less (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/theme/src/button/index.less
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: PR E2E Test (pnpm test:e2e3)

@zzcr zzcr merged commit db24997 into dev Mar 28, 2025
5 checks passed
@kagol kagol removed the enhancement New feature or request (功能增强) label Mar 31, 2025
@kagol kagol deleted the lty/fix-button branch April 14, 2025 12:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants