-
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): [carousel] refactor carousel theme vars #2244
Conversation
WalkthroughThe changes in this pull request involve a systematic update of CSS variable naming conventions across carousel-related files. Specifically, the prefix for CSS variables has been changed from Changes
Possibly related PRs
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
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: 3
🧹 Outside diff range and nitpick comments (4)
packages/theme/src/carousel-item/vars.less (1)
13-18
: Approve changes with suggestions for documentationThe refactoring of the carousel item theme variables looks good. The new naming convention (
--tv-CarouselItem-*
) is more specific and consistent, which should improve maintainability and reduce the risk of naming conflicts.However, given the significant changes in variable names and the injection method, please consider the following suggestions:
- Update any relevant documentation to reflect these new variable names and the
.inject-CarouselItem-vars()
function.- If there are any migration guides or upgrade instructions for the project, make sure to include information about these theme variable changes.
- Consider adding a comment in the file explaining the
--tv-
prefix and referencing where the referenced variables (e.g.,--tv-size-height-lg
) are defined.Would you like me to draft a documentation update or migration guide snippet for these changes?
packages/theme/src/carousel/vars.less (3)
15-17
: Consider using relative units for arrow dimensions.The variable naming update from
--ti-
to--tv-
is consistent with the new convention. However, using fixed pixel values for dimensions might limit responsiveness.Consider using relative units (e.g., em, rem) for better scalability across different screen sizes:
- --tv-Carousel-arrow-height: 32px; - --tv-Carousel-arrow-width: 32px; + --tv-Carousel-arrow-height: 2rem; + --tv-Carousel-arrow-width: 2rem;
27-41
: Consider using relative units for indicator dimensions.The variable naming updates and the use of referenced variables for colors are good practices. However, using fixed pixel values for dimensions might limit responsiveness.
Consider using relative units (e.g., em, rem) for better scalability across different screen sizes:
- --tv-Carousel-indicators-border-radius: 13px; - --tv-Carousel-indicators-height: 8px; - --tv-Carousel-indicator-active-width: 12px; - --tv-Carousel-indicator-active-button-width: 12px; + --tv-Carousel-indicators-border-radius: 0.8125rem; + --tv-Carousel-indicators-height: 0.5rem; + --tv-Carousel-indicator-active-width: 0.75rem; + --tv-Carousel-indicator-active-button-width: 0.75rem;
45-47
: Consider using a theme variable for default indicator background color.The variable naming updates and the use of a referenced variable for the active background color are good practices. However, using a hard-coded color value for the default background might limit theme flexibility.
Consider using a theme variable for the default indicator background color:
- --tv-Carousel-outside-button-bg-color: #000; + --tv-Carousel-outside-button-bg-color: var(--tv-color-text-primary);This change assumes that
--tv-color-text-primary
is defined elsewhere in your theme and represents a dark color suitable for this purpose. Adjust the variable name as needed to fit your theme structure.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (4)
- packages/theme/src/carousel-item/index.less (3 hunks)
- packages/theme/src/carousel-item/vars.less (1 hunks)
- packages/theme/src/carousel/index.less (6 hunks)
- packages/theme/src/carousel/vars.less (1 hunks)
🧰 Additional context used
🔇 Additional comments (18)
packages/theme/src/carousel-item/index.less (6)
38-38
: LGTM! Consistent with new naming convention.The updated CSS variable
--tv-CarouselItem-title-height
follows the new naming convention and improves specificity. This change enhances code consistency and readability.
40-41
: LGTM! Consistent naming and smart use of variables.The updated CSS variables follow the new naming convention, improving consistency and readability. Nice touch using the same variable for both height and line-height, which ensures vertical centering of the text.
43-43
: LGTM! Consistent with new naming convention.The updated CSS variable
--tv-CarouselItem-title-bg-color
follows the new naming convention, improving specificity and consistency with other changes.
48-48
: LGTM! Consistent with new naming convention.The updated CSS variable
--tv-CarouselItem-title-span-font-size
follows the new naming convention, improving specificity and consistency with other changes.
89-89
: LGTM! Consistent with new naming convention. Verify all updates.The updated CSS variable
--tv-CarouselItem-mask-bg-color
follows the new naming convention, improving specificity and consistency with other changes.As this is the last variable change in this file, please run the following script to ensure all variables have been updated consistently:
#!/bin/bash # Description: Verify all CSS variables have been updated to the new naming convention # Test: Check for any remaining --ti- prefixed variables and list all --tv- prefixed variables echo "Checking for any remaining --ti- prefixed variables:" rg --type less "\-\-ti\-" packages/theme/src/carousel-item/ echo "Listing all --tv- prefixed variables:" rg --type less "\-\-tv\-" packages/theme/src/carousel-item/
19-19
: LGTM! Verify usage across the codebase.The updated method name
.inject-CarouselItem-vars()
is more descriptive and follows a clear naming pattern. This change improves code readability and maintainability.To ensure this change doesn't break anything, please verify its usage across the codebase:
packages/theme/src/carousel/vars.less (9)
19-19
: Approve arrow font size variable update.The variable naming update and the use of a referenced variable for font size are good practices. This change promotes consistency and easier maintenance of the theme.
21-21
: Approve arrow hover background color variable update.The variable naming update and the use of a referenced variable for the hover background color are good practices. This change enhances theme consistency and maintainability.
23-25
: Approve arrow background and SVG color variable updates.The variable naming updates and the use of referenced variables for colors are good practices. These changes promote theme consistency and easier maintenance.
49-49
: Approve label button font size variable addition.The addition of the
--tv-Carousel-labels-button-font-size
variable, referencing--tv-font-size-md
, is a good practice. This promotes consistency in font sizes across the theme and improves maintainability.
51-51
: Approve arrow hover text color variable addition.The addition of the
--tv-Carousel-arrow-hover-text-color
variable, referencing--tv-color-icon-hover
, is a good practice. This enhances theme consistency and improves maintainability of hover states.
53-55
: Approve left and right arrow background color variable additions.The addition of separate variables for left and right arrow background colors, both referencing
--tv-color-bg
, is a good practice. This allows for potential future customization while maintaining current consistency.
57-59
: Approve arrow disabled state variable additions.The addition of separate variables for arrow disabled background color and icon color, referencing
--tv-color-bg-disabled
and--tv-color-icon-disabled
respectively, is a good practice. This allows for consistent and customizable styling of disabled states across the theme.
13-60
: Overall assessment: Improved theme consistency and maintainability.The changes in this file significantly improve the consistency and maintainability of the carousel component's theming. The new naming convention with the
--tv-
prefix is consistently applied, and the use of referenced theme variables for colors and some dimensions is a good practice.Some suggestions for further improvement include:
- Consider using relative units (e.g., rem) for dimensions to improve responsiveness.
- Review the use of hard-coded color values and consider replacing them with theme variables where appropriate.
These changes align well with the PR objective of refactoring carousel theme variables. Great work on improving the overall structure and consistency of the theme!
13-13
: Approve function name change and verify usage.The new function name
.inject-Carousel-vars()
is more descriptive and aligns better with its purpose. This is a good improvement in code readability.Please ensure that all calls to this function have been updated across the codebase. Run the following script to verify:
✅ Verification successful
Function name change verified successfully.
The old function name
.component-css-vars-carousel()
is no longer present in the codebase. All usages have been updated to.inject-Carousel-vars()
as shown in:
packages/theme/src/carousel/vars.less
packages/theme/src/carousel/index.less
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Check for any remaining occurrences of the old function name and verify the new function name usage. echo "Checking for old function name usage:" rg --type less "\.component-css-vars-carousel\(\)" echo "Verifying new function name usage:" rg --type less "\.inject-Carousel-vars\(\)"Length of output: 392
packages/theme/src/carousel/index.less (3)
21-21
: Updated CSS variable injection method is correctly implementedThe change from
.component-css-vars-carousel()
to.inject-Carousel-vars();
is correctly applied.
41-42
: CSS variable updates are correctly appliedThe changes correctly update the CSS variables to the new
--tv-
prefix for arrow dimensions, background colors, and SVG fill colors. The use of variables enhances theme consistency and maintainability.Also applies to: 46-46, 69-70, 71-73, 78-79, 80-82, 86-88, 99-99, 102-102
126-128
: Indicator styles updated with new CSS variablesThe indicator styles are updated to use the new
--tv-
prefixed CSS variables, which enhances theme consistency and makes customization easier.Also applies to: 133-134, 142-142, 146-149, 153-153, 155-157, 162-164, 184-184, 193-193, 206-206
|
||
.@{svg-prefix-cls} { | ||
fill: var(--ti-carousel-indicator-active-text-color); | ||
fill: var(--tv-Carousel-indicator-active-text-color); |
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.
Inconsistent use of CSS variables for SVG fill color
The fill
property of .@{svg-prefix-cls}
is set to var(--tv-Carousel-indicator-active-text-color)
, an indicator variable. In other places (lines 72~, 81~), the fill color uses var(--tv-Carousel-arrow-svg-color)
. For consistency, consider using the arrow-specific variable here as well.
Consider updating the fill color:
- fill: var(--tv-Carousel-indicator-active-text-color);
+ fill: var(--tv-Carousel-arrow-svg-color);
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
fill: var(--tv-Carousel-indicator-active-text-color); | |
fill: var(--tv-Carousel-arrow-svg-color); |
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
opacity: var(--ti-carousel-opacity); | ||
opacity: 0.5; |
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.
🛠️ Refactor suggestion
Consider using a CSS variable for arrow opacity
The opacity
property is set to a fixed value 0.5
. To maintain consistency and allow for theme customization, consider using a CSS variable.
Suggestion:
- opacity: 0.5;
+ opacity: var(--tv-Carousel-arrow-opacity);
Define --tv-Carousel-arrow-opacity
in your vars.less
file to allow for theme customization.
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
opacity: 0.5; | |
opacity: var(--tv-Carousel-arrow-opacity); |
background-color: var(--ti-carousel-arrow-bg-color); | ||
color: var(--ti-carousel-indicator-active-text-color); | ||
background-color: var(--tv-Carousel-arrow-bg-color); | ||
color: var(--tv-Carousel-indicator-active-text-color); |
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.
Potential inconsistency in CSS variable usage for arrow text color
The color
property for .@{carousel-prefix-cls}__arrow
is set to var(--tv-Carousel-indicator-active-text-color)
, which is an indicator variable. It might be more appropriate to use an arrow-specific variable for consistency.
Consider updating the variable:
- color: var(--tv-Carousel-indicator-active-text-color);
+ color: var(--tv-Carousel-arrow-text-color);
Ensure that --tv-Carousel-arrow-text-color
is defined in your vars.less
file.
Committable suggestion was skipped due to low confidence.
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: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (1)
- examples/sites/demos/pc/app/carousel/card-show.spec.ts (1 hunks)
🧰 Additional context used
🔇 Additional comments (1)
examples/sites/demos/pc/app/carousel/card-show.spec.ts (1)
14-14
: LGTM: CSS color change approved.The change in the expected CSS fill color from 'rgb(194, 194, 194)' to 'rgb(144, 144, 144)' aligns with the theme refactoring mentioned in the PR objectives.
To ensure consistency across the project, please verify that this color change is applied correctly in different themes (if applicable). You can use the following script to check for any remaining instances of the old color:
✅ Verification successful
CSS color change verified across the project.
All instances of
'rgb(194, 194, 194)'
have been successfully updated to the new color, ensuring consistency with the theme refactoring.🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Search for any remaining instances of the old color value rg --type css --type vue 'rgb\(194,\s*194,\s*194\)' || echo "No instances of the old color found."Length of output: 164
Script:
#!/bin/bash # Search for any remaining instances of the old color value in CSS and Vue files rg --type css -g "*.vue" 'rgb\(194,\s*194,\s*194\)' || echo "No instances of the old color found."Length of output: 136
@@ -6,9 +6,10 @@ test('轮播卡片', async ({ page }) => { | |||
const preview = page.locator('#card-show') | |||
const btnRight = preview.getByRole('button').nth(1) | |||
await btnRight.click() | |||
await page.waitForTimeout(200) |
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.
🛠️ Refactor suggestion
Consider using a more robust waiting mechanism.
While adding a wait time can help with timing issues, using fixed timeouts (waitForTimeout
) in tests can lead to flaky tests if the timing is not consistent across different environments or load conditions.
Consider using a more robust waiting mechanism, such as waiting for a specific element to appear or for a particular state to be reached. For example:
await page.waitForSelector('selector-for-next-slide', { state: 'visible' });
This approach will make the test more reliable and less dependent on specific timing.
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
New Features
Bug Fixes
Refactor