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(theme): [scroll-text] refactor scroll-text、scrollbar、tall-st… #2292

Merged
merged 1 commit into from
Oct 18, 2024

Conversation

zzcr
Copy link
Member

@zzcr zzcr commented Oct 18, 2024

…orage、top-box theme vars

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 variable naming conventions for multiple components, enhancing consistency across styles.
    • Introduced new methods for injecting CSS variables, improving the structure of the codebase.
  • Bug Fixes

    • Enhanced animation fluidity for scroll text and scrollbar components.
  • Chores

    • Reorganized and simplified CSS variable definitions across various components, ensuring clarity and maintainability.

Copy link

coderabbitai bot commented Oct 18, 2024

Walkthrough

The changes in this pull request involve a comprehensive update to the CSS variable naming conventions across multiple components in the theme package. The primary modification is the replacement of the mixin method calls with new injection methods, such as .inject-ScrollText-vars() and similar for other components. Additionally, variable names have been updated from the --ti- prefix to the --tv- prefix, reflecting a standardized naming approach. Keyframes and styling properties have also been adjusted to enhance the animation and overall structure of the CSS.

Changes

File Path Change Summary
packages/theme/src/scroll-text/index.less Replaced .component-css-vars-scroll-text() with .inject-ScrollText-vars(), updated variable names to --tv-, modified keyframes for animations.
packages/theme/src/scroll-text/vars.less Replaced .component-css-vars-scroll-text() with .inject-ScrollText-vars(), updated variable names to --tv-.
packages/theme/src/scrollbar/index.less Replaced .component-css-vars-scrollbar() with .inject-Scrollbar-vars(), updated variable names to --tv-.
packages/theme/src/scrollbar/vars.less Replaced .component-css-vars-scrollbar() with .inject-Scrollbar-vars(), updated variable names to --tv-.
packages/theme/src/tall-storage/index.less Replaced .component-css-vars-tall-storage() with .inject-TallStorage-vars(), updated variable names to --tv-.
packages/theme/src/tall-storage/vars.less Replaced .component-css-vars-tall-storage() with .inject-TallStorage-vars(), updated variable names to --tv-.
packages/theme/src/top-box/index.less Replaced .component-css-vars-top-box() with .inject-TopBox-vars(), updated variable names to --tv-.
packages/theme/src/top-box/vars.less Replaced .component-css-vars-top-box() with .inject-TopBox-vars(), updated variable names to --tv-.

Possibly related PRs

Suggested labels

refactoring

Poem

🐰 In the land of styles and hues,
A rabbit hops with joyful news!
Variables fresh, with a new prefix,
Our components dance, oh what a mix!
From ti- to tv-, a grand renown,
In this theme, we wear our crown! 🌟


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 refactoring Refactoring (重构) label Oct 18, 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: 2

🧹 Outside diff range and nitpick comments (2)
packages/theme/src/top-box/vars.less (1)

13-20: Excellent refactoring of CSS variables!

The changes in this function improve the naming conventions and semantic meaning of the variables. The new .inject-TopBox-vars() function aligns well with the project's naming standards, and the use of more specific semantic variable names enhances code readability and maintainability.

Consider adding a brief comment above the function to explain its purpose and usage, which would further improve code documentation. For example:

// Injects CSS variables for the TopBox component
.inject-TopBox-vars() {
  // ... (existing code)
}
packages/theme/src/scrollbar/index.less (1)

Line range hint 1-86: Summary: Consistent refactoring of variable names and injection method.

The changes in this file are part of a larger refactoring effort to standardize variable naming conventions and injection methods. The updates include:

  1. Changing the variable prefix from --ti- to --tv-.
  2. Capitalizing "Scrollbar" in variable names.
  3. Updating the injection method from .component-css-vars-scrollbar() to .inject-Scrollbar-vars().

These changes improve consistency and clarity without altering the functionality of the scrollbar component. The refactoring aligns well with the PR objectives.

To ensure this refactoring effort is consistent across the entire project, consider using a linter or style guide that enforces these new naming conventions. This will help maintain consistency in future development and prevent regressions to the old naming style.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 831d4cd and 40ade98.

