-
Notifications
You must be signed in to change notification settings - Fork 273
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(cascader): [cascader] refactor cascader's css vars #2318
Conversation
WalkthroughThe changes in this pull request involve a comprehensive update to the Cascader component and its related components, focusing on the renaming of CSS variables from the Changes
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
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: 5
🧹 Outside diff range and nitpick comments (11)
packages/theme/src/cascader-menu/vars.less (6)
15-15
: Approve variable renaming with a suggestion for consistencyThe renaming of
--ti-cascader-menu-text-color
to--tv-CascaderMenu-text-color
aligns well with the new naming convention. The use ofvar(--tv-color-text, #191919)
with a fallback color is a good practice for browser compatibility.For consistency, consider updating the comment to reflect the new variable name:
- // 下拉菜单文本色 + // CascaderMenu text color --tv-CascaderMenu-text-color: var(--tv-color-text, #191919);This change would make the comment more aligned with the English variable naming convention.
17-17
: Approve variable renaming with a suggestion for improvementThe renaming of
--ti-cascader-menu-border-color
to--tv-CascaderMenu-border-color
is correct and follows the new naming convention. However, there's room for improvement:
- The hardcoded color value
#f5f5f5
might limit theme customization.- The comment "无对应变量" (no corresponding variable) suggests this color isn't linked to a global theme variable.
Consider creating a global theme variable for this color and using it here. For example:
--tv-CascaderMenu-border-color: var(--tv-color-border-light, #f5f5f5);This change would improve consistency with other theme variables and make future theme customization easier.
19-19
: Approve variable renaming with a suggestion for consistencyThe renaming of
--ti-cascader-menu-empty-text-color
to--tv-CascaderMenu-empty-text-color
is correct and aligns with the new naming convention. The use ofvar(--tv-color-text-weaken, #808080)
with a fallback color is a good practice.For consistency with the English variable naming, consider updating the comment:
- // 下拉菜单为空时的文本色 + // CascaderMenu empty state text color --tv-CascaderMenu-empty-text-color: var(--tv-color-text-weaken, #808080);This change would make the comment more aligned with the English variable naming convention.
21-21
: Approve variable renaming with a suggestion for consistencyThe renaming of
--ti-cascader-menu-list-padding-vertical
to--tv-CascaderMenu-list-padding-y
is appropriate. It follows the new naming convention and uses the shorter 'y' suffix, which is a common practice for vertical padding. The use ofvar(--tv-space-md, 8px)
with a fallback value is good for maintaining consistent spacing across the framework.For consistency with the English variable naming, consider updating the comment:
- // 下拉菜单列表垂直方向的内边距 + // CascaderMenu list vertical padding --tv-CascaderMenu-list-padding-y: var(--tv-space-md, 8px);This change would align the comment with the English variable naming convention.
23-23
: Approve variable renaming with suggestions for improvementThe renaming of
--ti-cascader-menu-list-padding-horizontal
to--tv-CascaderMenu-list-padding-x
is appropriate. It follows the new naming convention and uses the shorter 'x' suffix, which is a common practice for horizontal padding.Consider the following improvements:
- For consistency with other variables, use a global spacing variable with 0 as a fallback:
--tv-CascaderMenu-list-padding-x: var(--tv-space-none, 0);
- Update the comment to align with the English variable naming convention:
- // 下拉菜单列表水平方向的内边距 + // CascaderMenu list horizontal padding --tv-CascaderMenu-list-padding-x: var(--tv-space-none, 0);These changes would improve consistency with other variables and make the code more maintainable.
25-25
: Approve variable renaming with a suggestion for improvementThe renaming of
--ti-cascader-menu-width
to--tv-CascaderMenu-width
correctly follows the new naming convention.However, the hardcoded width of 159px might limit flexibility in responsive designs or different use cases.
Consider the following improvements:
- Use a more flexible approach for setting the width. For example:
--tv-CascaderMenu-width: var(--tv-CascaderMenu-custom-width, 159px);This allows for easy customization while maintaining the default value.
- Update the comment to align with the English variable naming convention:
- // 下拉菜单的宽度 + // CascaderMenu width --tv-CascaderMenu-width: var(--tv-CascaderMenu-custom-width, 159px);These changes would improve the component's flexibility and maintain consistency with the naming conventions.
packages/theme/src/cascader-panel/vars.less (3)
15-15
: LGTM: Updated variable name and reference.The change from
--ti-cascader-panel-border-radius
to--tv-CascaderPanel-border-radius
aligns with the new naming convention. The updated reference tovar(--tv-border-radius-md, 6px)
uses a more generic variable name, which is good for consistency across components.Consider adding a comment explaining the significance of the
md
size for border radius, if it's not already documented elsewhere in the codebase.
19-19
: LGTM: Updated font size variable and reference.The change from
--ti-cascader-panel-font-size
to--tv-CascaderPanel-font-size
aligns with the new naming convention. The updated reference tovar(--tv-font-size-md, 14px)
uses a more generic variable name, which is good for consistency across components.Consider adding a comment explaining the significance of the
md
size for font size, if it's not already documented elsewhere in the codebase.
13-31
: Overall assessment: Consistent refactoring with some areas needing verification.The refactoring of the CascaderPanel CSS variables is consistent with the new naming convention and design system. The changes improve clarity and maintain a more standardized approach to theming.
Key points to address:
- Verify the impact of removing the top margin for nodes (line 23).
- Check the effect of changing vertical padding to 0 for node labels (line 25).
- Consider using a common height variable instead of a hardcoded value for node height (line 21).
These changes may affect the component's layout and appearance. It's recommended to thoroughly test the CascaderPanel component with these new styles to ensure it still meets the design requirements.
To maintain consistency across the entire design system, consider creating a document or guide that explains the naming conventions, common variables (like spacing and sizing), and their intended usage. This will help ensure that future changes and additions to the theme follow the same patterns established in this refactoring.
packages/theme/src/cascader/vars.less (2)
15-25
: Consider using a design token for input icon font sizeThe changes look good overall, with consistent updates to variable names and values. However, the input icon font size is set to a fixed value of 10px without referencing a design token.
--tv-Cascader-input-icon-font-size: 10px; // 无对应变量Consider using a design token for this value to maintain consistency with the rest of the system. For example:
--tv-Cascader-input-icon-font-size: var(--tv-font-size-xs, 10px);This would allow for easier theming and maintenance in the future.
39-49
: Use a design token for item hover background colorThe color-related variables have been updated consistently to use the new
--tv-
prefix and reference appropriate design tokens. However, the item hover background color is set to a fixed value:--tv-Cascader-item-hover-bg-color: #f5f7fa; // 无对应Consider using a design token for this value to maintain consistency with the rest of the system. For example:
--tv-Cascader-item-hover-bg-color: var(--tv-color-bg-hover, #f5f7fa);This would allow for easier theming and maintenance in the future.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (8)
- packages/theme/src/cascader-menu/index.less (4 hunks)
- packages/theme/src/cascader-menu/vars.less (1 hunks)
- packages/theme/src/cascader-node/index.less (4 hunks)
- packages/theme/src/cascader-node/vars.less (1 hunks)
- packages/theme/src/cascader-panel/index.less (1 hunks)
- packages/theme/src/cascader-panel/vars.less (1 hunks)
- packages/theme/src/cascader/index.less (7 hunks)
- packages/theme/src/cascader/vars.less (1 hunks)
🧰 Additional context used
🔇 Additional comments (54)
packages/theme/src/cascader-menu/vars.less (1)
13-13
: Approve function name change: Improved clarity and consistencyThe function name change from
.component-css-vars-cascader-menu()
to.inject-CascaderMenu-vars()
is a positive improvement. It enhances code readability by clearly indicating the function's purpose (injecting variables) and the specific component it relates to (CascaderMenu). This change aligns with the overall refactoring effort and contributes to a more consistent and maintainable codebase.packages/theme/src/cascader-panel/vars.less (5)
13-13
: LGTM: Improved function naming convention.The change from
.component-css-vars-cascader-panel()
to.inject-CascaderPanel-vars()
improves clarity and consistency in the naming convention. It accurately reflects the function's purpose of injecting variables for the CascaderPanel component.
17-17
: LGTM: Consistent variable naming and reference update.The change from
--ti-cascader-panel-border-color
to--tv-CascaderPanel-border-color
maintains consistency with the new naming convention. The updated reference tovar(--tv-color-border-disabled, #dbdbdb)
uses a more generic variable name, which is good for maintaining a consistent color scheme across components.
31-31
: LGTM: Updated variable name and optimized value.The change from
--ti-cascader-panel-node-border-radius
to--tv-CascaderPanel-node-border-radius
aligns with the new naming convention. The value change from0px
to0
is a minor optimization, as0
doesn't require a unit in CSS.
25-29
: LGTM: Updated padding variables, but verify layout impact.The changes to the padding variables align with the new naming convention and use of generic reference variables:
- Vertical padding: Changed from
--ti-cascader-panel-node-label-padding-vertical
to--tv-CascaderPanel-node-label-padding-x
with a value of0
.- Right padding: Updated to use
var(----tv-space-xl, 16px)
.- Left padding: Updated to use
var(----tv-space-xl, 16px)
.These changes improve consistency with the new design system.
However, the change in vertical padding to
0
and the use of a new spacing variable could affect the layout. Please verify that these changes don't negatively impact the component's appearance.To check the impact of these changes, you can run the following command:
#!/bin/bash # Search for references to the cascader panel node label padding in Less and Vue files rg --type less --type vue '(cascader-panel|CascaderPanel).*node.*label.*padding'Review the results to ensure that the new padding values maintain the desired layout and spacing within the component.
23-23
: Variable name updated, but verify the intentional removal of top margin.The change from
--ti-cascader-panel-node-margin-top
to--tv-CascaderPanel-node-margin-top
aligns with the new naming convention, which is good.However, the value has been changed from
4px
to0
. This removes the top margin for nodes, which could affect the layout and spacing of the cascader panel. Please verify if this change is intentional and doesn't negatively impact the component's appearance.To check the impact of this change, you can run the following command to find any related styles or components that might be affected:
Review the results to ensure that removing the top margin doesn't cause any unintended layout issues.
packages/theme/src/cascader-panel/index.less (8)
23-23
: Approve border-radius variable update.The change from
--ti-
to--tv-
prefix for the border-radius variable aligns with the new theming structure and improves component-specific styling.
24-24
: Approve font-size variable update.The change from
--ti-
to--tv-
prefix for the font-size variable is consistent with the new theming structure and improves component-specific styling.
26-27
: Approve border-color and border-radius variable updates.The changes from
--ti-
to--tv-
prefix for the border-color and border-radius variables are consistent with the new theming structure and improve component-specific styling.
34-37
: Approve cascader node styling updates with improved granularity.The changes from
--ti-
to--tv-
prefix for padding, height, and line-height variables are consistent with the new theming structure. The padding variables now offer more granular control (x, right, left), which enhances styling flexibility for the cascader node.
39-39
: Approve cascader node border-radius variable update.The change from
--ti-
to--tv-
prefix for the border-radius variable is consistent with the new theming structure and improves component-specific styling for the cascader node.
40-40
: Approve cascader node margin-top variable update.The change from
--ti-
to--tv-
prefix for the margin-top variable is consistent with the new theming structure and improves component-specific styling for the cascader node.
20-40
: Summary: Successful refactoring of Cascader Panel CSS variablesThe changes in this file successfully refactor the CSS variables for the Cascader Panel component, aligning with the PR objectives. Key points:
- Consistent renaming of CSS variables from
--ti-
to--tv-
prefix.- Updated mixin injection method for better maintainability.
- Improved granularity in padding variables for the cascader node.
These changes enhance the component-specific styling and maintain consistency with the new theming structure. The refactoring does not introduce functional or API changes, as expected.
20-20
: Approve mixin update and verify its impact.The change from
.component-css-vars-cascader-panel()
to.inject-CascaderPanel-vars()
improves naming consistency and clarity. This aligns well with modern CSS practices and component-specific styling.To ensure this change doesn't break existing styles, please run the following script to check for any remaining usage of the old mixin name:
packages/theme/src/cascader-menu/index.less (7)
20-20
: Approved: Consistent method renaming for CSS variable injectionThe change from
.component-css-vars-cascader-menu()
to.inject-CascaderMenu-vars()
aligns with the PR's refactoring objectives. This new naming convention is more descriptive and follows a clear pattern, improving code readability and maintainability.
22-24
: Approved: Consistent CSS variable renamingThe changes from
--ti-cascader-menu-width
to--tv-CascaderMenu-width
and--ti-cascader-menu-text-color
to--tv-CascaderMenu-text-color
are consistent with the PR's objective of refactoring CSS variables. The new naming convention (changing prefix from--ti-
to--tv-
and capitalizing the component name) improves consistency across the codebase.
25-25
: Approved: Consistent CSS variable renaming for border colorThe change from
--ti-cascader-menu-border-color
to--tv-CascaderMenu-border-color
follows the same pattern as previous renamings, maintaining consistency in the refactoring effort.
42-42
: Approved: Consistent CSS variable renaming for list marginsThe changes to the list margin variables (
--tv-CascaderMenu-list-margin-vertical
and--tv-CascaderMenu-list-margin-horizontal
) are consistent with the overall refactoring pattern, maintaining the semantic meaning while updating the prefix and component name capitalization.
45-45
: Approved: Consistent and improved CSS variable renaming for list paddingThe changes to the list padding variables follow the established refactoring pattern and introduce an improvement in naming conciseness:
--ti-cascader-menu-list-padding-vertical
→--tv-CascaderMenu-list-padding-y
--ti-cascader-menu-list-padding-horizontal
→--tv-CascaderMenu-list-padding-x
The use of 'y' and 'x' instead of 'vertical' and 'horizontal' makes the variable names more concise while maintaining clarity. This is a good optimization in the refactoring process.
63-63
: Approved: Consistent CSS variable renaming for empty text and no data colorThe change from
--ti-cascader-menu-empty-text-color
to--tv-CascaderMenu-empty-text-color
on lines 63 and 72 is consistent with the overall refactoring pattern. It's good to see that the same variable is used for both empty text and no data scenarios, maintaining consistency in the component's styling.Also applies to: 72-72
Line range hint
1-72
: Summary: Successful refactoring of CSS variables in cascader-menu componentThe changes in this file consistently implement the new CSS variable naming convention, transitioning from the
--ti-
prefix to--tv-
and capitalizing the component name in variable names. This refactoring improves code consistency and readability across the project. The changes maintain the semantic meaning of all variables while introducing some improvements in conciseness (e.g., using 'y' and 'x' for padding directions).All modifications align with the PR objectives and contribute to a more standardized approach to theming in the Tiny Vue framework. Great job on maintaining consistency throughout the file!
packages/theme/src/cascader-node/vars.less (13)
19-19
: LGTM! Consistent with previous changes.The variable renaming is consistent with the new naming convention and aligns with the previous hover text color change. The fallback color remains unchanged, preserving the original design.
23-23
: LGTM! Consistent with previous changes.The variable renaming is consistent with the new naming convention and aligns with the previous text color changes. The fallback color remains unchanged, preserving the original design.
31-31
: LGTM! Verify the new variable reference.The variable renaming is consistent with the new naming convention. The fallback color remains unchanged, preserving the original design. However, please ensure that
--tv-color-icon
is properly defined in the new theming system and provides the expected value.To verify the new variable reference, run the following script:
#!/bin/bash # Search for the definition of --tv-color-icon rg --type less "--tv-color-icon"
33-33
: LGTM! Verify the new variable reference.The variable renaming is consistent with the new naming convention. The fallback color remains unchanged, preserving the original design. However, please ensure that
--tv-color-icon-disabled
is properly defined in the new theming system and provides the expected value.To verify the new variable reference, run the following script:
#!/bin/bash # Search for the definition of --tv-color-icon-disabled rg --type less "--tv-color-icon-disabled"
35-35
: LGTM with a minor concern. Verify the new variable reference and naming.The variable renaming is consistent with the new naming convention, and the fallback color remains unchanged. However, there are two points to consider:
- Please ensure that
--tv-color-icon-hover
is properly defined in the new theming system and provides the expected value.- The new variable reference (
--tv-color-icon-hover
) suggests a hover state, while the variable name includes "active". Verify if this is intentional or if it should be--tv-color-icon-active
instead.To verify the new variable reference and check for potential naming inconsistencies, run the following script:
#!/bin/bash # Search for the definition of --tv-color-icon-hover and check for similar variables rg --type less "--tv-color-icon-(hover|active)"
37-51
: LGTM! Verify new variable references and consider the fixed max-width value.The variable renamings are consistent with the new naming convention and follow the pattern of previous changes. However, please consider the following points:
- Ensure that all new variable references (e.g.,
--tv-space-sm
,--tv-space-xl
,--tv-font-weight-regular
) are properly defined in the new theming system.- The
--tv-CascaderNode-label-max-width
has changed from a calculation to a fixed value of 107px. Verify if this change is intentional and whether it might affect the component's responsiveness across different screen sizes.To verify the new variable references and the fixed max-width value, run the following script:
#!/bin/bash # Search for the definitions of new variable references rg --type less "--tv-(space-sm|space-xl|font-weight-regular)" # Search for usages of the label max-width variable rg --type less "--t[iv]-cascader-node-label-max-width"
13-13
: LGTM! Verify function usage across the codebase.The function name change to
inject-CascaderNode-vars()
improves consistency with modern naming conventions. However, ensure that all calls to this function have been updated accordingly throughout the codebase.To verify the function usage, run the following script:
✅ Verification successful
Function usage successfully updated.
All instances ofinject-cascader-node-vars
have been updated toinject-CascaderNode-vars
across the codebase. No outdated references were found.🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Search for both old and new function names to ensure all occurrences have been updated rg --type less "inject-(cascader-node|CascaderNode)-vars"Length of output: 207
29-29
: LGTM! Verify the new variable reference.The variable renaming is consistent with the new naming convention. The fallback size remains unchanged, preserving the original design. However, please ensure that
--tv-font-size-sm
is properly defined in the new theming system and provides the expected value.To verify the new variable reference, run the following script:
✅ Verification successful
Verified!
The
--tv-font-size-sm
variable is properly defined inpackages/theme/src/base/vars.less
with a fallback value of12px
. All references to--tv-font-size-sm
across the codebase are consistent and adhere to the new theming system.🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Search for the definition of --tv-font-size-sm rg --type less "--tv-font-size-sm"Length of output: 1007
Script:
#!/bin/bash # Search for the definition of --tv-font-size-sm using the correct rg syntax rg --type less -e '--tv-font-size-sm'Length of output: 3746
21-21
: LGTM! Verify the new variable reference.The variable renaming is consistent with the new naming convention. The fallback color remains unchanged, preserving the original design. However, please ensure that
--tv-color-bg
is properly defined in the new theming system and provides the expected value.To verify the new variable reference, run the following script:
✅ Verification successful
Verified the new variable reference.
The
--tv-color-bg
is properly defined inpackages/theme/src/base/vars.less
with the expected valuevar(--tv-base-color-common-3)
. This ensures that the theming system correctly references the background color, maintaining the original design consistency.🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Search for the definition of --tv-color-bg rg --type less "--tv-color-bg"Length of output: 1007
Script:
#!/bin/bash # Search for the definition of --tv-color-bg using the -e flag to specify the pattern correctly rg --type less -e '--tv-color-bg\s*:'Length of output: 191
25-25
: LGTM! Verify the new variable reference.The variable renaming is consistent with the new naming convention. The fallback color remains unchanged, preserving the original design. However, please ensure that
--tv-color-text-disabled
is properly defined in the new theming system and provides the expected value.To verify the new variable reference, run the following script:
✅ Verification successful
Please run the following script to verify the definition of
--tv-color-text-disabled
:
Verified:
--tv-color-text-disabled
is properly defined.The new variable
--tv-color-text-disabled
is correctly defined in the theming system, ensuring that the disabled text color behaves as expected across all relevant components.🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Search for the definition of --tv-color-text-disabled rg --type less "--tv-color-text-disabled"Length of output: 1007
Script:
# #!/bin/bash # Search for the definition of --tv-color-text-disabled with exact match rg --type less -- "--tv-color-text-disabled"Length of output: 5257
15-15
: LGTM! Verify the new variable reference.The variable renaming is consistent with the new naming convention. The fallback color remains unchanged, preserving the original design. However, please ensure that
--tv-color-bg-secondary
is properly defined in the new theming system and provides the expected value.To verify the new variable reference, run the following script:
✅ Verification successful
Verification Successful!
The variable
--tv-color-bg-secondary
is properly defined inpackages/theme/src/base/vars.less
and is used consistently across the codebase. No issues found.🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Search for the definition of --tv-color-bg-secondary rg --type less "--tv-color-bg-secondary"Length of output: 1007
Script:
#!/bin/bash # Correctly search for the definition of --tv-color-bg-secondary in LESS files rg --type less -e '--tv-color-bg-secondary'Length of output: 6348
Script:
#!/bin/bash # Search for any similar variable names that might exist rg --type less -e '--tv-color-bg-secondary' -e '--tv-color-bg-secondary'Length of output: 6375
27-27
: LGTM! Verify the new variable reference.The variable renaming is consistent with the new naming convention. The fallback color remains unchanged, preserving the original design. However, please ensure that
--tv-color-bg-disabled
is properly defined in the new theming system and provides the expected value.To verify the new variable reference, run the following script:
17-17
: LGTM! Verify the new variable reference.The variable renaming is consistent with the new naming convention. The fallback color remains unchanged, preserving the original design. However, please ensure that
--tv-color-text
is properly defined in the new theming system and provides the expected value.To verify the new variable reference, run the following script:
✅ Verification successful
Verified! The
--tv-color-text
variable is properly defined and utilized across the codebase. No issues found with its implementation.🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Search for the definition of --tv-color-text rg --type less "--tv-color-text"Length of output: 1007
Script:
#!/bin/bash # Search for the definition of --tv-color-text in LESS files rg --type less -e "--tv-color-text"Length of output: 25690
packages/theme/src/cascader-node/index.less (9)
65-66
: Approve the updated CSS variable names for icon styles.The changes consistently update the prefix from
--ti-
to--tv-
for icon font size and colors, maintaining clarity and specificity in the variable names.Also applies to: 72-72
75-75
: Approve the updated CSS variable name for active state font weight.The change updates the prefix from
--ti-
to--tv-
for the active state font weight, maintaining clarity and specificity in the variable name.
84-84
: Approve the updated CSS variable names for prefix and postfix styles.The changes consistently update the prefix from
--ti-
to--tv-
for prefix display and postfix right position, maintaining clarity and specificity in the variable names.Also applies to: 90-90
95-95
: Approve the updated CSS variable names for label styles.The changes consistently update the prefix from
--ti-
to--tv-
for label max-width and padding, maintaining clarity and specificity in the variable names.Also applies to: 98-98
24-24
: Approve the updated CSS variable names for color properties.The changes consistently update the prefix from
--ti-
to--tv-
for text and background colors across various states (selectable, active, hover). The new variable names are more specific and descriptive.To ensure consistency across the entire codebase, please run the following command to check for any remaining
--ti-
prefixes in LESS files:#!/bin/bash # Search for any remaining --ti- prefixes in LESS files rg --type less "--ti-" packages/Also applies to: 29-30, 32-32
Line range hint
1-119
: Summary: Consistent update of CSS variable prefixesThe changes in this file consistently update CSS variable names from the
--ti-
prefix to the--tv-
prefix. This refactoring maintains existing functionality while aligning with a new naming convention, likely part of a larger standardization effort across the project.To ensure the consistency of this change across the entire project, please run the following commands:
#!/bin/bash # Count remaining --ti- prefixes in LESS files echo "Remaining --ti- prefixes:" rg --type less "--ti-" packages/ | wc -l # Count new --tv- prefixes in LESS files echo "New --tv- prefixes:" rg --type less "--tv-" packages/ | wc -l # List any files that still contain both prefixes echo "Files with mixed prefixes:" rg --type less --files-with-matches "(--(ti|tv)-)" packages/ | xargs -I {} sh -c 'grep -q -- "--ti-" {} && grep -q -- "--tv-" {} && echo {}'This will help identify any inconsistencies or missed updates across the project.
110-110
: Approve the updated CSS variable names for radio and checkbox styles.The changes consistently update the prefix from
--ti-
to--tv-
for radio and checkbox margin-right, maintaining clarity and specificity in the variable names.To ensure consistency across other components using radio and checkbox styles, please run the following command:
#!/bin/bash # Search for radio and checkbox margin-right variables in other components rg --type less "(radio|checkbox).*margin-right" packages/theme/src/Also applies to: 117-117
37-37
: Approve the updated CSS variable names for hover and disabled states.The changes consistently update the prefix from
--ti-
to--tv-
for hover and disabled states, maintaining clarity and specificity in the variable names.To ensure all variables have been updated, please run the following command to check for any remaining
--ti-
prefixes specifically in the cascader-node LESS file:Also applies to: 43-44, 53-55, 59-59
21-21
: Approve the updated CSS variable injection method.The change from
.component-css-vars-cascader-node()
to.inject-CascaderNode-vars()
aligns with a more component-specific naming convention. This is likely part of a broader refactoring effort.Please ensure that the
inject-CascaderNode-vars()
method is properly implemented and includes all necessary variables. You can verify this by running:✅ Verification successful
CSS Variable Injection Method Verified Successfully
The
inject-CascaderNode-vars()
method is correctly implemented inpackages/theme/src/cascader-node/vars.less
and includes all necessary variables following the updated--tv-
naming convention.🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Search for the implementation of inject-CascaderNode-vars rg --type less "inject-CascaderNode-vars\s*\(\s*\)\s*\{" -A 20Length of output: 534
Script:
#!/bin/bash # Search for the implementation of inject-CascaderNode-vars rg --type less 'inject-CascaderNode-vars\s*\(\s*\)\s*\{' -A 20Length of output: 1925
packages/theme/src/cascader/vars.less (3)
27-37
: Verify font size consistency across different sizesThe variables for different sizes have been updated consistently. However, I noticed that the font size for all sizes (medium, small, and mini) is set to the same value:
--tv-Cascader-medium-font-size: var(--tv-font-size-md, 14px); --tv-Cascader-small-font-size: var(--tv-font-size-md, 14px); --tv-Cascader-mini-font-size: var(--tv-font-size-md, 14px);Is it intentional to have the same font size for all sizes? Typically, smaller sizes might use a smaller font size. Consider reviewing this to ensure it aligns with the design system.
13-115
: Summary of Cascader CSS variables refactoringOverall, the refactoring of Cascader CSS variables from
--ti-
to--tv-
prefix has been done consistently. The use of design tokens for most values is a positive change that will improve maintainability and theming capabilities. However, there are several areas that require attention:
- Some variables are still using fixed values instead of design tokens (e.g., input icon font size, item hover background color).
- Multiple variables are marked as "没有生效" (not effective), indicating they might not be used in the component implementation.
- There's a potential inconsistency in font sizes across different component sizes (medium, small, mini).
- The width variable is incorrectly set to a string value ('100%') instead of a proper CSS value.
Next steps:
- Review all variables marked as ineffective and either implement them in the component or remove them from this file.
- Replace remaining fixed values with appropriate design tokens where possible.
- Verify the font size consistency across different component sizes and adjust if necessary.
- Correct the width variable value from '100%' to 100%.
- After making these changes, thoroughly test the Cascader component to ensure all styles are applied correctly and there are no visual regressions.
These improvements will further enhance the consistency and maintainability of the Cascader component styles.
83-97
:⚠️ Potential issueReview and implement list-related variables
All of the list-related variables in this section are marked as "没有生效" (not effective):
--tv-Cascader-list-margin-left: 0; --tv-Cascader-list-margin-right: 0; --tv-Cascader-list-margin-top: 0; --tv-Cascader-list-margin-bottom: 0; --tv-Cascader-list-padding-left: 0; --tv-Cascader-list-padding-right: 0; --tv-Cascader-list-padding-top: 6px; --tv-Cascader-list-padding-bottom: 6px;This suggests that these styles are not being applied to the component. Please take the following actions:
- Review the Cascader component implementation to understand why these variables are not being used.
- If these styles are needed, implement them in the component using these variables.
- If these styles are not needed, consider removing these variables to keep the codebase clean.
- For non-zero values (like padding-top and padding-bottom), consider using design tokens instead of fixed pixel values if you decide to keep and implement these variables.
A comprehensive review of the list-related styles in the Cascader component may be necessary to ensure consistency and proper styling.
packages/theme/src/cascader/index.less (8)
31-31
: LGTM! Consistent variable renaming.The CSS variable renaming is consistent across these lines, following the pattern of changing
--ti-
to--tv-
and using PascalCase for the component name.Also applies to: 42-42, 47-47, 51-51, 56-56
64-64
: LGTM! Improved naming for size-specific variables.The CSS variable renaming is consistent and follows the established pattern. The size-specific variables (medium, small, mini) now include the size in the variable name, which improves clarity and maintainability.
Also applies to: 68-68, 73-74, 78-79, 83-84
90-90
: LGTM! Verify dropdown appearance after changes.The changes are consistent with the refactoring goals. The addition of
.inject-Cascader-vars()
and the more specific variable names for dropdown styles should improve theming capabilities.Please verify that the dropdown appearance hasn't been unintentionally altered by these changes. You may want to visually inspect the component in different states and sizes.
Also applies to: 99-106, 108-109
149-152
: LGTM! Verify tag appearance after changes.The CSS variable renaming for tags is consistent and follows the established pattern. The new variable names are more specific, which should improve theming flexibility.
Please verify that the tag appearance, including margins and colors, hasn't been unintentionally altered by these changes. You may want to visually inspect the component with multiple tags in different states.
Also applies to: 154-154, 179-180, 183-183
242-242
: LGTM! Verify suggestion panel appearance.The CSS variable renaming is consistent and follows the established pattern. The new variable names for the suggestion list are more granular, which should allow for more precise theming control.
Please verify that the suggestion panel appearance, including margins, paddings, and colors, hasn't been unintentionally altered by these changes. You may want to visually inspect the component with various suggestion items.
Also applies to: 244-244, 250-259
267-267
: LGTM! Verify suggestion item states.The CSS variable renaming for suggestion items is consistent and follows the established pattern. The new variable names provide more specific control over different states of suggestion items (normal, hover, checked).
Please verify that the appearance of suggestion items in various states (normal, hover, checked) hasn't been unintentionally altered by these changes. You may want to interact with the component to ensure all states are visually correct.
Also applies to: 269-270, 277-277, 281-281, 285-285
295-299
: LGTM! Verify overall component appearance.The CSS variable renaming is consistent across all aspects of the component, including empty text, search input, placeholder, and multiple selection styles. The new variable names provide more granular control for theming.
As a final step, please verify the overall appearance of the Cascader component in various states and configurations (empty, with search input, multiple selection) to ensure no unintended visual changes have been introduced by this refactoring.
Also applies to: 306-309, 317-317, 322-322
Line range hint
1-322
: LGTM! Comprehensive CSS variable refactoring completed.The refactoring of CSS variables in the Cascader component has been consistently applied throughout the file. The changes from
--ti-
to--tv-
prefix and the introduction of more specific and granular variable names should improve theming capabilities and maintainability.Key points:
- Variable naming is consistent and follows the new convention.
- The
.inject-Cascader-vars()
method has replaced.component-css-vars-cascader()
.- No logical changes to the styles themselves were observed, only variable renaming.
To ensure the refactoring hasn't introduced any unintended visual changes:
- Conduct a comprehensive visual test of the Cascader component in all its states and configurations.
- Verify that the theming system still works as expected with the new variable names.
- Check that the
.inject-Cascader-vars()
method is correctly implemented and includes all necessary variables.#!/bin/bash # Verify the implementation of .inject-Cascader-vars() rg -t less "\.inject-Cascader-vars\s*\(\)\s*\{" packages/theme/src/
- Ensure that no old
--ti-
prefixed variables are left in other related files.#!/bin/bash # Check for any remaining --ti- prefixed variables related to Cascader rg -t less "--ti-cascader" packages/theme/src/
// 下拉菜单面板子项的高度 | ||
--ti-cascader-panel-node-height: var(--ti-common-size-height-normal, 32px); | ||
--tv-CascaderPanel-node-height: 32px; |
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
Use the common height variable instead of hardcoding 32px
.
The value 32px
removes the reference to the standardized height variable --tv-size-height-md
, which is used across multiple components for consistency. To maintain uniformity, please update the value to var(--tv-size-height-md, 32px)
.
🔗 Analysis chain
Variable name updated, but consider maintaining reference to a common height variable.
The change from --ti-cascader-panel-node-height
to --tv-CascaderPanel-node-height
aligns with the new naming convention, which is good.
However, the value has been simplified from var(--ti-common-size-height-normal, 32px)
to 32px
. This removes the reference to a common height variable, which could make it harder to maintain consistent heights across components. Consider keeping a reference to a common height variable, such as var(--tv-size-md, 32px)
, if such a variable exists in the new system.
To verify if a common height variable exists, you can run the following command:
If a suitable common variable is found, consider using it instead of the hardcoded value.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Search for common height variables in Less files
rg --type less '(--tv-size-\w+|--tv-height-\w+).*32px'
Length of output: 1016
--tv-Cascader-list-text-color: var(--tv-color-text); | ||
// 下拉列表子项的高度(没有生效) | ||
--ti-cascader-item-height: var(--ti-common-size-height-normal, 32px); | ||
--tv-Cascader-item-height: 32px; | ||
// 下拉列表子项悬浮时的背景色(没有生效) | ||
--ti-cascader-item-hover-bg-color: #f5f7fa; | ||
// 下拉列表子项选中时的文本色(没有生效) | ||
--ti-cascader-item-checked-text-color: var(--ti-base-color-primary-active); | ||
--tv-Cascader-item-hover-bg-color: #f5f7fa; // 无对应 | ||
// 搜索后下拉列表无匹配数据的文本色 | ||
--ti-cascader-empty-text-color: var(--ti-common-color-text-weaken, #808080); | ||
--tv-Cascader-empty-text-color: var(--tv-color-text-weaken, #808080); | ||
// 搜索框的文本色(没有生效) | ||
--ti-cascader-search-input-text-color: var(--ti-common-color-info-normal, #191919); | ||
--tv-Cascader-search-input-text-color: var(--tv-color-text, #191919); | ||
// 搜索框的占位符的文本色(没有生效) | ||
--ti-cascader-search-input-placeholder-text-color: var(--ti-common-color-placeholder, #808080); | ||
--tv-Cascader-search-input-placeholder-text-color: var(--tv-color-text-placeholder, #808080); |
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.
Review and address ineffective variables
The text color and placeholder variables have been updated consistently. However, several variables are marked as "没有生效" (not effective) in the comments:
--tv-Cascader-list-text-color: var(--tv-color-text);
--tv-Cascader-item-height: 32px;
--tv-Cascader-item-hover-bg-color: #f5f7fa;
--tv-Cascader-search-input-text-color: var(--tv-color-text, #191919);
--tv-Cascader-search-input-placeholder-text-color: var(--tv-color-text-placeholder, #808080);
Please review these variables and either:
- Implement them in the component if they are needed.
- Remove them if they are no longer necessary.
This will help maintain a clean and efficient codebase.
--tv-Cascader-dropdown-box-shadow: var(--tv-shadow-3-left, -4px 0 16px 0 rgba(0, 0, 0, 0.08)); | ||
// 多选模式输入框宽度 | ||
--ti-cascader-width: '100%'; | ||
--tv-Cascader-width: '100%'; | ||
// 下拉框的左侧外边距 | ||
--ti-cascader-dropdown-margin-left: var(--ti-common-space-0, 0px); | ||
--tv-Cascader-dropdown-margin-left: 0; | ||
// 下拉框的右侧侧外边距 | ||
--ti-cascader-dropdown-margin-right: var(--ti-common-space-0, 0px); | ||
--tv-Cascader-dropdown-margin-right: 0; | ||
// 下拉框的顶部外边距 | ||
--ti-cascader-dropdown-margin-top: 4px; | ||
--tv-Cascader-dropdown-margin-top: var(--tv-space-md, 4px); | ||
// 下拉框的底部外边距 | ||
--ti-cascader-dropdown-margin-bottom: 4px; | ||
--tv-Cascader-dropdown-margin-bottom: var(--tv-space-md, 4px); | ||
// 输入框标签左侧外边距 | ||
--ti-cascader-tag-margin-left: var(--ti-common-space-6, 6px); | ||
--tv-Cascader-tag-margin-left: 6px; | ||
// 输入框标签右侧外边距 | ||
--ti-cascader-tag-margin-right: var(--ti-common-space-0, 0px); | ||
--tv-Cascader-tag-margin-right: 0; | ||
// 输入框标签顶部外边距 | ||
--ti-cascader-tag-margin-top: calc(var(--ti-common-space-1, 1px) + 1px); | ||
--tv-Cascader-tag-margin-top: var(--tv-space-xs, 2px); | ||
// 输入框标签底部外边距 | ||
--ti-cascader-tag-margin-bottom: calc(var(--ti-common-space-1, 1px) + 1px); | ||
--tv-Cascader-tag-margin-bottom: var(--tv-space-xs, 2px); |
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.
Correct the width variable value
The layout-related variables have been updated consistently to use the new --tv-
prefix and reference appropriate design tokens. However, the width variable is set to a string value:
--tv-Cascader-width: '100%';
In CSS, percentage values should not be quoted. This should be corrected to:
--tv-Cascader-width: 100%;
This will ensure that the width is correctly applied to the component.
--tv-Cascader-empty-margin-left: 0; | ||
// 搜索后下拉列表无匹配数据右侧外边距 | ||
--ti-cascader-empty-margin-right: var(--ti-common-space-0, 0px); | ||
--tv-Cascader-empty-margin-right: 0; | ||
// 搜索后下拉列表无匹配数据顶部外边距 | ||
--ti-cascader-empty-margin-top: var(--ti-common-space-10, 10px); | ||
--tv-Cascader-empty-margin-top: 10px; | ||
// 搜索后下拉列表无匹配数据底部外边距 | ||
--ti-cascader-empty-margin-bottom: var(--ti-common-space-10, 10px); | ||
--tv-Cascader-empty-margin-bottom: 10px; | ||
// 搜索框的左侧外边距(没有生效) | ||
--ti-cascader-search-input-margin-left: calc(var(--ti-common-space-1, 1px) + 1px); | ||
--tv-Cascader-search-input-margin-left: var(--tv-space-xs, 2px); | ||
// 搜索框的左侧内边距(没有生效) | ||
--ti-cascader-search-input-padding-left: var(--ti-common-space-2x, 8px); | ||
--tv-Cascader-search-input-padding-left: var(--tv-space-md, 8px); | ||
// 下拉列表子项的字体大小 | ||
--ti-cascader-item-font-size: var(--ti-common-font-size-base, 14px); | ||
--tv-Cascader-item-font-size: var(--tv-font-size-md, 14px); | ||
// 搜索框的字体大小(没有生效) | ||
--ti-cascader-search-input-font-size: var(--ti-common-font-size-base, 14px); | ||
--tv-Cascader-search-input-font-size: var(--tv-font-size-md, 14px); | ||
// 输入框关闭图标hover时的颜色 | ||
--ti-cascader-close-hover-icon-color: #191919; | ||
--tv-Cascader-close-hover-icon-color: var(--tv-color-icon-hover, #191919); |
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.
Address remaining ineffective variables and approve changes
The remaining variables have been consistently updated to use the --tv-
prefix and reference appropriate design tokens. However, there are still some variables marked as "没有生效" (not effective):
--tv-Cascader-search-input-margin-left: var(--tv-space-xs, 2px);
--tv-Cascader-search-input-padding-left: var(--tv-space-md, 8px);
--tv-Cascader-search-input-font-size: var(--tv-font-size-md, 14px);
Please review these variables and either implement them in the component or remove them if they are no longer necessary.
The other changes in this section look good, particularly the use of design tokens for values like empty state margins and the close icon hover color.
.inject-Cascader-vars(); | ||
|
||
display: inline-block; | ||
position: relative; | ||
font-size: var(--ti-cascader-font-size); | ||
font-size: var(--tv-Cascader-font-size); |
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
Refactoring from --ti-
to --tv-
prefixes is incomplete. Further updates required.
The verification process has revealed that the renaming of CSS variables from --ti-
to --tv-
prefixes is not complete across the codebase. While the changes in packages/theme/src/cascader/index.less
appear to be correct, numerous other files in the packages/theme/src/
directory still contain --ti-
prefixed variables.
To ensure consistency and prevent potential styling issues:
- Conduct a thorough review of all LESS files in the
packages/theme/src/
directory. - Systematically rename all remaining
--ti-
prefixed variables to use the--tv-
prefix. - Update any components or styles that may be referencing the old variable names.
- After completing the renaming process, perform a comprehensive test of the affected components to ensure no styling regressions have occurred.
This refactoring process is crucial for maintaining a consistent and reliable theming system across the entire project.
🔗 Analysis chain
LGTM! Verify the new method implementation.
The changes look good. The renaming of the CSS variables and the method for injecting them is consistent with the refactoring goals.
Please ensure that the .inject-Cascader-vars()
method is properly implemented and includes all necessary variables. You can verify this by running:
Continued Verification: Inspecting .inject-Cascader-vars()
Method Implementation. To ensure that all necessary CSS variables are correctly injected by the new method, please run the following script:
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: 0
🧹 Outside diff range and nitpick comments (1)
examples/sites/demos/pc/app/cascader/auto-load-checkStrictly.spec.ts (1)
13-13
: Approved: Improved selector specificityThe addition of
nth(0)
to the radio button selector enhances the test's reliability by ensuring it always clicks the first radio button, even if multiple are present. This change aligns with similar updates in other test files, improving consistency across the test suite.Consider adding a comment explaining why
nth(0)
is necessary here, to provide context for future maintainers:// Ensure we're clicking the first radio button in case multiple are present await page.getByRole('menuitem', { name: '选项2' }).getByRole('radio').nth(0).click()
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (2)
- examples/sites/demos/pc/app/cascader/auto-load-checkStrictly.spec.ts (1 hunks)
- examples/sites/demos/pc/app/cascader/check-strictly.spec.ts (1 hunks)
🧰 Additional context used
🔇 Additional comments (2)
examples/sites/demos/pc/app/cascader/check-strictly.spec.ts (2)
7-7
: Improved specificity in radio button selection.The addition of
.nth(0)
explicitly selects the first radio button, which enhances test reliability. This change is beneficial as it prevents potential issues if multiple radio buttons were to exist within the menu item in the future.
10-10
: Consistent update in expectation check.This change aligns with the modification in line 7, ensuring that the expectation check is performed on the same specific radio button that was interacted with. This consistency improves the test's clarity and maintainability.
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
--ti-
to--tv-
across all Cascader components, enhancing maintainability and consistency.Bug Fixes
Documentation