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

refactor(transfer): [transfer] update css vars #2320

Merged
merged 1 commit into from
Oct 21, 2024

Conversation

shenjunjian
Copy link
Collaborator

@shenjunjian shenjunjian commented Oct 19, 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

    • Updated naming conventions for CSS variables in the transfer UI, enhancing consistency and clarity.
  • Style

    • Adjusted various style properties, including font sizes, padding, margins, and colors for buttons and panels to align with the new naming scheme.

@github-actions github-actions bot added the refactoring Refactoring label Oct 19, 2024
Copy link

coderabbitai bot commented Oct 19, 2024

Walkthrough

The pull request involves a comprehensive update to the CSS variables used in the transfer component's stylesheets. The primary change is the renaming of CSS variables from a ti- prefix to a tv- prefix, reflecting a new naming convention. Additionally, the method for injecting CSS variables has been modified. The updates affect various style properties, including font sizes, padding, margins, and colors, ensuring consistency across the component's styles. No new functionality or structural changes to the CSS layout are introduced.

Changes

File Path Change Summary
packages/theme/src/transfer/index.less Renamed CSS variables from --ti- to --tv-, updated properties like font-size, padding, and margins.
packages/theme/src/transfer/vars.less Renamed CSS variables from --ti- to --tv-, updated injection method from .component-css-vars-transfer() to .inject-Transfer-vars(), and modified variable values.

Possibly related PRs

Suggested reviewers

  • zzcr

🐰 In the land of style and cheer,
The variables change, oh so dear!
From ti- to tv-, a fresh new start,
With colors and padding, we craft with heart.
Hopping through code, we make it bright,
A transfer of styles, all done just right! 🌈


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.

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

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

35-35: Check the definition of --tv-Transfer-font-size

Ensure that the CSS variable --tv-Transfer-font-size is defined in your variables file and is correctly referenced here.


296-297: Reconsider setting line-height to header height

Using line-height: var(--tv-Transfer-header-height); matches the line height to the header's total height. This may cause vertical alignment issues with the text. Consider using a line height based on the font size for better text rendering.


346-359: Ensure consistent dimensions for header sort elements

Variables like --tv-Transfer-header-sort-width are used for both width and height of sort elements. Verify that these dimensions are appropriate and consistent with the design guidelines.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 50489a1 and 905cec8.

📒 Files selected for processing (2)
  • packages/theme/src/transfer/index.less (17 hunks)
  • packages/theme/src/transfer/vars.less (1 hunks)
🧰 Additional context used
🔇 Additional comments (6)
packages/theme/src/transfer/vars.less (2)

13-243: Consistent Renaming to New Naming Convention

The CSS variables have been consistently renamed from --ti- to --tv-, aligning with the updated naming convention. This improves code clarity and maintainability.


13-13: Verify the Method Name Change Alignment with Project Conventions

At line 13, the method name has been changed from .component-css-vars-transfer() to .inject-Transfer-vars(). Please ensure that this new method name conforms to the project's naming conventions and that all references to the old method name are updated throughout the codebase.

Run the following script to check for any remaining occurrences of the old method name:

✅ Verification successful

Method Name Change Alignment Verified

All references to .component-css-vars-transfer() have been successfully updated to .inject-Transfer-vars() throughout the codebase, conforming to project naming conventions.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Search for any occurrences of .component-css-vars-transfer in the codebase.

# Test: Search for the old method name. Expect: No occurrences found.
rg --type less '\.component-css-vars-transfer\('

Length of output: 50


Script:

#!/bin/bash
# Description: Perform a case-insensitive search for .component-css-vars-transfer in all LESS files.

# Test: Ensure no occurrences of the old method name exist.
rg --type less -i '\.component-css-vars-transfer\('

Length of output: 53


Script:

#!/bin/bash
# Description: Use ast-grep to search for any usage of .component-css-vars-transfer in all LESS files.

# Test: Ensure no occurrences of the old method name exist.
ast-grep --lang css --pattern $'\.component-css-vars-transfer($_)' '**/*.less'

Length of output: 481


Script:

#!/bin/bash
# Description: List all .less files in the codebase to verify their existence and paths.

fd --extension less

Length of output: 29815


Script:

#!/bin/bash
# Description: Perform a comprehensive search for .component-css-vars-transfer in all .less files.

# Search for the old method name with word boundaries to ensure accurate matches.
rg --type less '\.component-css-vars-transfer\('