📒 Files selected for processing (8)
  • packages/theme/src/scroll-text/index.less (3 hunks)
  • packages/theme/src/scroll-text/vars.less (1 hunks)
  • packages/theme/src/scrollbar/index.less (3 hunks)
  • packages/theme/src/scrollbar/vars.less (1 hunks)
  • packages/theme/src/tall-storage/index.less (2 hunks)
  • packages/theme/src/tall-storage/vars.less (1 hunks)
  • packages/theme/src/top-box/index.less (3 hunks)
  • packages/theme/src/top-box/vars.less (1 hunks)
🧰 Additional context used
🔇 Additional comments (26)
packages/theme/src/scroll-text/vars.less (1)

13-15: Approve the refactoring of CSS variable injection

The changes to the function name and variable naming convention are consistent with the PR objectives of refactoring the theme components. The new structure using .inject-ScrollText-vars() and the --tv- prefix for variables improves consistency and readability.

However, please note the following:

  1. The removal of margin-related variables that were present in the previous version might affect the layout of the ScrollText component. Ensure that this removal is intentional and doesn't negatively impact the component's appearance or functionality in different contexts.

  2. If there's any documentation referencing the old variable names or the previous function name, it should be updated to reflect these changes.

To ensure consistency across the codebase, please run the following script:

This script will help identify any remaining instances of the old naming conventions that might need to be updated, as well as potential documentation files that might require revision.

✅ Verification successful

It appears there was an error in the previous search for the --ti- prefix. Here's the corrected script to properly search for the old variable prefix:

[/run_scripts]


To ensure that the removal of margin-related variables does not negatively impact the ScrollText component, please run the following script:

[/run_scripts]


Please use the following corrected script to verify the removal of margin-related variables:

[/run_scripts]


To correctly verify the removal of margin-related variables without encountering path errors, please use the following updated script:

[/run_scripts]


Approve the refactoring of CSS variable injection

The changes to the function name and variable naming convention are consistent with the PR objectives of refactoring the theme components. The new structure using .inject-ScrollText-vars() and the --tv- prefix for variables improves consistency and readability.

Additionally, the removal of margin-related variables has been successfully verified, ensuring that there are no residual instances that could affect the component's layout.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for any remaining occurrences of old variable names or function names

# Test 1: Search for old variable prefix
echo "Searching for old --ti- prefix in ScrollText related files:"
rg --type less '--ti-' packages/theme/src/scroll-text

# Test 2: Search for old function name
echo "Searching for old component-css-vars-scroll-text function:"
rg --type less 'component-css-vars-scroll-text' packages/theme/src/scroll-text

# Test 3: Check for any documentation files that might need updating
echo "Checking for potential documentation files that might need updating:"
fd -e md -e txt . packages/theme/src/scroll-text

Length of output: 994


Script:

#!/bin/bash
# Description: Corrected script to check for any remaining occurrences of old variable names or function names

# Test 1: Search for old variable prefix
echo "Searching for old --ti- prefix in ScrollText related files:"
rg --type less -- '--ti-' packages/theme/src/scroll-text

# Test 2: Search for old function name
echo "Searching for old component-css-vars-scroll-text function:"
rg --type less 'component-css-vars-scroll-text' packages/theme/src/scroll-text

# Test 3: Check for any documentation files that might need updating
echo "Checking for potential documentation files that might need updating:"
fd -e md -e txt . packages/theme/src/scroll-text

Length of output: 589


Script:

#!/bin/bash
# Description: Verify the removal of margin-related variables in ScrollText

# Test 1: Search for any margin-related CSS variables in vars.less
echo "Checking for remaining margin-related variables in vars.less:"
rg --type less '--tv-ScrollText-.*margin' packages/theme/src/scroll-text/vars.less

# Test 2: Search for any usage of margin variables in ScrollText component files
echo "Searching for usage of margin-related variables in ScrollText component files:"
rg '--tv-ScrollText-.*margin' packages/theme/src/scroll-text/**/*.{less,css}

# Test 3: Ensure that no legacy margin variables exist in documentation
echo "Checking for legacy margin variables in documentation files:"
rg '--ti-.*margin' packages/theme/src/scroll-text/**/*.{md,txt}

Length of output: 2006


Script:

#!/bin/bash
# Description: Corrected script to verify the removal of margin-related variables in ScrollText

# Test 1: Search for any margin-related CSS variables in vars.less
echo "Checking for remaining margin-related variables in vars.less:"
rg --type less -e '--tv-ScrollText-.*margin' packages/theme/src/scroll-text/vars.less

