Thanks to visit codestin.com
Credit goes to github.com

Skip to content

feat(checkbox): [checkbox] Component dark theme adaptation #3007

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

Merged
merged 6 commits into from
Mar 5, 2025

Conversation

Youyou-smiles
Copy link
Collaborator

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

feat(checkbox): [checkbox] Component dark theme adaptation

Summary by CodeRabbit

  • Style

    • Refined the checkbox’s visual presentation with updated styling for SVG elements, hover, selected, and disabled states.
    • Improved customization options with enhanced control over background, border colors, and dimensions.
  • Tests

    • Adjusted visual tests to target specific SVG paths, ensuring alignment with the updated styling and a consistent user experience.

Copy link

coderabbitai bot commented Mar 3, 2025

Walkthrough

This pull request refactors the styling of the checkbox component. The old SVG styling rules have been removed and replaced with new input-based styles that define dimensions, fill properties, and hover/disabled state behaviors. In addition, several SVG-specific CSS variables were removed in favor of new variables controlling background and border colors for different states. The associated test has also been updated to target the first <path> element within the SVG for its CSS assertions.

Changes

File(s) Change Summary
packages/theme/.../checkbox/index.less and packages/theme/.../checkbox/vars.less Styling Update: Removed legacy SVG styles; added &__input styles with new classes for checked, half-selected, and disabled states; replaced specific SVG variables with new ones for background and border colors.
examples/.../checkbox/basic-usage.spec.ts Test Update: Modified selector to assert the fill color on the first <path> element within the checkbox SVG.

Possibly related PRs

Suggested reviewers

  • zzcr

Poem

I'm a little bunny hopping with glee,
Spotting fresh updates as pretty as can be.
New styles and variables make my world bright,
Checkboxes now shine with Colors just right!
With a twitch of my nose, I celebrate this delight! 🐰
Hop on, developers—let's code into the night!


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ 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 Mar 3, 2025
Copy link

Walkthrough

This pull request adapts the checkbox component to support a dark theme. It involves significant changes to the styling of the checkbox, including updates to the LESS files for theme variables and component styles, as well as modifications to the Vue component to reflect these style changes.

Changes

Files Summary
packages/theme/src/checkbox/index.less Updated styles for checkbox component to support dark theme, including new styles for checked, unchecked, and disabled states.
packages/theme/src/checkbox/vars.less Added new theme variables for dark theme support and removed unused variables.
packages/vue/src/checkbox/src/pc.vue Modified Vue component to use updated class names for checkbox icons.

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: 3

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

152-180: Good implementation of SVG styling for different checkbox states.

The addition of specific SVG styling for different checkbox states (checked, half-selected, and unchecked) is well-structured and properly leverages CSS variables for theme customization.

However, there's a potential issue with the unchecked state background:

- fill: rgba(255,255,255,0.02);
+ fill: var(--tv-Checkbox-unchecked-bg-color);

The current semi-transparent white background (rgba(255,255,255,0.02)) may not render correctly in all theme environments. Consider creating a new CSS variable for this purpose in the vars file to ensure consistent behavior across themes.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 6cbb529 and 157a5c3.

📒 Files selected for processing (3)
  • packages/theme/src/checkbox/index.less (1 hunks)
  • packages/theme/src/checkbox/vars.less (1 hunks)
  • packages/vue/src/checkbox/src/pc.vue (1 hunks)
🔇 Additional comments (1)
packages/vue/src/checkbox/src/pc.vue (1)

73-73: Updated the unchecked state styling with an appropriate class name.

This change modifies the class name for the unchecked checkbox icon from icon-check to icon-not-check, which better aligns with its purpose in the UI and allows for more specific styling in the dark theme adaptation.

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

♻️ Duplicate comments (1)
packages/theme/src/checkbox/index.less (1)

181-200: 🛠️ Refactor suggestion

Replace Hardcoded Color in Disabled State Icons

Within the disabled state for the checkbox input, the path:last-child of the .icon-checked-sur, .icon-halfselect block (line 187) is still using a hardcoded color (#FFFFFF). This duplicates an earlier review comment recommending the use of a CSS variable to ensure consistent theming. Consider replacing the hardcoded value with the appropriate CSS variable (for example, var(--tv-Checkbox-border-color-inverse)) to maintain theme consistency.

Proposed diff:

-          fill: #FFFFFF;
+          fill: var(--tv-Checkbox-border-color-inverse);
🧹 Nitpick comments (1)
packages/theme/src/checkbox/index.less (1)

151-180: Dark Theme Input Styling – Updated SVG and Icon States

The new styles under &__input effectively set the SVG dimensions and update the icon fill properties for various states. The use of CSS variables (e.g., var(--tv-Checkbox-svg-width), var(--tv-Checkbox-bg-active-color), and var(--tv-Checkbox-border-color-inverse)) helps ensure consistency with the dark theme adaptation. Please double-check that the values for the subtle fill (rgba(255,255,255,0.02)) and hover state (var(--tv-Checkbox-unchecked-border-hover-color)) match the design specifications across all states.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 157a5c3 and b8341b4.

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

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

♻️ Duplicate comments (1)
packages/theme/src/checkbox/index.less (1)

180-198: 🛠️ Refactor suggestion

Replace Hardcoded Color in Disabled State
Within the disabled state styling (&__input.is-disabled), the path:last-child of .icon-checked-sur, .icon-halfselect is still using a hardcoded #FFFFFF. As noted in previous reviews, replacing hardcoded values with CSS variables (for example, using var(--tv-Checkbox-border-color-inverse) or another appropriate variable) will improve theme consistency and maintainability.

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

151-179: Enhanced SVG Styling for Enabled Checkbox Input
The new styles under &__input establish clear, state-specific styling for the checkbox’s inner SVG. Defining the SVG’s font size via var(--tv-Checkbox-icon-size) and applying CSS variables for different icon states (e.g., var(--tv-Checkbox-bg-color-active), var(--tv-Checkbox-border-color-inverse), etc.) ensures that the component adapts well to both dark and light themes. This approach enhances maintainability and consistency across themes.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 15d3247 and a04bf45.

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

@zzcr zzcr merged commit 64cde0d into dev Mar 5, 2025
9 of 10 checks passed
@Youyou-smiles Youyou-smiles deleted the lty/feat-checkbox branch March 19, 2025 09:19
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