Length of output: 50

packages/theme/src/transfer/index.less (4)

30-30: Ensure the mixin .inject-Transfer-vars(); is correctly defined

The mixin .inject-Transfer-vars(); is used here. Please verify that it is correctly defined and imported, replacing the previous mixin .component-css-vars-transfer(); if applicable.


83-86: Verify definitions of padding variables for buttons

The variables for button padding (--tv-Transfer-button-padding-left, etc.) are used here. Please ensure they are correctly defined in your variables file.


127-130: Ensure disabled state variables are defined

Variables like --tv-Transfer-button-disabled-border-color, --tv-Transfer-button-disabled-bg-color, and --tv-Transfer-button-disabled-text-color are used for styling the disabled state. Verify that these variables are defined and match the design specifications.


248-249: Confirm hover state variables are defined

The variables --tv-Transfer-panel-item-hover-bg-color and --tv-Transfer-panel-item-hover-text-color are applied on hover. Please ensure they are defined and provide the desired visual effect.

// 面板头部边框色
--ti-transfer-header-border-color: rgba(0, 0, 0, 0.08);
--tv-Transfer-header-border-color: #00000014; // 没有对应common变量值
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Avoid Hardcoded Color Values Without Variable Reference

At line 109, the variable --tv-Transfer-header-border-color is assigned a hardcoded color value #00000014 with the comment // 没有对应common变量值 ("No corresponding common variable value").

To maintain consistency and ease future theming, consider defining a common variable for this color in the global variables file. This allows for centralized management of color values and enhances themability.

Apply this diff to define and use a common variable:

Define the new common variable in the global variables file:

+ // In packages/theme/src/common/variables.less
+ --tv-color-border-light: #00000014;

Update the assignment in vars.less:

- --tv-Transfer-header-border-color: #00000014; // 没有对应common变量值
+ --tv-Transfer-header-border-color: var(--tv-color-border-light);

Committable suggestion was skipped due to low confidence.

Comment on lines +266 to +269
margin-left: var(--tv-Transfer-panel-filter-padding-left);
margin-right: var(--tv-Transfer-panel-filter-padding-right);
margin-top: var(--tv-Transfer-panel-filter-padding-top);
margin-bottom: var(--tv-Transfer-panel-filter-padding-bottom);
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Validate the change from padding to margin

The padding has been changed to margin to address spacing issues with absolute positioned elements. Ensure that this change does not introduce unintended layout shifts or affect the component's responsiveness.


&:not(.is-disabled) {
border-color: var(--ti-transfer-button-bg-color) !important;
border-color: var(--tv-Transfer-button-bg-color) !important;
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Potential mismatch between border-color and background-color variables

Setting border-color to var(--tv-Transfer-button-bg-color) might not reflect the intended design. Typically, a separate variable for border-color is used.

Consider introducing a specific border color variable:

- border-color: var(--tv-Transfer-button-bg-color) !important;
+ border-color: var(--tv-Transfer-button-border-color) !important;

Ensure that --tv-Transfer-button-border-color is defined appropriately.

Committable suggestion was skipped due to low confidence.

Comment on lines +48 to +54
margin-left: var(--tv-Transfer-buttons-defaultButton-margin-left);
}

& + .@{button-prefix-cls} {
margin-right: var(--ti-transfer-buttons-defaultButton-margin-right);
margin-top: var(--ti-transfer-buttons-defaultButton-margin-top);
margin-bottom: var(--ti-transfer-buttons-defaultButton-margin-bottom);
margin-right: var(--tv-Transfer-buttons-defaultButton-margin-right);
margin-top: var(--tv-Transfer-buttons-defaultButton-margin-top);
margin-bottom: var(--tv-Transfer-buttons-defaultButton-margin-bottom);
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Inconsistent variable naming: buttons vs. button

There is a mix of variable names using both --tv-Transfer-buttons- and --tv-Transfer-button- prefixes. Please ensure consistency in variable naming to avoid confusion and potential errors.

Consider updating the variable names for consistency:

- margin-left: var(--tv-Transfer-buttons-defaultButton-margin-left);
+ margin-left: var(--tv-Transfer-button-defaultButton-margin-left);

Repeat this change for all occurrences to maintain a consistent naming convention.

Committable suggestion was skipped due to low confidence.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactoring Refactoring
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants