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): [loading] refactor loading theme vars #2277

Merged
merged 1 commit into from
Oct 17, 2024

Conversation

zzcr
Copy link
Member

@zzcr zzcr commented Oct 16, 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 loading component styling with a new variable naming convention for improved clarity.
    • Enhanced loading spinner dimensions and colors for better consistency.
  • Bug Fixes

    • Removed deprecated icon font styles in favor of SVGs for the loading spinner.
  • Refactor

    • Standardized CSS variable declarations across the loading component for better maintainability.

Copy link

coderabbitai bot commented Oct 16, 2024

Walkthrough

The changes in this pull request involve a comprehensive update to the loading component's styling in the LESS files. Key modifications include a shift in variable naming conventions from --ti- to --tv-, along with updates to the method for applying CSS variables. The loading component's CSS variables, including dimensions, colors, and text properties, have been systematically renamed and restructured to ensure consistency. The removal of the .iconfont-loading class indicates a transition towards using SVGs instead of icon fonts.

Changes

File Change Summary
packages/theme/src/loading/index.less - Updated variable naming from --ti- to --tv- for loading-related classes and CSS variables.
- Changed method call from .component-css-vars-loading() to .inject-Loading-vars().
- Updated background color and dimensions for loading spinner sizes.
packages/theme/src/loading/vars.less - Refactored CSS variable declarations, changing prefixes from --ti- to --tv-.
- Updated method signature from .component-css-vars-loading() to .inject-Loading-vars().
- Modified values for various loading-related CSS variables.

Possibly related PRs

Suggested labels

refactoring

Poem

🐇 In the land of styles, so bright and new,
The loading spins with a vibrant hue.
From ti to tv, a change so grand,
With SVGs and colors, all carefully planned.
Hop along, dear friends, let’s celebrate,
A loading dance that’s truly first-rate! 🎉


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 16, 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 (5)
packages/theme/src/loading/vars.less (5)

13-13: Approve function name change with a minor suggestion.

The new function name .inject-Loading-vars() is more descriptive and aligns with its purpose. However, for consistency with typical CSS naming conventions, consider using kebab-case for the entire function name.

Consider renaming the function to .inject-loading-vars() for better alignment with CSS naming conventions.


15-15: Approve variable change with a suggestion for fallback.

The variable renaming and value update improve consistency with the new naming scheme and color management. However, consider adding a fallback color to maintain backwards compatibility.

Consider adding a fallback color:

