-
Notifications
You must be signed in to change notification settings - Fork 316
refactor(checkbox): [checkbox] refactor checkbox x-design theme #2174
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
Conversation
WalkthroughThe changes involve the removal of specific properties from the checkbox component, including Changes
Possibly related PRs
Poem
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: 7
Outside diff range and nitpick comments (5)
packages/theme/src/mixins/checkbox.less (2)
Line range hint
17-42
: LGTM! Consider documenting the use case.The new
.checkbox-border-disabled
mixin looks well-implemented and handles both unchecked and checked states for disabled checkboxes with borders.Since this is described as a "rarely used scenario", it might be helpful to add a brief comment explaining when this mixin should be used. This could help other developers understand its purpose and prevent misuse.
Line range hint
44-87
: LGTM! Consider using double colon for pseudo-elements.The changes to the
.checkbox-input-disabled
mixin look good. The removal of the@bg-color-checked
parameter and the consistent use of@border-color
for both checked and indeterminate states simplify the mixin and improve consistency.While both
:after
and::after
are valid, consider using::after
for pseudo-elements (and:hover
for pseudo-classes) as it's the modern syntax and helps distinguish between pseudo-classes and pseudo-elements. However, if broader browser support is a concern, the current syntax is acceptable.packages/theme/src/card/index.less (2)
296-296
: Approved: Consider using a CSS variable for consistency.The change from '#FAFAFA' to '#fafafa' is purely cosmetic and doesn't affect functionality. However, for better maintainability and consistency with the rest of the codebase, consider using a CSS variable for this color value.
Consider using a CSS variable for the background color:
- background-color: #fafafa; + background-color: var(--ti-card-input-bg-color, #fafafa);This approach would improve consistency with other color definitions in the codebase and allow for easier theming.
Line range hint
1-299
: Overall review: Consider maintaining flexibility with CSS variables.The changes in this file seem to be moving away from CSS variables towards fixed values for certain properties. While this might simplify the code or improve performance marginally, it could reduce the component's flexibility and make it harder to maintain or customize in the future.
Consider the following general recommendations:
- Maintain the use of CSS variables where possible, especially for values that might need to be adjusted across different themes or responsive designs.
- If moving to fixed values is necessary, document the reasoning behind these changes for future reference.
- Ensure consistency in the approach across the entire component and related components.
- If performance is a concern, consider using CSS custom properties with fallback values, which provides a good balance between performance and flexibility.
packages/theme/src/base/vars.less (1)
314-316
: Improved disabled control state definitionsThe changes to the disabled control background colors are well-thought-out and provide more granular control over the appearance of disabled UI elements. The renaming of
--tv-color-bg-disabled-control-active
to--tv-color-bg-disabled-control-checked
improves clarity.However, for consistency, consider renaming
--tv-color-bg-disabled-control-unactive
to--tv-color-bg-disabled-control-unchecked
to match the terminology used in the "checked" state.- --tv-color-bg-disabled-control-unactive: var(--tv-base-color-common-6); + --tv-color-bg-disabled-control-unchecked: var(--tv-base-color-common-6);
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (14)
- examples/sites/demos/apis/checkbox.js (0 hunks)
- examples/sites/demos/pc/app/checkbox/border-composition-api.vue (0 hunks)
- examples/sites/demos/pc/app/checkbox/border.spec.ts (0 hunks)
- examples/sites/demos/pc/app/checkbox/border.vue (0 hunks)
- examples/sites/demos/pc/app/checkbox/webdoc/checkbox.js (0 hunks)
- packages/theme/src/base/vars.less (4 hunks)
- packages/theme/src/card/index.less (2 hunks)
- packages/theme/src/checkbox-button/index.less (7 hunks)
- packages/theme/src/checkbox-button/vars.less (1 hunks)
- packages/theme/src/checkbox-group/index.less (2 hunks)
- packages/theme/src/checkbox-group/vars.less (1 hunks)
- packages/theme/src/checkbox/index.less (5 hunks)
- packages/theme/src/checkbox/vars.less (1 hunks)
- packages/theme/src/mixins/checkbox.less (3 hunks)
Files not reviewed due to no reviewable changes (5)
- examples/sites/demos/apis/checkbox.js
- examples/sites/demos/pc/app/checkbox/border-composition-api.vue
- examples/sites/demos/pc/app/checkbox/border.spec.ts
- examples/sites/demos/pc/app/checkbox/border.vue
- examples/sites/demos/pc/app/checkbox/webdoc/checkbox.js
Additional comments not posted (25)
packages/theme/src/checkbox-group/vars.less (2)
13-19
: Consistent renaming of function and CSS variables.The changes in this file appear to be part of a larger refactoring effort to standardize naming conventions:
- The function has been renamed from
.component-css-vars-checkbox-group()
to.inject-CheckboxGroup-vars()
.- CSS variable names have been updated from
--ti-checkbox-group-*
to--tv-CheckboxGroup-*
.These changes improve consistency and readability across the codebase.
To ensure this renaming is consistent across the project, please run the following script:
#!/bin/bash # Description: Verify consistent renaming of checkbox group related functions and variables # Test 1: Check for any remaining occurrences of the old function name echo "Checking for old function name..." rg --type less "component-css-vars-checkbox-group" # Test 2: Check for any remaining occurrences of the old CSS variable prefix echo "Checking for old CSS variable prefix..." rg --type less "\-\-ti-checkbox-group-" # Test 3: Check for consistent use of the new function name echo "Checking for consistent use of new function name..." rg --type less "inject-CheckboxGroup-vars" # Test 4: Check for consistent use of the new CSS variable prefix echo "Checking for consistent use of new CSS variable prefix..." rg --type less "\-\-tv-CheckboxGroup-"
19-19
: Verify the impact of changing margin-top to 0.The
--tv-CheckboxGroup-margin-top
value has been changed to a fixed value of 0. This might affect the layout of the checkbox group component.To ensure this change doesn't negatively impact the layout, please run the following script:
Additionally, please visually inspect the checkbox group component in various contexts to ensure the layout remains correct with this change.
packages/theme/src/checkbox-group/index.less (5)
24-24
: Clarify the reason for removing the flex-wrap CSS variable.The
flex-wrap
property has been changed from using a CSS variable to a fixed value ofwrap
. While this simplifies the code, it removes the flexibility to control this behavior through a variable.Could you please clarify the reasoning behind this change? Was the variable never used differently, or is there a specific requirement for always using
wrap
?To check the previous usage, you can run:
#!/bin/bash # Description: Check for any custom usage of the checkbox group flex-wrap variable # Test: Search for any custom usage of the checkbox group flex-wrap variable rg --type less --type css --type vue "ti-checkbox-group-flex-wrap"
26-26
: Approve the use of new CSS variable for margin-top.The use of
--tv-CheckboxGroup-margin-top
aligns with the new CSS variable naming convention, which is good for consistency.To ensure the new variable is properly defined and consistent with the old one, please run:
#!/bin/bash # Description: Verify the definition and value of the new margin-top variable # Test 1: Search for the definition of the new variable rg --type less --type css "tv-CheckboxGroup-margin-top" # Test 2: Compare with the old variable (if it exists) rg --type less --type css "ti-checkbox-group-margin-top"
36-36
: Approve the use of new CSS variable for margin-bottom in vertical layout.The use of
--tv-CheckboxGroup-margin-bottom
for the vertical layout's margin-bottom aligns with the new CSS variable naming convention, which is good for consistency.To ensure the new variable is properly defined and consistent with the old one, please run:
#!/bin/bash # Description: Verify the definition and value of the new margin-bottom variable # Test 1: Search for the definition of the new variable rg --type less --type css "tv-CheckboxGroup-margin-bottom" # Test 2: Compare with the old variable (if it exists) rg --type less --type css "ti-checkbox-group-margin-bottom"
Line range hint
1-44
: Overall assessment of checkbox group styling changes.The refactoring of this file aligns with the project's goal of standardizing CSS variable usage and simplifying the stylesheet structure. The changes generally improve code consistency and maintainability.
However, there are a few points to consider:
- The introduction of the
.inject-CheckboxGroup-vars()
mixin centralizes variable injection, which is good, but we need to ensure it includes all necessary variables.- The hardcoding of
flex-wrap: wrap;
reduces flexibility. The rationale behind this change should be clarified.- The new CSS variable naming convention (
--tv-*
) is consistently applied, which improves overall code coherence.These changes seem to be part of a larger refactoring effort. To ensure consistency across the entire codebase, it would be beneficial to:
- Check for any remaining usages of old variable names:
#!/bin/bash # Description: Find any remaining old variable names in the codebase # Test: Search for old variable name pattern rg --type less --type css --type vue "ti-checkbox-group-"
- Verify that the new variable names are consistently used:
#!/bin/bash # Description: Check for consistent usage of new variable names # Test: Search for new variable name pattern rg --type less --type css --type vue "tv-CheckboxGroup-"These checks will help ensure that the refactoring has been applied consistently across the project.
21-21
: Approve the use of.inject-CheckboxGroup-vars()
mixin.The introduction of a single mixin to inject CheckboxGroup variables is a good refactoring step. It can improve maintainability and reduce code duplication.
To ensure all necessary variables are included, please run the following script:
Verification successful
Verification Successful:
.inject-CheckboxGroup-vars()
mixin is correctly implemented.The
.inject-CheckboxGroup-vars()
mixin inpackages/theme/src/checkbox-group/vars.less
includes all necessary CSS variables for the CheckboxGroup component. The refactoring effectively consolidates variable declarations, enhancing maintainability and reducing code duplication.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the contents of the .inject-CheckboxGroup-vars() mixin # Test: Search for the mixin definition and its contents rg --type less -A 10 "\.inject-CheckboxGroup-vars\(\s*\)\s*\{"Length of output: 179
Script:
#!/bin/bash # Description: Verify the contents of the .inject-CheckboxGroup-vars() mixin # Test: Search for the mixin definition and its contents in .less and .css files rg --type less --type css -A 10 "\.inject-CheckboxGroup-vars\(\s*\)\s*\{"Length of output: 621
packages/theme/src/base/vars.less (2)
293-294
: Excellent addition of control-specific icon colors!The new CSS custom properties
--tv-color-icon-control-active
and--tv-color-icon-control-disabled
are well-defined and provide specific colors for control icons (mainly checkboxes and radio buttons). This addition enhances the consistency and flexibility of the design system, allowing for easy customization of these specific UI elements.
319-319
: Unified hover background and new active control borderThe changes improve consistency in the design system:
- Unifying
--tv-color-bg-hover
with--tv-base-color-common-3
may enhance overall UI consistency.- Adding
--tv-color-border-active-control
provides clear visual feedback for active controls.These changes are approved, but it's important to verify the impact of the hover background color change across all components.
To ensure the hover background color change doesn't negatively impact any components, please run the following command to check its usage:
Review the results to confirm that the new color works well in all contexts where it's used.
Also applies to: 340-340
Verification successful
Hover background color change verified
The usage of
--tv-color-bg-hover
has been updated consistently across the codebase:
packages/theme/src/pager/vars.less
packages/theme/src/base/vars.less
No issues found.
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Search for all occurrences of --tv-color-bg-hover in .vue, .less, and .css files rg --type vue --type less --type css -A 5 $'--tv-color-bg-hover'Length of output: 485
Script:
#!/bin/bash # Search for all occurrences of --tv-color-bg-hover in .vue, .less, and .css files rg --type vue --type less --type css -A 5 -e '--tv-color-bg-hover'Length of output: 94
Script:
#!/bin/bash # Search for all occurrences of --tv-color-bg-hover in .vue, .less, and .css files rg -g '*.vue' -g '*.less' -g '*.css' -A 5 -e '--tv-color-bg-hover'Length of output: 2176
packages/theme/src/checkbox-button/vars.less (2)
39-39
: Duplicate font-size variables for mini and small sizesBoth
--tv-CheckboxButton-size-mini-font-size
and--tv-CheckboxButton-small-font-size
are assigned the same valuevar(--tv-font-size-sm)
. Verify if this is intentional or if different font sizes should be applied tomini
andsmall
variants for distinction.To confirm if the font sizes should differ, check other components or design guidelines for consistency.
Also applies to: 49-49
43-47
: Review size variables for consistency with design specificationsThe height variables for
mini
,small
, andmedium
sizes are defined as follows:
--tv-CheckboxButton-size-small-height
:var(--tv-size-height-sm);
--tv-CheckboxButton-size-mini-height
:var(--tv-size-height-xs);
--tv-CheckboxButton-size-medium-height
:var(--tv-size-height-lg);
Ensure that these sizes align with the design specifications and that the
medium
size is correctly set tovar(--tv-size-height-lg)
. Typically,medium
might correspond tovar(--tv-size-height-md)
unless intentionally set otherwise.packages/theme/src/checkbox/index.less (9)
21-29
: Good job updating to the new theming variablesLines 21-29 correctly apply the new CSS variables prefixed with
--tv-
, enhancing consistency and maintainability of the theming system.
41-45
: Consistent use of CSS variables for dimensions and bordersThe updates in lines 41-45 correctly utilize the new theming variables for border, border-radius, width, and height, aligning with the updated theming system.
57-58
: Correct application of variable-based dimensions for SVG iconsLines 57-58 properly set the SVG icon dimensions using the new variables, ensuring scalability and consistency.
62-70
: Proper use of theming variables for icon colorsThe fills for
.icon-checked-sur
and.icon-halfselect
are correctly updated to use the appropriate variables in lines 62 and 70.
79-88
: Updated styling for.is-filter
classLines 79-88 show correct updates to the background color, padding, border-radius, and line-height, enhancing the
.is-filter
class styling.
94-95
: Consistent border styling in.is-bordered
classLines 94-95 appropriately use the new variables for border-radius and border properties.
153-153
: Verify outline color variable usageLine 153 sets the outline color using
var(--tv-Checkbox-bg-color-checked)
. Ensure that this variable represents an appropriate color for the outline and that it meets accessibility standards.Consider using a dedicated outline color variable for the outline to enhance clarity and maintainability.
170-171
: Appropriate use of font variablesLines 170-171 correctly apply font size and weight using the new variables, maintaining consistency in typography.
185-203
: Ensure the.is-group-display-only
class behaves as expectedLines 185-203 modify styles for the
.is-group-display-only
class. Verify that the display properties and conditional visibility work as intended with the updated styles.Consider testing the component to ensure no unintended side effects occur due to these style changes.
packages/theme/src/checkbox-button/index.less (4)
20-20
: Utilization of.inject-CheckboxButton-vars();
mixinThe addition of the
.inject-CheckboxButton-vars();
mixin enhances maintainability by centralizing variable declarations for the checkbox button component.
140-140
: Consistent alignment and display properties across sizesLines 140, 152, and 165 set
display: flex;
andalign-items: center;
for medium, small, and mini sizes respectively. Ensure that this consistency across different sizes is maintained throughout the stylesheet for uniform behavior.Also applies to: 152-152, 165-165
124-125
: Ensure hover state variables are properly definedLines 124-125 introduce hover state styles using new variables:
- Line 124:
color: var(--tv-CheckboxButton-hover-text-color);
- Line 125:
border: 1px solid var(--tv-CheckboxButton-border-color-hover);
Please ensure that these variables (
--tv-CheckboxButton-hover-text-color
and--tv-CheckboxButton-border-color-hover
) are defined in your variables file to avoid any undefined variable issues.Run the following script to confirm the variable definitions:
#!/bin/bash # Description: Verify that hover state variables are defined. # Variables to check variables=( '--tv-CheckboxButton-hover-text-color' '--tv-CheckboxButton-border-color-hover' ) for var in "${variables[@]}"; do echo "Checking definition of $var" rg --type less "$var\\s*:" done
168-168
: Verify the uniqueborder-radius
variable for the 'mini' sizeOn line 168, the
border-radius
for the 'mini' size usesvar(--tv-CheckboxButton-size-mini-border-radius);
, whereas other sizes usevar(--tv-CheckboxButton-border-radius);
. Please confirm if this differentiation is intentional and that the variable--tv-CheckboxButton-size-mini-border-radius
is defined.Run the following script to verify the definition of the variable:
Verification successful
Border-radius for 'mini' size is correctly defined
Confirmed that
--tv-CheckboxButton-size-mini-border-radius
is defined inpackages/theme/src/checkbox-button/vars.less
. The differentiation for the 'mini' size'sborder-radius
is intentional.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify that '--tv-CheckboxButton-size-mini-border-radius' is defined. # Test: Search for the variable definition. Expectation: At least one occurrence in the variables files. rg --type less $'--tv-CheckboxButton-size-mini-border-radius\\s*:'Length of output: 1427
Script:
#!/bin/bash # Description: Verify that '--tv-CheckboxButton-size-mini-border-radius' is defined. # Test: Search for the variable definition. Expectation: At least one occurrence in the variables files. rg --type less -e '--tv-CheckboxButton-size-mini-border-radius\s*:'Length of output: 189
packages/theme/src/checkbox/vars.less (1)
13-62
: Approved: Refactored CSS variables align with new naming conventionsThe updates to the function name and CSS variable prefixes from
--ti-
to--tv-
enhance consistency across the codebase. The modifications adhere to the new naming conventions and improve maintainability.
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 (2)
packages/theme/src/checkbox-button/vars.less (1)
39-49
: Addition of size-related variablesThe introduction of new variables for button heights and font sizes at different sizes (mini, small, medium) is a positive change. This provides more granular control over the component's appearance and improves flexibility.
However, for better consistency, consider renaming
--tv-CheckboxButton-small-font-size
to--tv-CheckboxButton-size-small-font-size
to match the naming pattern of other size-related variables.Apply this diff for improved consistency:
- --tv-CheckboxButton-small-font-size: var(--tv-font-size-sm); + --tv-CheckboxButton-size-small-font-size: var(--tv-font-size-sm);packages/theme/src/checkbox-button/index.less (1)
Line range hint
1-194
: Overall assessment: Good refactoring with minor improvements neededThe refactoring of the checkbox button styles has significantly improved the use of CSS variables, enhancing maintainability and theming capabilities. Most issues from previous reviews have been addressed.
However, there are a few minor issues that still need attention:
- Inconsistent CSS variable prefixes (using
--ti-
instead of--tv-
) on lines 75 and 82.- Hardcoded padding values on line 97 that could be replaced with CSS variables.
Once these minor issues are resolved, the refactoring will be complete and consistent throughout the file.
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (3)
- examples/sites/demos/pc/app/checkbox/shape.spec.ts (1 hunks)
- packages/theme/src/checkbox-button/index.less (7 hunks)
- packages/theme/src/checkbox-button/vars.less (1 hunks)
Additional comments not posted (13)
examples/sites/demos/pc/app/checkbox/shape.spec.ts (1)
11-13
: Approved: Consistent color change across checkbox elements.The background color expectation has been updated from 'rgb(245, 246, 248)' to 'rgb(230, 230, 230)' consistently for all three checkbox elements. This change aligns with the refactoring effort mentioned in the PR objectives.
To ensure this color change is consistent across the codebase, please run the following script:
Could you provide some context for this color change? It would be helpful to understand the reasoning behind selecting this specific shade of gray ('rgb(230, 230, 230)') for the checkbox background.
packages/theme/src/checkbox-button/vars.less (4)
13-13
: Improved function naming and structureThe change from
.component-css-vars-checkbox-button()
to.inject-CheckboxButton-vars()
is a positive improvement. The new name is more descriptive and aligns better with modern CSS-in-JS practices. This change enhances code readability and maintainability.
15-51
: Consistent update of variable prefixesThe change from
--ti-
to--tv-
prefix for all variables is consistent and well-implemented. This update likely reflects a broader change in the project's theming structure. The consistency in naming conventions enhances code maintainability and reduces the potential for errors.
15-41
: Improved use of theme variables for colors and stylesThe refactoring to use theme variables (e.g.,
var(--tv-color-bg-secondary)
) for colors, font sizes, and border radii is a significant improvement. This change enhances consistency across the component and potentially the entire design system. It also improves maintainability by centralizing style definitions and making it easier to implement global style changes.
13-51
: Clarification needed on removed variablesThe AI summary indicates that some variables related to button sizes, margins, and paddings have been removed. Could you please clarify the reasoning behind these removals? It's important to ensure that this simplification doesn't negatively impact the component's flexibility or cause unintended side effects in existing implementations.
To help assess the impact, please run the following script to check for any remaining references to the removed variables:
Verification successful
No issues found with variable removal
After thorough verification, all
tv-CheckboxButton
variables related to size, margin, and padding are still present invars.less
and are actively used inindex.less
. There are no removed or replaced variables affecting the component's styling.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Search for references to removed variables in the codebase # Test: Search for references to removed variables rg --type less --type vue --type js 'ti-CheckboxButton-(size|margin|padding)'Length of output: 107
Script:
#!/bin/bash # Description: Search for references to removed variables in the codebase # Corrected search pattern and file types rg --glob '*.less' --glob '*.vue' --glob '*.js' 'tv-CheckboxButton-(size|margin|padding)'Length of output: 1490
packages/theme/src/checkbox-button/index.less (8)
20-24
: LGTM: Improved modularity and consistencyThe introduction of the
.inject-CheckboxButton-vars()
mixin and the use of CSS variables for styling properties like margin-top are positive changes. They enhance modularity and maintain consistency with modern CSS best practices.
27-37
: LGTM: Consistent use of CSS variables and layout adjustmentThe update to use the new CSS variable for border-right color (line 35) is consistent with the overall refactoring. The addition of
display: block;
(line 37) may affect the layout, but it appears to be an intentional change to ensure the pseudo-element is visible.
40-54
: LGTM: Refined checkmark stylingThe adjustments to the checkmark's pseudo-element (lines 40-54) appear to be fine-tuning its appearance. These changes should improve the visual presentation of the checked state.
64-65
: LGTM: Consistent use of CSS variablesThe updates to color and border-color properties using the new CSS variables (lines 64-65) are consistent with the overall refactoring approach. This change enhances maintainability and theming capabilities.
112-116
: LGTM: Consistent styling updatesThe updates to the margin property (line 112) and the introduction of a font-size property using a CSS variable (line 116) are consistent with the overall refactoring approach. These changes enhance maintainability and theming capabilities.
124-125
: LGTM: Consistent use of CSS variables for hover stateThe updates to color and border properties for the hover state (lines 124-125) using the new CSS variables are consistent with the overall refactoring approach. This change improves maintainability and theming flexibility.
Line range hint
140-168
: LGTM: Improved size variants using CSS variablesThe updates to various properties for different button sizes (medium, small, mini) using CSS variables (lines 140-168) are well-implemented. This approach significantly improves maintainability and allows for easier theming and customization of size variants.
Line range hint
177-194
: LGTM: Consistent updates for mini size and focus stateThe updates to the checked state styling for mini size buttons (lines 177-179) and the focus state (line 194) using new CSS variables are consistent with the overall refactoring approach. These changes maintain visual consistency while improving 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
Release Notes
New Features
Bug Fixes
Refactor
Chores