-
Notifications
You must be signed in to change notification settings - Fork 276
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): [crop] refactor crop theme vars #2245
Conversation
WalkthroughThe pull request introduces changes to the styling of the crop component within the theme package. Key updates include renaming CSS variables to a new naming convention, altering the method for injecting CSS variables, and adjusting certain property values for consistency and clarity. The modifications aim to enhance the readability and maintainability of the CSS code while aligning with a restructured variable naming scheme. Changes
Possibly related PRs
Suggested labels
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? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this 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 (3)
packages/theme/src/crop/vars.less (3)
15-15
: Approved: Variable rename and value update. Minor comment improvement suggested.The variable rename from
--ti-crop-modal-bg-color
to--tv-Crop-modal-bg-color
aligns with the new naming convention. The value change tovar(--tv-color-bg-mask)
improves theme consistency.Consider updating the comment to reflect the new variable name:
- // 弹窗蒙层的背景色,实际为该值的0.5的透明度 + // Crop modal overlay background color, applied with 50% opacity
17-17
: Approved: Variable rename and value update. Minor comment improvement suggested.The variable rename from
--ti-crop-center-bg-color
to--tv-Crop-center-bg-color
aligns with the new naming convention. The value change tovar(--tv-color-bg-control)
improves theme consistency.Consider updating the comment to improve clarity and reflect the new variable name:
- // 设置裁剪框在图片正中心加号背景色 + // Background color for the center plus sign in the Crop component
19-19
: Approved: Variable rename and value update. Minor comment improvement suggested.The variable rename from
--ti-crop-face-bg-color
to--tv-Crop-face-bg-color
aligns with the new naming convention. The value change tovar(--tv-color-bg-secondary)
improves theme consistency.Consider updating the comment to improve clarity and reflect the new variable name:
- // 弹窗裁剪框的背景色,实际为该值的0.1透明度 + // Crop component face area background color, applied with 10% opacity
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (2)
- packages/theme/src/crop/index.less (6 hunks)
- packages/theme/src/crop/vars.less (1 hunks)
🧰 Additional context used
🔇 Additional comments (6)
packages/theme/src/crop/vars.less (1)
13-19
: Overall: Excellent refactoring of Crop component theme variables.The changes in this file consistently apply a new naming convention (
--tv-Crop-*
instead of--ti-crop-*
) and utilize more generic color variables. This refactoring improves the consistency and maintainability of the theme variables without introducing any functional changes.Key improvements:
- Consistent naming convention across all variables.
- Use of more generic color variables, enhancing theme flexibility.
- Improved clarity in variable purposes through updated comments.
These changes align well with the PR objectives of refactoring the crop theme variables. Great job on improving the code quality!
packages/theme/src/crop/index.less (5)
88-90
: LGTM: Standardized percentage valuesThe changes from
33.33333%
to33.3333%
standardize the decimal places used for percentage values. This improves code consistency and readability without affecting the visual output.
98-100
: LGTM: Consistent standardization of percentage valuesThese changes are consistent with the standardization applied to the
.cropper-dashed.dashed-h
class. They improve code consistency and readability.
116-116
: LGTM: Consistent application of new variable naming conventionThis change from
var(--ti-crop-center-bg-color)
tovar(--tv-Crop-center-bg-color)
is consistent with the new naming convention observed earlier. It maintains consistency across the component.
320-321
: LGTM: Removed unnecessary units for zero valuesExcellent change. Removing the
px
unit from zero values (top: 0;
andleft: 0;
) adheres to CSS best practices. This improves code cleanliness without affecting the styling.
67-67
: Verify consistency of the new variable naming conventionThe change from
var(--ti-crop-modal-bg-color)
tovar(--tv-Crop-modal-bg-color)
aligns with a new naming convention. This update looks good and improves consistency.To ensure this naming convention is applied consistently across the project, please run the following script:
#!/bin/bash # Description: Check for consistency in the new CSS variable naming convention # Test: Search for any remaining old-style crop variable names rg --type less "var\(--ti-crop-" packages/theme/src/ # Test: Verify the usage of the new naming convention rg --type less "var\(--tv-Crop-" packages/theme/src/
@@ -10,11 +10,11 @@ | |||
* | |||
*/ | |||
|
|||
.component-css-vars-crop() { | |||
.inject-Crop-vars() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codebase verification
Inconsistent function naming detected.
The function naming convention change from .component-css-vars-crop()
to .inject-Crop-vars()
is only partially applied. Remaining .component-css-vars-*()
functions are found in several files:
packages/theme/src/wizard/vars.less
packages/theme/src/upload/index.less
packages/theme/src/slider/index.less
packages/theme/src/button/index.less
- (and others as per the output)
🔗 Analysis chain
Function name change looks good, verify consistency.
The function name change from .component-css-vars-crop()
to .inject-Crop-vars()
follows a new naming convention. This change improves clarity and consistency.
To ensure this naming convention is applied consistently across the project, run the following script:
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Check for consistency in function naming across theme files
# Test: Search for similar function names in other theme files
rg --type less -g 'packages/theme/src/**/*.less' '\.inject-[A-Z][a-zA-Z]+-vars\(\)'
# Test: Check for any remaining old-style function names
rg --type less -g 'packages/theme/src/**/*.less' '\.component-css-vars-[a-z]+\(\)'
Length of output: 11296
@@ -18,7 +18,7 @@ | |||
|
|||
.@{crop-prefix-cls} { | |||
&__wrapper { | |||
.component-css-vars-crop(); | |||
.inject-Crop-vars(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codebase verification
.inject-Crop-vars()
method not found
The .inject-Crop-vars()
method referenced in packages/theme/src/crop/index.less
does not have an implementation in the codebase. Please ensure that this method is properly defined and injects all necessary CSS variables.
🔗 Analysis chain
Verify the implementation of .inject-Crop-vars()
The change from .component-css-vars-crop()
to .inject-Crop-vars()
appears to be part of a larger refactoring effort to standardize naming conventions. This change looks good, but it's important to ensure that the new method injects all necessary CSS variables correctly.
Please run the following script to verify the implementation of the new method:
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Check the implementation of .inject-Crop-vars() method
# Test: Search for the definition of .inject-Crop-vars()
rg --type less "\.inject-Crop-vars\s*\(\s*\)\s*\{" packages/theme/src/
Length of output: 373
PR
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Issue Number: N/A
What is the new behavior?
Does this PR introduce a breaking change?
Other information
Summary by CodeRabbit