-  --tv-Loading-icon-color: var(--tv-color-icon-active);
+  --tv-Loading-icon-color: var(--tv-color-icon-active, #191919);

17-17: Approve text color change with a suggestion for fallback.

The variable renaming and value update are consistent with the new naming scheme. However, consider adding a fallback color to maintain backwards compatibility.

Consider adding a fallback color:

-  --tv-Loading-text-color: var(--tv-color-text-secondary);
+  --tv-Loading-text-color: var(--tv-color-text-secondary, #4e5969);

19-19: Approve background color change with a suggestion for fallback.

The variable renaming and value update improve consistency with the new naming scheme and color management. However, consider adding a fallback color to maintain backwards compatibility.

Consider adding a fallback color:

-  --tv-Loading-mask-bg-color: var(--tv-color-bg);
+  --tv-Loading-mask-bg-color: var(--tv-color-bg, #fff);

Remaining --ti- Prefixed Variables Found

Several loading-related CSS variables with the --ti- prefix were found in the following files:

  • packages/theme/src/upload-list/vars.less
  • packages/theme/src/upload-list/index.less
  • packages/theme/src/tree/vars.less
  • packages/theme/src/tree/index.less
  • packages/theme/src/modal/vars.less
  • packages/theme/src/modal/index.less
  • packages/theme/src/float-button/vars.less
  • packages/theme/src/float-button/index.less
  • packages/theme/src/base/basic-var.less
  • packages/theme-mobile/src/pull-refresh/index.less
  • packages/theme-mobile/src/pull-refresh/vars.less
  • packages/theme-mobile/src/loading/vars.less
  • packages/theme-mobile/src/loading/index.less
  • packages/theme-mobile/src/button/vars.less
  • packages/theme-mobile/src/button/index.less

Please update these variables to use the --tv- prefix to maintain consistency and align with the new naming conventions.

🔗 Analysis chain

Line range hint 1-53: Overall assessment: Approve with recommendations

The refactoring of the loading component's CSS variables significantly improves consistency, maintainability, and alignment with the design system. The changes from --ti- to --tv- prefix and the use of semantic design system variables enhance the overall quality of the code.

Recommendations:

  1. Verify all new variable values to ensure they match the intended designs.
  2. Consider adding fallback values for color and size variables to maintain backwards compatibility.
  3. Ensure that these changes are reflected in the component's documentation.
  4. Update any related test files to account for these new variable names.

To ensure consistency across the entire codebase, please run the following script to check for any remaining --ti- prefixed variables related to loading:

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

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for any remaining --ti- prefixed loading variables
rg --type less "--ti-.*loading"

Length of output: 450


Script:

#!/bin/bash
# Search for any remaining --ti- prefixed loading variables in .less files
rg --type less -e '--ti-.*loading'

Length of output: 6601

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between d22c32d and 5181252.

📒 Files selected for processing (2)
  • packages/theme/src/loading/index.less (3 hunks)
  • packages/theme/src/loading/vars.less (1 hunks)
🧰 Additional context used
🔇 Additional comments (14)
packages/theme/src/loading/vars.less (4)

28-32: Approve fullscreen loading icon size changes with verification suggestion.

The variable renaming and value updates improve consistency with the new naming scheme and leverage the design system's size variables. This change enhances maintainability and provides flexibility for different icon sizes.

Please verify that the new design system variables provide the intended sizes for each variant (small, medium, large). Ensure that these changes don't unintentionally alter the appearance of the loading icons.

To verify, you can run the following script:

#!/bin/bash
# Search for the definitions of the used design system variables
rg --type less "tv-icon-size|tv-size-height-xs|tv-size-height-md"

Also applies to: 35-39


42-46: Approve default loading spinner height changes with verification suggestion.

The variable renaming and value updates improve consistency with the new naming scheme and leverage the design system's size variables. This change enhances maintainability and provides flexibility for different spinner sizes.

Please verify that the new design system variables provide the intended heights for each variant (small, medium, large) of the default loading spinner. Ensure that these changes don't unintentionally alter the appearance of the loading spinners.

To verify, you can run the following script:

#!/bin/bash
# Search for the definitions of the used design system variables
rg --type less "tv-icon-size|tv-size-height-xs|tv-size-height-md"

49-53: Approve default loading spinner width changes with verification suggestion.

The variable renaming and value updates improve consistency with the new naming scheme and leverage the design system's size variables. This change enhances maintainability and provides flexibility for different spinner sizes.

Please verify that the new design system variables provide the intended widths for each variant (small, medium, large) of the default loading spinner. Ensure that these changes don't unintentionally alter the appearance of the loading spinners.

To verify, you can run the following script:

#!/bin/bash
# Search for the definitions of the used design system variables
rg --type less "tv-icon-size|tv-size-height-xs|tv-size-height-md"

23-25: Approve margin changes with verification suggestion.

The variable renaming and value updates improve consistency with the new naming scheme and leverage the design system's spacing variables. The change from explicit pixel values to design system variables enhances maintainability.

Please verify that var(--tv-space-xl) provides the intended vertical margin. Also, confirm that setting the horizontal margin to 0 is intentional.

To verify, you can run the following script:

#!/bin/bash
# Search for the definition of --tv-space-xl
rg --type less "tv-space-xl"
packages/theme/src/loading/index.less (10)

19-19: Mixin variables injected correctly

The mixin .inject-Loading-vars() is correctly used to inject the new loading component variables.


24-24: Updated loading mask background color variable

The background-color property now correctly uses var(--tv-Loading-mask-bg-color).


40-41: Fullscreen small spinner dimensions updated

The height and width of the small fullscreen spinner are correctly updated to use var(--tv-Loading-fullscreen-small-height) and var(--tv-Loading-fullscreen-small-width).


47-48: Fullscreen medium spinner dimensions updated

The height and width of the medium fullscreen spinner are correctly updated to use var(--tv-Loading-fullscreen-medium-height) and var(--tv-Loading-fullscreen-medium-width).


54-55: Fullscreen large spinner dimensions updated

The height and width of the large fullscreen spinner are correctly updated to use var(--tv-Loading-fullscreen-large-height) and var(--tv-Loading-fullscreen-large-width).


70-72: Loading text styles updated

The color, margin, and font size of the loading text are correctly updated with the new variables:

  • color: var(--tv-Loading-text-color);
  • margin: var(--tv-Loading-text-margin-y) var(--tv-Loading-text-margin-x);
  • font-size: var(--tv-Loading-text-font-size);

78-79: Spinner small size dimensions updated

The height and width of the small spinner are correctly updated to use var(--tv-Loading-spinner-small-height) and var(--tv-Loading-spinner-small-width).


86-87: Spinner medium size dimensions updated

The height and width of the medium spinner are correctly updated to use var(--tv-Loading-spinner-medium-height) and var(--tv-Loading-spinner-medium-width).


94-95: Spinner large size dimensions updated

The height and width of the large spinner are correctly updated to use var(--tv-Loading-spinner-large-height) and var(--tv-Loading-spinner-large-width).


100-100: SVG icon fill color updated

The fill property for the SVG icon now correctly uses var(--tv-Loading-icon-color).

--ti-loading-text-font-size: var(--ti-common-font-size-2, 16px);
// 加载图标自定义加载图标顶部外边距
--ti-loading-spinner-margin-top: calc(var(--ti-common-space-0, 0px) - 21px);
--tv-Loading-text-font-size: var(--tv-font-size-lg);
Copy link

Choose a reason for hiding this comment

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

💡 Codebase verification

Variable --tv-font-size-lg is not defined. Please define it or revert to using the previous variable with a fallback value.

🔗 Analysis chain

Approve font size change with a verification suggestion.

The variable renaming and value update improve consistency with the new naming scheme and use a more semantic font size variable. This change enhances maintainability.

Please verify that --tv-font-size-lg corresponds to 14px or the intended size. If not, consider adding a fallback size:

-  --tv-Loading-text-font-size: var(--tv-font-size-lg);
+  --tv-Loading-text-font-size: var(--tv-font-size-lg, 14px);

To verify, you can run the following script:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for the definition of --tv-font-size-lg
rg --type less "tv-font-size-lg"

Length of output: 2558

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.

1 participant