# Test 2: Search for any usage of margin variables in ScrollText component files
echo "Searching for usage of margin-related variables in ScrollText component files:"
rg -e '--tv-ScrollText-.*margin' packages/theme/src/scroll-text/**/*.{less,css}

# Test 3: Ensure that no legacy margin variables exist in documentation
echo "Checking for legacy margin variables in documentation files:"
rg -e '--ti-.*margin' packages/theme/src/scroll-text/**/*.{md,txt}

Length of output: 1065


Script:

#!/bin/bash
# Description: Corrected script to verify the removal of margin-related variables in ScrollText

# Test 1: Search for any margin-related CSS variables in vars.less
echo "Checking for remaining margin-related variables in vars.less:"
rg --type less -e '--tv-ScrollText-.*margin' packages/theme/src/scroll-text/vars.less

# Test 2: Search for any usage of margin variables in ScrollText component files (.less and .css)
echo "Searching for usage of margin-related variables in ScrollText component files:"
rg -e '--tv-ScrollText-.*margin' -t less -t css packages/theme/src/scroll-text

# Test 3: Ensure that no legacy margin variables exist in documentation files (.md and .txt)
echo "Checking for legacy margin variables in documentation files:"
rg -e '--ti-.*margin' -t md -t txt packages/theme/src/scroll-text

Length of output: 667

packages/theme/src/tall-storage/vars.less (1)

13-23: Excellent refactoring of the TallStorage component variables!

The changes in this file represent a significant improvement:

  1. The function naming .inject-TallStorage-vars() is more descriptive and follows a consistent pattern.
  2. The variable naming convention has been updated from --ti- to --tv-, which appears to be a standardization across the codebase.
  3. Each variable is clearly defined with a descriptive name and references other variables for values, promoting consistency and ease of maintenance.
  4. The added comments for each variable provide clear explanations of their purposes, enhancing code readability.

Overall, this refactoring improves code organization, readability, and maintainability.

To ensure consistency across the codebase, please run the following verification script:

This script will help ensure that:

  1. The old --ti- prefix is not used elsewhere in the theme package.
  2. The new .inject-TallStorage-vars() function is properly used.
  3. The old .component-css-vars-tall-storage() function is not referenced anywhere.
✅ Verification successful

Verification Successful!

All instances of the old --ti- prefix and .component-css-vars-tall-storage() function have been removed. The new .inject-TallStorage-vars() function is correctly used in the codebase.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of new variable prefix and function name

# Test 1: Check for any remaining occurrences of the old prefix
echo "Checking for old '--ti-' prefix usage:"
rg --type less "'--ti-'" packages/theme/src

# Test 2: Verify the usage of the new function name
echo "Checking for usage of new function name:"
rg --type less "\.inject-TallStorage-vars\(\)" packages/theme/src

# Test 3: Check for any remaining occurrences of the old function name
echo "Checking for old function name usage:"
rg --type less "\.component-css-vars-tall-storage\(\)" packages/theme/src

Length of output: 608

packages/theme/src/scrollbar/vars.less (2)

25-25: Approve function name change and verify usage.

The new function name .inject-Scrollbar-vars() is more descriptive and follows a better naming convention. This change improves code readability and maintainability.

To ensure this change doesn't break existing code, please run the following script to check for any remaining usage of the old function name:

#!/bin/bash
# Description: Check for any remaining usage of the old function name

# Test: Search for the old function name. Expect: No results.
rg --type less -g '!packages/theme/src/scrollbar/vars.less' '.component-css-vars-scrollbar\(\)'

# Test: Search for the new function name. Expect: At least one result (the import/usage of this function).
rg --type less '.inject-Scrollbar-vars\(\)'

27-35: Approve CSS variable updates and verify usage.

The changes to the CSS variable names and values improve consistency and modularity in the theming system. The new --tv- prefix and the use of other --tv- prefixed variables for values create a more maintainable and flexible structure.

To ensure these changes don't break existing styles, please run the following script to check for any remaining usage of the old variable names:

Additionally, please ensure that the new --tv- prefixed variables used for values (e.g., --tv-space-sm, --tv-color-bg-scrollbar-thumb, etc.) are properly defined elsewhere in the theme.

✅ Verification successful

CSS Variable Refactor Verified

The refactoring of CSS variable names from --ti- to --tv- has been successfully verified. No remaining usages of the old variable names were found, and the new variable names are consistently used across the codebase.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for any remaining usage of the old variable names

