-
Notifications
You must be signed in to change notification settings - Fork 297
refactor(link): [link] refactor the link theme #2273
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 in this pull request involve updates to expected CSS color values for various link elements across multiple test files. Additionally, there are modifications to CSS variable naming conventions and method signatures within the theme's LESS files. The updates aim to standardize color values for link states and enhance consistency in styling. Changes
Possibly related PRs
Suggested reviewers
📜 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: 1
🧹 Outside diff range and nitpick comments (5)
examples/sites/demos/pc/app/link/basic-usage.spec.ts (1)
12-12
: Consider enhancing test coverage and improving maintainabilityThe update to the expected hover color aligns with the PR's objective of refactoring the link theme. However, there are a few points to consider:
The test only checks the hover state color. Consider adding a test for the default (non-hover) state as well to ensure complete coverage of link behavior.
The specific color value '20, 118, 255' is hardcoded. To improve maintainability and make future theme changes easier, consider using a constant or configuration value instead.
There's no explanation for why this specific color was chosen. Adding a comment explaining the rationale behind the color change would improve code readability and maintainability.
Here's a suggested improvement:
import { LINK_HOVER_COLOR } from '../../../constants/colors'; // ... rest of the code ... // Check default state await expect(link.first()).toHaveCSS('color', LINK_DEFAULT_COLOR); // Check hover state await link.first().hover(); await expect(link.first()).toHaveCSS('color', LINK_HOVER_COLOR);This approach would centralize color definitions and make it easier to update them across all tests in the future.
examples/sites/demos/pc/app/link/link-style.spec.ts (2)
20-23
: LGTM! Consider adding a comment explaining the color choice.The color change for the default link is consistent across all states (initial, hover, and after pseudo-element). The new color 'rgb(20, 118, 255)' appears to be a shade of blue, which is typical for default links.
Consider adding a comment explaining the rationale behind this specific color choice, especially if it's part of a broader design system or brand guidelines. This would help future maintainers understand the context of this change.
Line range hint
1-53
: Consider a comprehensive review of the link color scheme.The changes in this file consistently update the expected colors for various link types in the test suite. While most color choices align well with user expectations, there are a few points to consider:
- The primary link color (near-black) might have accessibility issues.
- The info link color is identical to the default link color, which could lead to user confusion.
- It's unclear if these color changes are part of a broader design system update.
To ensure a cohesive and accessible design:
- Conduct a comprehensive review of the entire link color scheme, ensuring each link type has a distinct and appropriate color.
- Verify that all colors meet WCAG 2.1 accessibility standards for color contrast.
- Consider creating a color palette or design tokens that can be reused across the project for consistency.
- Update the documentation to reflect the new color choices and their rationale.
This will help maintain a consistent user experience and make future updates easier to manage.
packages/theme/src/link/vars.less (1)
15-89
: Consistent application of new CSS variable naming convention.The update of all CSS variable names to use the
--ti-Link-
prefix is consistent and improves code organization. This change reduces the risk of naming conflicts and enhances code readability.Consider updating any relevant documentation to reflect this new naming convention, if not already done.
packages/theme/src/link/index.less (1)
92-92
: Approve icon-specific underline styles, suggest documentation.The introduction of icon-specific underline width variables (
--ti-Link-has-icon-underline-width
) provides more granular control over underline styles when icons are present. The use ofcalc()
for dynamic positioning is a good approach.Consider adding comments or documentation to explain the purpose and expected values of the new
--ti-Link-has-icon-underline-width
variable. This will help other developers understand and correctly use this styling option.Also applies to: 96-96
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (5)
- examples/sites/demos/pc/app/link/basic-usage.spec.ts (1 hunks)
- examples/sites/demos/pc/app/link/dynamic-disable.spec.ts (1 hunks)
- examples/sites/demos/pc/app/link/link-style.spec.ts (1 hunks)
- packages/theme/src/link/index.less (2 hunks)
- packages/theme/src/link/vars.less (1 hunks)
🧰 Additional context used
🔇 Additional comments (26)
examples/sites/demos/pc/app/link/dynamic-disable.spec.ts (7)
10-10
: LGTM: Consistent color update for disabled default linkThe change to use 'rgb(194, 194, 194)' as the expected color for the disabled default link is consistent with the refactoring objective. It maintains the test's effectiveness while standardizing the color across all link types.
14-14
: LGTM: Consistent color update for disabled primary linkThe change to use 'rgb(194, 194, 194)' as the expected color for the disabled primary link maintains consistency with the refactoring pattern established for the default link.
18-18
: LGTM: Consistent color update for disabled success linkThe change to use 'rgb(194, 194, 194)' as the expected color for the disabled success link continues the consistent refactoring pattern across different link types.
22-22
: LGTM: Consistent color update for disabled warning linkThe change to use 'rgb(194, 194, 194)' as the expected color for the disabled warning link maintains the consistent refactoring pattern established for all link types.
26-26
: LGTM: Consistent color update for disabled danger linkThe change to use 'rgb(194, 194, 194)' as the expected color for the disabled danger link further reinforces the consistent refactoring pattern across all link types.
30-30
: LGTM: Consistent color update for disabled info link and overall refactoringThe change to use 'rgb(194, 194, 194)' as the expected color for the disabled info link completes the consistent refactoring pattern across all link types. This modification, along with the previous ones, successfully standardizes the expected color for all disabled links in the test.
The refactoring achieves the following:
- Consistency: All link types now expect the same color when disabled.
- Simplification: The test now checks for a single, uniform color value across different link types.
- Maintainability: Future color changes can be made more easily by updating a single value.
These changes align well with the PR objective of refactoring the link theme while maintaining the test's effectiveness.
Line range hint
1-32
: Overall assessment: Successful refactoring of link theme in test fileThe changes in this file successfully refactor the link theme by standardizing the expected color for disabled links across all types (default, primary, success, warning, danger, and info). This refactoring aligns well with the PR objectives and offers several benefits:
- Consistency: A uniform color expectation ('rgb(194, 194, 194)') is now applied to all disabled link types.
- Simplification: The test logic is simplified by using a single color value for all checks.
- Maintainability: Future updates to the disabled link color can be made more easily by changing a single value.
The changes maintain the effectiveness of the test while improving its structure and readability. This refactoring contributes positively to the overall code quality and aligns with best practices for test maintenance.
examples/sites/demos/pc/app/link/link-style.spec.ts (4)
32-35
: LGTM! Appropriate color choice for success link.The color change for the success link to 'rgb(92, 179, 0)' is consistent across all states and appears to be an appropriate shade of green typically associated with success. This color choice aligns well with user expectations for success-related elements.
38-41
: LGTM! Suitable color choice for warning link.The color change for the warning link to 'rgb(255, 136, 0)' is consistent across all states. This shade of orange is typically associated with warnings, making it an appropriate choice for a warning link. The color aligns well with user expectations for warning-related elements.
44-47
: LGTM! Appropriate color choice for danger link.The color change for the danger link to 'rgb(242, 48, 48)' is consistent across all states. This shade of red is typically associated with danger or errors, making it an appropriate choice for a danger link. The color aligns well with user expectations for danger-related elements.
26-29
:⚠️ Potential issueVerify accessibility standards for the primary link color.
The color change for the primary link to 'rgb(25, 25, 25)' (very close to black) is consistent across all states. However, this color choice raises some concerns:
- It's unusual for a primary link to be nearly black, as this might not visually indicate that it's clickable.
- The contrast between this color and typical background colors might not meet accessibility standards, particularly for users with visual impairments.
Please verify that this color choice meets WCAG 2.1 accessibility standards for color contrast. You can use tools like the WebAIM Contrast Checker to ensure compliance.
Additionally, consider running the following command to check if this color is used consistently across the project:
#!/bin/bash # Search for the use of rgb(25, 25, 25) color in the project rg -t css -t less -t scss -t js -t ts 'rgb\(25,\s*25,\s*25\)' || echo "Color not found in other files"This will help ensure that the color choice is part of a consistent design system.
packages/theme/src/link/vars.less (4)
35-89
: Comprehensive coverage of link states and properties.The changes thoroughly cover all necessary link states (default, hover, primary, danger, success, warning, and info) and their respective properties (text color, border color, disabled state). The consistency in naming and structure across different states is commendable.
13-94
: Excellent consistency and thorough commenting.The changes demonstrate remarkable consistency in naming, structure, and commenting throughout the file. Each variable is accompanied by a clear comment explaining its purpose, which significantly enhances code readability and maintainability.
13-13
: Function renaming looks good, but verify usage.The renaming of
.component-css-vars-link()
to.inject-Link-vars()
improves clarity and follows a more specific naming convention. This change enhances code readability and maintainability.Please verify that all references to this function have been updated across the codebase. Run the following script to check for any remaining occurrences of the old function name:
#!/bin/bash # Search for any remaining occurrences of the old function name rg --type less "\.component-css-vars-link\(\)"
15-89
: Good use of centralized theme variables, but verify their existence.The use of centralized theme variables (e.g.,
--tv-font-size-md
,--tv-color-border-hover
) is a positive change. It promotes consistency across the UI and simplifies future theme updates.Please ensure that all referenced
--tv-*
variables are properly defined elsewhere in the codebase. Run the following script to check for the definitions of these variables:#!/bin/bash # Search for definitions of the new theme variables rg --type less "^\s*--tv-" | sort | uniqpackages/theme/src/link/index.less (11)
53-54
: Approve hover and disabled state style updates.The color and fill properties for hover and disabled states have been correctly updated to use the new camelCase variable names. This change maintains consistency with the earlier variable renaming while preserving the existing functionality.
Also applies to: 59-60
65-67
: Approve SVG icon hover style updates with improved naming.The font weight, color, and fill properties for SVG icon hover states have been correctly updated to use the new camelCase variable names. The new variable names (e.g.,
--ti-Link-has-svg-hover-text-color
) are more specific, which improves clarity and maintainability.
72-74
: Approve disabled SVG icon style updates, query font weight choice.The color and fill properties for disabled SVG icon states have been correctly updated to use the new camelCase variable names. However, I noticed that the disabled state now uses the default font weight (
--ti-Link-font-weight
) instead of a specific disabled font weight.Is this intentional? If a different font weight is desired for the disabled state, consider creating a specific variable like
--ti-Link-disabled-font-weight
. Please confirm if this change in font weight behavior is intended.
82-82
: Approve underline style updates with full-width improvement.The underline styles have been updated correctly:
- The width is now set to 100%, ensuring the underline spans the full width of the link. This improves the visual consistency of the underline effect.
- The
border-bottom
property now uses the new camelCase variable name, maintaining consistency with the earlier variable renaming.These changes enhance both the appearance and the maintainability of the underline styles.
Also applies to: 88-88
106-109
: Approve link type mixin updates.The link type mixin has been correctly updated to use the new camelCase variable names for various states (default, hover, disabled). This change maintains consistency with the earlier variable renaming while preserving the existing functionality of the mixin.
115-118
: Approve primary link type mixin updates.The primary link type mixin has been correctly updated to use the new camelCase variable names for various states. This change is consistent with the earlier variable renaming and maintains the existing functionality of the mixin.
124-127
: Approve danger link type mixin updates.The danger link type mixin has been correctly updated to use the new camelCase variable names for various states. This change aligns with the earlier variable renaming and preserves the existing functionality of the mixin.
133-136
: Approve success, warning, and info link type mixin updates.The success, warning, and info link type mixins have all been correctly updated to use the new camelCase variable names for various states. These changes are consistent with the earlier variable renaming and maintain the existing functionality of each mixin. The uniform application of these updates across all link types demonstrates a thorough and consistent refactoring approach.
Also applies to: 142-145, 151-154
22-22
: Approve method renaming, verify implementation.The change from
.component-css-vars-link()
to.inject-Link-vars()
improves clarity and follows a more specific naming convention. This is a good refactoring step.Please ensure that the
.inject-Link-vars()
method is properly implemented and contains all the necessary CSS variables for the link component. Run the following script to verify the method's existence and content:#!/bin/bash # Description: Verify the implementation of .inject-Link-vars() method # Test: Search for the .inject-Link-vars() method definition rg --type less -A 10 '\.inject-Link-vars\s*\(\s*\)\s*{'
30-31
: Approve CSS variable renaming, verify global consistency.The update of CSS variable names from lowercase to camelCase format (e.g.,
--ti-link-*
to--ti-Link-*
) improves naming consistency. This is a positive change.To ensure all instances have been updated, please run the following script to check for any remaining lowercase versions of these variables:
#!/bin/bash # Description: Search for any remaining lowercase --ti-link-* variables # Test: Look for lowercase --ti-link-* variables rg --type less '--ti-link-[a-z-]+'If any results are found, they should be updated to maintain consistency across the codebase.
Also applies to: 34-36, 38-38
Line range hint
1-154
: Summary of link theme refactoringThe refactoring of the link theme has been successfully implemented with the following key points:
- CSS variables have been consistently renamed from lowercase to camelCase format (e.g.,
--ti-link-*
to--ti-Link-*
).- The method for injecting link variables has been renamed to
.inject-Link-vars()
.- Underline behavior has been improved with full-width underlining and specific handling for links with icons.
- All link types (default, primary, danger, success, warning, info) have been updated consistently.
These changes improve code consistency and maintainability without altering the component's functionality.
To ensure a complete and correct refactoring, please run the following final verification steps:
- Confirm that all
--ti-link-*
variables have been renamed:#!/bin/bash # Search for any remaining lowercase --ti-link-* variables in all less files rg --type less '--ti-link-[a-z-]+' packages/theme/src/
- Verify that the
.inject-Link-vars()
method is properly implemented:#!/bin/bash # Search for the .inject-Link-vars() method definition rg --type less -A 10 '\.inject-Link-vars\s*\(\s*\)\s*{' packages/theme/src/
- Check for any potential regressions by running the component's test suite, if available.
await expect(anchor).toHaveCSS('color', 'rgb(20, 118, 255)') | ||
await anchor.hover() | ||
await expect(await getAfter(6)).toBe('rgb(37, 43, 58)') | ||
await expect(anchor).toHaveCSS('color', 'rgb(92, 97, 115)') | ||
await expect(await getAfter(6)).toBe('rgb(20, 118, 255)') | ||
await expect(anchor).toHaveCSS('color', 'rgb(20, 118, 255)') |
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.
Consider differentiating info link color from default link color.
The color change for the info link to 'rgb(20, 118, 255)' is consistent across all states. However, this is the same color used for the default link, which might lead to the following issues:
- Users may not be able to distinguish between default and info links visually.
- It could create confusion about the purpose or importance of these links.
Consider using a distinct color for info links to improve user experience and maintain clear visual hierarchy. For example, you might use a different shade of blue or another color typically associated with information (like teal or cyan).
If this is an intentional design decision, please add a comment explaining the rationale to help future maintainers understand the context.
packages/theme/src/link/vars.less
Outdated
// 链接字重 | ||
--ti-link-font-weight: var(--ti-common-font-weight-4, normal); | ||
--ti-Link-font-weight: var(--tv-font-weight-regular); |
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.
tv开头
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