-
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(dialog-box): [dialog-box] refactor dialog-box theme vars #2202
Conversation
WalkthroughThe changes involve a comprehensive refactoring of the dialog box theme's CSS variables, transitioning from a prefix-based naming convention ( Changes
Possibly related PRs
Suggested labels
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 3
🧹 Outside diff range and nitpick comments (2)
packages/theme/src/dialog-box/index.less (2)
139-140
: LGTM with a suggestion: Footer styles updateThe updates to footer padding and the introduction of a variable for button minimum width are good improvements. They enhance consistency and maintainability.
Consider adding a comment explaining the rationale behind the specific padding values (24px 32px 32px) for better maintainability in the future.
Also applies to: 144-144
182-185
: LGTM with a suggestion: Drawer body styles updateThe introduction of new variables for drawer body color and divider border color enhances theme customization capabilities. The padding update for the drawer body is also noted.
Consider adding a comment explaining the rationale behind the specific padding value (0 32px) for better maintainability in the future.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (2)
- packages/theme/src/dialog-box/index.less (7 hunks)
- packages/theme/src/dialog-box/vars.less (1 hunks)
🔇 Additional comments (9)
packages/theme/src/dialog-box/index.less (9)
21-21
: LGTM: Consistent variable naming updateThe changes to the background color, border-radius, and box-shadow properties are consistent with the refactoring goal. The new variable names (
--tv-DialogBox-*
) are more specific to the DialogBox component, which improves clarity and maintainability.Also applies to: 23-24
28-28
: Approve mixin addition, verify layout changesThe addition of
.inject-DialogBox-vars()
mixin is a good practice for modular and reusable styles. However, the changes todisplay
andalign-items
properties might affect the layout of the dialog box wrapper.Please verify that these changes don't negatively impact the dialog box layout in various scenarios. Consider running visual regression tests if available.
Also applies to: 37-38
63-65
: LGTM: Improved variable naming for header stylesThe updates to padding, background color, font properties, and text color use more specific and descriptive variable names. This change enhances the maintainability and clarity of the header styles.
Also applies to: 70-71
86-87
: Approve variable updates, verify button positioningThe use of new variable names for icon colors and sizes is consistent with the refactoring goal and improves maintainability. However, the changes to the positioning of header buttons (
top
andright
properties) might affect their layout.Please verify that the new positioning of header buttons (lines 86-87) doesn't cause any visual issues or overlap with other elements in the header.
Also applies to: 99-100, 103-103, 108-109, 112-112
120-122
: LGTM: Improved variable naming for body stylesThe updates to padding, text color, and font size for the dialog body use more specific variable names. This change enhances the maintainability and clarity of the body styles.
156-158
: Approve width variables, clarify border-radiusThe introduction of variables for drawer minimum and maximum width improves flexibility and maintainability.
Could you clarify the rationale behind setting the border-radius to 0? This change might affect the visual appearance of the drawer-style dialog. Please confirm if this is intentional and aligns with the design specifications.
165-167
: Approve layout changes, verify visual appearanceThe updates to width, margins, padding, and positioning for the drawer-style dialog components improve flexibility and potentially the overall layout. The use of
calc()
for width calculation is a good practice.Please verify that these layout changes:
- Maintain the desired visual appearance of the drawer-style dialog.
- Ensure proper alignment of header, body, and footer components.
- Don't cause any overflow or truncation issues with the content.
Consider running visual regression tests if available.
Also applies to: 171-172, 175-175
188-189
: Approve footer changes, verify alignmentThe updates to padding and text alignment for the drawer footer are noted.
Please verify that:
- The new padding (24px 0 32px) provides sufficient space for footer content without causing overflow.
- The right text alignment is consistent with the design specifications and doesn't cause any visual issues with different types of footer content (e.g., multiple buttons, long text).
Line range hint
1-324
: Overall assessment: Consistent and comprehensive refactoringThe changes in this file demonstrate a consistent and comprehensive refactoring of the dialog box styles. The transition from
--ti-
to--tv-
prefixed variables enhances the specificity and maintainability of the component styles. The introduction of new variables for various aspects of the dialog box (including the drawer variant) improves theme customization capabilities.Key improvements:
- More specific and descriptive variable names
- Enhanced modularity with the introduction of the
.inject-DialogBox-vars()
mixin- Improved flexibility in layout with the use of
calc()
and new width variablesWhile the changes appear to be well-implemented, it's crucial to verify that they don't introduce any unintended visual or functional regressions, especially in the layout and positioning of dialog box elements.
Recommend conducting thorough visual regression testing across different screen sizes and content scenarios to ensure the refactored styles maintain the intended design and functionality of the dialog box component.
--tv-DialogBox-btn-height: 32px; | ||
// 关闭按钮图标尺寸 | ||
--ti-dialog-box-close-icon-size: var(--ti-common-font-size-5, 24px); | ||
--tv-DialogBox-close-icon-size: 24px; |
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 variables instead of hard-coded pixel values
The properties --tv-DialogBox-btn-height
and --tv-DialogBox-close-icon-size
use hard-coded pixel values (32px
, 24px
). For consistency and easier theming, consider using existing size variables or introducing new ones.
Apply the following changes:
- --tv-DialogBox-btn-height: 32px;
+ --tv-DialogBox-btn-height: var(--tv-size-md);
- --tv-DialogBox-close-icon-size: 24px;
+ --tv-DialogBox-close-icon-size: var(--tv-icon-size-lg);
📝 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.
--tv-DialogBox-btn-height: 32px; | |
// 关闭按钮图标尺寸 | |
--ti-dialog-box-close-icon-size: var(--ti-common-font-size-5, 24px); | |
--tv-DialogBox-close-icon-size: 24px; | |
--tv-DialogBox-btn-height: var(--tv-size-md); | |
// 关闭按钮图标尺寸 | |
--tv-DialogBox-close-icon-size: var(--tv-icon-size-lg); |
--tv-DialogBox-drawer-min-width: 500px; | ||
// 抽屉最大宽度 | ||
--ti-dialog-box-drawer-max-width: calc(var(--ti-common-space-10, 10px) * 100); | ||
// 抽屉左内边距 | ||
--ti-dialog-box-drawer-padding-left: var(--ti-common-space-8x, 32px); | ||
// 抽屉右内边距 | ||
--ti-dialog-box-drawer-padding-right: var(--ti-common-space-8x, 32px); | ||
// 抽屉头部上内边距 | ||
--ti-dialog-box-drawer-header-padding-top: var(--ti-common-space-8x, 32px); | ||
// 抽屉头部下内边距 | ||
--ti-dialog-box-drawer-header-padding-bottom: var(--ti-common-space-5x, 20px); | ||
// 抽屉头部左内边距 | ||
--ti-dialog-box-drawer-header-padding-left: var(--ti-common-space-0, 0px); | ||
// 抽屉头部右内边距 | ||
--ti-dialog-box-drawer-body-padding-right: var(--ti-common-space-8x, 32px); | ||
// 抽屉内容上内边距 | ||
--ti-dialog-box-drawer-body-padding-top: var(--ti-common-space-0, 0px); | ||
// 抽屉内容下内边距 | ||
--ti-dialog-box-drawer-body-padding-bottom: var(--ti-common-space-0, 0px); | ||
// 抽屉内容左内边距 | ||
--ti-dialog-box-drawer-body-padding-left: var(--ti-common-space-8x, 32px); | ||
// 抽屉内容右内边距 | ||
--ti-dialog-box-drawer-header-padding-right: var(--ti-common-space-0, 0px); | ||
// 抽屉底部文本对齐方式 | ||
--ti-dialog-box-drawer-footer-text-align: right; | ||
// 抽屉底部上内边距 | ||
--ti-dialog-box-drawer-footer-padding-top: var(--ti-common-space-6x, 24px); | ||
// 抽屉底部下内边距 | ||
--ti-dialog-box-drawer-footer-padding-bottom: var(--ti-common-space-8x, 32px); | ||
// 抽屉底部左内边距 | ||
--ti-dialog-box-drawer-footer-padding-left: var(--ti-common-space-0, 0px); | ||
// 抽屉底部右内边距 | ||
--ti-dialog-box-drawer-footer-padding-right: var(--ti-common-space-0, 0px); | ||
// 抽屉底部左外边距 | ||
--ti-dialog-box-drawer-footer-margin-left: var(--ti-common-space-8x, 32px); | ||
// 抽屉底部右外边距 | ||
--ti-dialog-box-drawer-footer-margin-right: var(--ti-common-space-10x, 40px); | ||
--tv-DialogBox-drawer-max-width: 1000px; |
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
Parameterize drawer width values using variables
The properties --tv-DialogBox-drawer-min-width
and --tv-DialogBox-drawer-max-width
use fixed pixel values (500px
, 1000px
). To enhance flexibility and maintain consistency, consider defining these values using variables or calculating them based on existing sizing variables.
For example:
- --tv-DialogBox-drawer-min-width: 500px;
+ --tv-DialogBox-drawer-min-width: var(--tv-drawer-min-width);
- --tv-DialogBox-drawer-max-width: 1000px;
+ --tv-DialogBox-drawer-max-width: var(--tv-drawer-max-width);
Ensure to define --tv-drawer-min-width
and --tv-drawer-max-width
accordingly in your theme variables.
Committable suggestion was skipped due to low confidence.
@@ -10,136 +10,46 @@ | |||
* | |||
*/ | |||
|
|||
.component-css-vars-dialog-box() { | |||
.inject-DialogBox-vars() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codebase verification
Mixin Naming Inconsistency Detected
The new mixin .inject-DialogBox-vars()
does not align with the existing component-css-vars-xxx
naming convention used throughout the codebase. Please update the mixin name to follow the established pattern for consistency and maintainability.
🔗 Analysis chain
Ensure mixin naming aligns with project conventions
The mixin .inject-DialogBox-vars()
replaces .component-css-vars-dialog-box()
. Please verify that the new naming convention follows the project's guidelines for mixin naming. Consistent naming helps maintain readability and maintainability.
You can run the following script to check for mixin naming patterns in the codebase:
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: List all mixin declarations in LESS files to verify naming conventions.
# Expectation: Mixin names should follow a consistent pattern.
rg --type less '^\.([a-zA-Z0-9_-]+)\(' -o --no-filename -r '$1' | sort | uniq
Length of output: 6372
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