# Test: Search for the old variable names. Expect: No results outside this file.
rg --type less -g '!packages/theme/src/scrollbar/vars.less' '\-\-ti-(scrollbar-vertical-right|scrollbar-vertical-width|scrollbar-thumb-bg-color|scrollbar-thumb-hover-bg-color|scrollbar-thumb-border-radius)'

# Test: Search for the new variable names. Expect: At least one result for each (the declaration in this file and potentially usage in other files).
rg --type less '\-\-tv-(Scrollbar-vertical-right|Scrollbar-vertical-width|Scrollbar-thumb-bg-color|Scrollbar-thumb-hover-bg-color|Scrollbar-thumb-border-radius)'

Length of output: 543


Script:

#!/bin/bash
# Description: Check for any remaining usage of the old variable names outside the specified file.

# Test 1: Search for the old variable names. Expect: No results outside this file.
rg --type less -g '!packages/theme/src/scrollbar/vars.less' '\-\-ti\-(scrollbar-vertical-right|scrollbar-vertical-width|scrollbar-thumb-bg-color|scrollbar-thumb-hover-bg-color|scrollbar-thumb-border-radius)'

# Test 2: Search for the new variable names. Expect: At least one result for each (the declaration in this file and potentially usage in other files).
rg --type less '\-\-tv\-(Scrollbar-vertical-right|Scrollbar-vertical-width|Scrollbar-thumb-bg-color|Scrollbar-thumb-hover-bg-color|Scrollbar-thumb-border-radius)'

Length of output: 1386


Script:

#!/bin/bash
# Description: Verify the usage of CSS variables with old and new prefixes.

# Test 1: Search for any remaining usage of old CSS variable names outside the specified file.
# Expect: No results should be found.
rg --type less -g '!packages/theme/src/scrollbar/vars.less' '--ti\-(scrollbar-vertical-right|scrollbar-vertical-width|scrollbar-thumb-bg-color|scrollbar-thumb-hover-bg-color|scrollbar-thumb-border-radius)'

# Test 2: Search for usages of the new CSS variable names across the codebase.
# Expect: At least one result for each new variable should be found, including their declarations and usages.
rg --type less '--tv\-(Scrollbar-vertical-right|Scrollbar-vertical-width|Scrollbar-thumb-bg-color|Scrollbar-thumb-hover-bg-color|Scrollbar-thumb-border-radius)'

Length of output: 1462


Script:

#!/bin/bash
# Description: Verify the usage of CSS variables with old and new prefixes.

# Test 1: Search for any remaining usage of old CSS variable names outside the specified file.
# Expect: No results should be found.
rg --type less -g '!packages/theme/src/scrollbar/vars.less' -e '--ti-(scrollbar-vertical-right|scrollbar-vertical-width|scrollbar-thumb-bg-color|scrollbar-thumb-hover-bg-color|scrollbar-thumb-border-radius)'

# Test 2: Search for usages of the new CSS variable names across the codebase.
# Expect: At least one result for each new variable should be found, including their declarations and usages.
rg --type less -e '--tv-(Scrollbar-vertical-right|Scrollbar-vertical-width|Scrollbar-thumb-bg-color|Scrollbar-thumb-hover-bg-color|Scrollbar-thumb-border-radius)'

Length of output: 1386

packages/theme/src/tall-storage/index.less (4)

30-30: Approve the updated border radius variable name.

The change from --ti-tall-storage-border-radius to --tv-TallStorage-border-radius is consistent with the new naming convention. This update improves consistency across the component's variables.


39-39: Approve the updated item height variable name.

The change from --ti-tall-storage-item-height to --tv-TallStorage-item-height aligns with the new naming convention. The calc() function usage remains intact, preserving the existing layout logic while improving naming consistency.


Line range hint 1-54: Summary: Consistent application of new naming conventions and injection method.

The changes in this file successfully implement the new naming convention for CSS variables (changing from --ti- to --tv- prefix and using PascalCase for component names) and update the variable injection method. These modifications improve consistency and specificity in the TallStorage component styling.

Key points:

  1. Variable injection method updated to .inject-TallStorage-vars().
  2. All CSS variable names updated to follow the new --tv-TallStorage-* pattern.
  3. Component-specific box shadow variable introduced.

These changes align well with the refactoring objectives. Ensure that similar updates are applied consistently across other components in the theme package.


42-43: Approve the updated variable names for item properties.

The changes to variable names for item height, line height, and background color are consistent with the new naming convention. This improves overall consistency within the component.

To ensure all instances have been updated, please run the following script:

#!/bin/bash
# Description: Verify consistent usage of new variable names in the TallStorage component

echo "Checking for any remaining old variable names in TallStorage:"
rg --type less '--ti-tall-storage-' packages/theme/src/tall-storage/

echo "Verifying usage of new variable names in TallStorage:"
rg --type less '--tv-TallStorage-' packages/theme/src/tall-storage/

This will help identify any missed instances of the old naming convention and confirm the consistent use of the new names throughout the component.

Also applies to: 50-50

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

53-53: LGTM: Hover state variable name updated.

The change from --ti-scrollbar-thumb-hover-bg-color to --tv-Scrollbar-thumb-hover-bg-color is consistent with the new naming convention and aligns with the previous updates.


66-68: LGTM: Vertical scrollbar variable names updated.

The changes from --ti-scrollbar-vertical-width to --tv-Scrollbar-vertical-width and --ti-scrollbar-vertical-right to --tv-Scrollbar-vertical-right are consistent with the new naming convention and align with the previous updates.

To ensure these changes don't unintentionally affect the vertical scrollbar's appearance, let's verify the values assigned to these variables:

#!/bin/bash
# Description: Verify the values of the new vertical scrollbar variables

# Test: Search for the variable definitions
rg --type less "tv-Scrollbar-vertical-(width|right):\s*" packages/theme/src

48-49: LGTM: Variable naming convention updated.

The change from --ti- to --tv- prefix and the capitalization of "Scrollbar" in the variable names align with the refactoring objectives. This new naming convention appears to be more specific to the Tiny Vue project.

To ensure consistency across the codebase, let's verify the usage of these new variable names:

#!/bin/bash
# Description: Verify the usage of new variable names

# Test: Search for any remaining usage of old variable names
rg --type less "--ti-scrollbar-thumb-(border-radius|bg-color)" packages/theme/src

# Test: Confirm the usage of new variable names
rg --type less "--tv-Scrollbar-thumb-(border-radius|bg-color)" packages/theme/src

19-19: LGTM: Injection method updated.

The change from .component-css-vars-scrollbar() to .inject-Scrollbar-vars() aligns with the refactoring objectives and improves clarity. This new naming convention appears to be more explicit about its purpose.

To ensure consistency across the codebase, let's verify the implementation of this new injection method:

✅ Verification successful

✅ Injection method implementation verified.

The .inject-Scrollbar-vars() method is properly defined in packages/theme/src/scrollbar/vars.less and is correctly utilized in index.less. This confirms that the refactoring aligns with the project's objectives and maintains clarity.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the implementation of the new injection method

# Test: Search for the definition of .inject-Scrollbar-vars()
rg --type less "\.inject-Scrollbar-vars\s*\(\)" packages/theme/src

Length of output: 1063


Script:

#!/bin/bash
# Description: Corrected script to verify the implementation of the new injection method

# Test: Search for the definition of .inject-Scrollbar-vars()
rg --type less '\.inject-Scrollbar-vars\s*\(\)' packages/theme/src

Length of output: 202

packages/theme/src/top-box/index.less (8)

21-21: Improved method naming for CSS variable injection.

The change from .component-css-vars-top-box() to .inject-TopBox-vars() enhances code readability and maintains consistency with the new naming convention. This refactoring aligns well with the PR objectives of standardizing the approach across components.


29-29: Consistent update of CSS variable name.

The change from --ti-top-box-bg-color to --tv-TopBox-bg-color aligns with the new naming convention. This update maintains consistency across the component library and improves the overall structure of the CSS variables.


77-77: Consistent update of success icon color variable.

The change from --ti-top-box-success-icon-color to --tv-TopBox-success-icon-color maintains consistency with the new naming convention while preserving the semantic meaning of the variable.


81-81: Consistent update of error icon color variable.

The change from --ti-top-box-error-icon-color to --tv-TopBox-error-icon-color aligns with the new naming convention, maintaining consistency across the component.


85-85: Consistent update of warning icon color variable.

The change from --ti-top-box-warning-icon-color to --tv-TopBox-warning-icon-color follows the established pattern, ensuring consistency with the new naming convention.


89-89: Consistent updates of help and info icon color variables.

The changes from:

  • --ti-top-box-help-icon-color to --tv-TopBox-help-icon-color
  • --ti-top-box-info-icon-color to --tv-TopBox-info-icon-color

Both align with the new naming convention, completing the consistent refactoring of icon color variables across all states (success, error, warning, help, and info).

Also applies to: 93-93


38-38: Consistent update of icon font size variable with a note on the default value.

The change from --ti-top-box-icon-font-size to --tv-TopBox-icon-font-size aligns with the new naming convention. However, the default value (24px) has been removed from this usage.

Please confirm that the default value for --tv-TopBox-icon-font-size is defined elsewhere, possibly in a central configuration file. Run the following script to check:


Line range hint 21-93: Summary of refactoring changes in top-box component.

The changes in this file consistently update the CSS variable naming convention and injection method. Key points:

  1. The prefix changed from --ti- to --tv-, likely reflecting a change in the design system or component library name.
  2. Component names in variables are now in PascalCase (e.g., TopBox) instead of kebab-case.
  3. The injection method was renamed from .component-css-vars-top-box() to .inject-TopBox-vars(), improving clarity and consistency.
  4. All icon color variables for different states (success, error, warning, help, info) were updated to follow the new convention.

These changes align well with the PR objectives of refactoring and standardizing the approach across components. The consistency of the changes suggests a well-planned and executed refactoring effort.

To ensure the refactoring is consistent across the entire codebase, run the following script:

This will help identify any instances that might have been missed during the refactoring process.

packages/theme/src/scroll-text/index.less (6)

156-160: Approve addition of midpoint in moveLeftWidthAdapt animation

The addition of a 50% keyframe with transform: translateX(0) in the moveLeftWidthAdapt animation is a good enhancement. This creates a pause effect at the midpoint of the animation, potentially making it feel more natural or purposeful.

Consider verifying the animation behavior to ensure it meets the intended design.


165-177: Approve addition of moveRightWidthAdapt animation

The addition of the moveRightWidthAdapt keyframe animation is a good complement to the existing moveLeftWidthAdapt animation. It provides right-to-left movement and mirrors the structure of its counterpart, including the midpoint pause.

This addition enhances the component's flexibility, allowing for bidirectional animations.


Line range hint 1-177: Summary of ScrollText component changes

The changes to the ScrollText component involve several improvements:

  1. Adoption of a new theming system using injection methods.
  2. Consistent update of CSS variable prefixes from --ti- to --tv-.
  3. Enhanced animations with the addition of midpoint pauses and a new right-to-left animation.

These changes generally improve the component's consistency and functionality. However, there are a couple of points that require clarification:

  1. The change to a fixed margin value instead of a variable.
  2. The modification of selector specificity in the .width-adapt class.

Overall, the refactoring appears to be a positive step towards a more maintainable and flexible component.


24-27: Approve variable naming changes, query about margin

The update of variable prefixes from --ti- to --tv- improves consistency with the new naming convention. This change is approved.

However, the margin has been changed from a variable to a fixed value of 0 auto. Was this intentional? It might reduce flexibility in theming.

To ensure consistency of the new naming convention, please run:

#!/bin/bash
# Description: Check for any remaining uses of the old prefix and confirm the usage of the new prefix.

# Test 1: Search for any remaining uses of the old prefix
echo "Checking for any remaining uses of the old prefix:"
rg --type less "--ti-scroll-text-"

# Test 2: Confirm the usage of the new prefix
echo "Confirming the usage of the new prefix:"
rg --type less "--tv-ScrollText-"

99-99: Query about selector specificity change

Spaces have been added before the div selectors in the .width-adapt class. This changes the specificity of the selectors and how they match elements. Was this change intentional? If so, what's the reasoning behind it?

      > div.left {
      > div.right {

This modification could affect how styles are applied in the cascade.

To understand the impact of this change, please run:

#!/bin/bash
# Description: Check for similar selector patterns in other components

# Test: Search for similar selector patterns in other components
echo "Checking for similar selector patterns in other components:"
rg --type less "> div\.(left|right)"

Also applies to: 104-104


20-20: Approve the use of .inject-ScrollText-vars()

The change from a mixin to an injection method is a good refactoring step. It likely improves the theming system's modularity and maintainability.

To ensure this change is consistent across the codebase, please run the following script:

✅ Verification successful

Verification Successful

The old mixin .component-css-vars-scroll-text() is no longer present in the codebase, and the new injection method .inject-ScrollText-vars() is correctly implemented.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for any remaining uses of the old mixin and confirm the presence of the new injection method.

# Test 1: Search for any remaining uses of the old mixin
echo "Checking for any remaining uses of the old mixin:"
rg --type less "\.component-css-vars-scroll-text\(\)"

# Test 2: Confirm the presence of the new injection method
echo "Confirming the presence of the new injection method:"
rg --type less "\.inject-ScrollText-vars\(\)"

Length of output: 926


Script:

#!/bin/bash
# Description: Check for any remaining uses of the old mixin and confirm the presence of the new injection method.

# Test 1: Search for any remaining uses of the old mixin
echo "Checking for any remaining uses of the old mixin:"
rg --type less "\.component-css-vars-scroll-text\(\)"

# Test 2: Confirm the presence of the new injection method
echo "Confirming the presence of the new injection method:"
rg --type less "\.inject-ScrollText-vars\(\)"

Length of output: 469

@@ -19,15 +19,15 @@
@storage-item-prefix-cls: ~'@{css-prefix}storage-item';

.@{tall-storage-prefix-cls} {
.component-css-vars-tall-storage();
.inject-TallStorage-vars();
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 variable injection methods found in tall-storage component.

Both .component-css-vars-tall-storage() and .inject-TallStorage-vars() are present in packages/theme/src/tall-storage/index.less. Please remove the old method to ensure consistency with the refactored variable injection approach.

🔗 Analysis chain

Approve the updated variable injection method.

The change from .component-css-vars-tall-storage() to .inject-TallStorage-vars() is consistent with the refactoring objectives. This new naming convention appears to be more specific and aligned with the component name, which should improve code clarity.

To ensure consistency across the codebase, please run the following script:

This will help identify any remaining instances of the old method or inconsistencies in the new naming convention.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of the new injection method across components

# Test: Search for both old and new injection method patterns
echo "Old injection method occurrences:"
rg --type less 'component-css-vars-\w+'

echo "New injection method occurrences:"
rg --type less 'inject-\w+-vars'

Length of output: 26484

Comment on lines +28 to +29
background-color: var(--tv-TallStorage-bg-color);
box-shadow: var(--tv-TallStorage-box-shadow);
Copy link

Choose a reason for hiding this comment

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

💡 Codebase verification

Old CSS shadow variables are still in use.

The old common shadow variable --ti-common-shadow-2-down is still used in the following files:

  • packages/theme/src/rich-text-editor/vars.less
  • packages/theme/src/card-template/index.less
  • packages/theme/src/base/old-basic-vars.less
  • packages/theme/src/base/basic-var.less

Please consider updating these usages to the new --tv-TallStorage-box-shadow variable or determine if maintaining the common shadow variable is necessary for consistent styling across components.

🔗 Analysis chain

Approve the updated CSS variable names with a suggestion.

The changes from --ti- to --tv- prefix and the more specific naming for the TallStorage component are improvements in consistency and clarity.

However, the change from --ti-common-shadow-2-down to --tv-TallStorage-box-shadow might impact other components. Please run the following script to check for any remaining usage of the old common shadow variable:

If there are occurrences in other components, consider whether a global shadow variable should be maintained or if component-specific shadows are preferred across the codebase.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for usage of the old common shadow variable

echo "Occurrences of the old common shadow variable:"
rg --type less '--ti-common-shadow-2-down'

Length of output: 1227


Script:

#!/bin/bash
# Description: Check for usage of the old common shadow variable across the entire codebase

echo "Occurrences of the old common shadow variable '--ti-common-shadow-2-down':"
rg --type less '--ti-common-shadow-2-down'

echo "Occurrences of the new TallStorage box shadow variable '--tv-TallStorage-box-shadow':"
rg --type less '--tv-TallStorage-box-shadow'

Length of output: 1297


Script:

#!/bin/bash
# Description: Check for usage of the old and new shadow variables across the entire codebase

echo "Occurrences of the old common shadow variable '--ti-common-shadow-2-down':"
rg --type less -e '--ti-common-shadow-2-down'

echo "Occurrences of the new TallStorage box shadow variable '--tv-TallStorage-box-shadow':"
rg --type less -e '--tv-TallStorage-box-shadow'

Length of output: 1096

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