Skip to content
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(guide): [guide] refactor guide theme vars #2207

Merged
merged 1 commit into from
Sep 29, 2024

Conversation

zzcr
Copy link
Member

@zzcr zzcr commented Sep 29, 2024

PR

PR Checklist

Please check if your PR fulfills the following requirements:

  • The commit message follows our Commit Message Guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • Other... Please describe:

What is the current behavior?

Issue Number: N/A

What is the new behavior?

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

Summary by CodeRabbit

  • New Features
    • Updated naming convention for theme variables to enhance consistency and clarity.
    • Simplified CSS variable definitions for improved styling of the guide component.
  • Bug Fixes
    • Adjusted hover and disabled states for buttons and icons to ensure proper functionality.
  • Refactor
    • Reorganized CSS variable structure for better maintainability and readability.

Copy link

coderabbitai bot commented Sep 29, 2024

Walkthrough

The pull request introduces significant changes to the CSS variable naming conventions within the theme's guide component. It replaces the prefix --ti- with --tv- for consistency and updates the method for injecting CSS variables. Additionally, the definitions of various style-related variables have been simplified or removed, indicating a potential redesign of the component's layout and styling approach.

Changes

File Path Change Summary
packages/theme/src/guide/index.less, packages/theme/src/guide/vars.less Renamed CSS variables from --ti- to --tv-, updated method calls from .component-css-vars-guide() to .inject-Guide-vars(), and simplified or removed variable definitions related to styling.

Possibly related PRs

Suggested labels

refactoring

Poem

🐰 In the garden where styles bloom,
Variables dance, dispelling gloom.
From --ti- to --tv-, they twirl with grace,
A fresh new look for our lovely space.
With each change, a hop and a cheer,
The guide shines bright, our vision is clear! 🌼


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?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions github-actions bot added the refactoring Refactoring (重构) label Sep 29, 2024
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🧹 Outside diff range and nitpick comments (4)
packages/theme/src/guide/index.less (2)

35-47: LGTM. Consider using variables for padding values.

The changes in the .shepherd-header class are well-implemented:

  1. CSS variable names have been consistently updated from --ti- to --tv-.
  2. Explicit padding values have been set, which improves consistency.

Consider using CSS variables for padding values (line 40) to maintain flexibility and consistency with the overall theming approach. For example:

-  padding: 24px 24px 0;
+  padding: var(--tv-Guide-header-padding-top) var(--tv-Guide-header-padding-horizontal) 0;

This would allow for easier theme customization in the future.


287-287: LGTM. Consistent variable renaming, but note duplication.

The change in the .@{guide-prefix-cls}__z-top class is correct:

  • The background color variable has been updated from --ti- to --tv-, maintaining consistency with the overall variable renaming strategy.

This change appears to be a duplicate of the one made on line 185. Consider reviewing if both instances are necessary or if one can be removed to avoid redundancy.

packages/theme/src/guide/vars.less (2)

29-29: Rename variable to remove redundancy in 'text-text-color'.

The variable --tv-Guide-text-text-color contains a redundant 'text-text' in its name. Renaming it to --tv-Guide-text-color would improve clarity and maintain consistency with naming conventions.

Apply this diff to rename the variable:

-  --tv-Guide-text-text-color: var(--tv-color-text-secondary);
+  --tv-Guide-text-color: var(--tv-color-text-secondary);

45-45: Clarify variable name by specifying 'border-color'.

The variable --tv-Guide-button-border may be ambiguous, as it doesn't specify the border property it represents. Renaming it to --tv-Guide-button-border-color enhances clarity and aligns with other variables like --tv-Guide-button-hover-border-color.

Apply this diff to rename the variable:

-  --tv-Guide-button-border: var(--tv-color-border-secondary);
+  --tv-Guide-button-border-color: var(--tv-color-border-secondary);
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 41f9ca8 and f23384f.

📒 Files selected for processing (2)
  • packages/theme/src/guide/index.less (7 hunks)
  • packages/theme/src/guide/vars.less (1 hunks)
🔇 Additional comments (13)
packages/theme/src/guide/index.less (12)

6-6: LGTM. Verify the new injection method.

The change from .component-css-vars-guide() to .inject-Guide-vars() looks good. The new method name is more specific and follows a clearer naming convention.

Please ensure that the .inject-Guide-vars() method is properly defined and working as expected in the relevant files.


9-19: LGTM. Consistent variable renaming and improved flexibility.

The changes in the .shepherd-arrow class are well-implemented:

  1. CSS variable names have been consistently updated from --ti- to --tv-.
  2. The use of calc() for arrow dimensions (height and width) allows for more flexible sizing.

These changes improve consistency and maintainability.


66-79: LGTM. Improved cancel icon styling and customization.

The changes in the .shepherd-cancel-icon class are well-implemented:

  1. Margin values have been updated to improve positioning.
  2. New styles for the SVG icon have been added, using CSS variables for dimensions and colors.
  3. Hover styles for the SVG icon have been updated, also using CSS variables.

These changes enhance the customization options for the cancel icon and maintain consistency with the overall theming approach.


85-106: LGTM. Improved text styling and scrollbar customization.

The changes in the .shepherd-text class are well-implemented:

  1. CSS variable names have been consistently updated from --ti- to --tv-.
  2. Padding has been adjusted to improve the layout (line 88).
  3. Scrollbar styles have been refined, including width, height, and border color customization.

These changes enhance the appearance and usability of the text area while maintaining consistency with the overall theming approach.


Line range hint 120-136: LGTM. Improved footer styling and layout.

The changes in the .shepherd-footer class are well-implemented:

  1. CSS variable names have been consistently updated from --ti- to --tv-.
  2. Border radius variables have been applied to improve customization options.
  3. Padding and positioning values have been adjusted to enhance the layout.

These changes improve the footer's appearance and maintain consistency with the overall theming approach.


141-159: LGTM. Enhanced button customization options.

The changes in the .shepherd-button class are well-implemented:

  1. CSS variable names have been consistently updated from --ti- to --tv-.
  2. New variables for button dimensions, colors, and styles have been introduced, improving customization options.
  3. Hover and disabled states have been updated to use the new variables.

These changes significantly enhance the button's customization possibilities while maintaining consistency with the overall theming approach.


165-168: LGTM. Improved readability and layout adjustment.

The changes in the .only-content class are appropriate:

  1. An empty line has been added, improving code readability.
  2. Setting padding-top: 0 for the header in the .only-content case adjusts the layout when only content is displayed.

These changes enhance code organization and provide better control over the component's appearance in different scenarios.


185-185: LGTM. Consistent variable renaming.

The change in the .@{guide-prefix-cls}__z-top class is correct:

  • The background color variable has been updated from --ti- to --tv-, maintaining consistency with the overall variable renaming strategy.

This change ensures that the z-top element's background color remains customizable through the new variable naming convention.


190-190: LGTM. Consistent variable renaming.

The change in the .shepherd-element.shepherd-has-title[data-popper-placement^='bottom'] selector is correct:

  • The background color variable has been updated from --ti- to --tv-, maintaining consistency with the overall variable renaming strategy.

This change ensures that the arrow's background color for bottom-placed elements with titles remains customizable through the new variable naming convention.


197-203: LGTM. Consistent variable renaming.

The changes in the .shepherd-element class are correct:

  1. The background color variable has been updated from --ti- to --tv-.
  2. The border-radius variable has been updated from --ti- to --tv-.

These changes maintain consistency with the overall variable renaming strategy, ensuring that the shepherd element's background color and border-radius remain customizable through the new variable naming convention.


228-240: LGTM. Consistent variable renaming for arrow positioning.

The changes in the arrow positioning for different placements are correct:

  • The arrow width variable has been updated from --ti- to --tv- for all placements (top, bottom, left, right).
  • The use of calc() for arrow positioning remains unchanged, maintaining the existing layout logic.

These changes ensure consistency with the overall variable renaming strategy while preserving the correct arrow positioning for various element placements.


Line range hint 1-287: Overall LGTM. Comprehensive variable renaming and minor improvements.

This refactoring of the guide theme variables is well-executed:

  1. CSS variables have been consistently renamed from --ti- to --tv- throughout the file.
  2. Minor adjustments to padding, layout, and styles have been made, improving the overall appearance and customization options.
  3. The changes maintain the existing functionality while enhancing theme consistency.

The refactoring improves code maintainability and aligns with what appears to be a broader effort to standardize variable naming conventions.

To ensure the changes haven't introduced any unintended side effects, please:

  1. Verify that all components using these variables have been updated accordingly.
  2. Run visual regression tests to confirm that the guide's appearance remains consistent with the previous version.
  3. Check if there's any documentation that needs to be updated to reflect these variable name changes.
packages/theme/src/guide/vars.less (1)

1-1: Ensure all references to the old mixin .component-css-vars-guide() are updated.

The mixin name has been changed from .component-css-vars-guide() to .inject-Guide-vars(). To prevent any issues, please verify that all instances of the old mixin are updated throughout the codebase.

Run the following script to find any remaining references to the old mixin:

✅ Verification successful

All references to the old mixin .component-css-vars-guide() have been successfully updated throughout the codebase.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Find usages of the old mixin `.component-css-vars-guide()`

# Test: Search for occurrences of the old mixin in LESS files. Expect: No matches.
rg --type less '\.component-css-vars-guide\('

Length of output: 47


Script:

#!/bin/bash
# Description: Find usages of the old mixin `.component-css-vars-guide()` using ast-grep

ast-grep --lang less --pattern "
  mixin_usage:Mixin(.component-css-vars-guide) {
    $$$
  }
"

Length of output: 209


Script:

#!/bin/bash
# Description: Find usages of the old mixin `.component-css-vars-guide()` using fd and grep

fd --type f --extension less --exec grep -H '\.component-css-vars-guide\(' {} +

Length of output: 17315


Script:

#!/bin/bash
# Description: Find usages of the old mixin `.component-css-vars-guide()` using fd and grep -F

fd --type f --extension less --exec grep -FH '.component-css-vars-guide(' {} +

Length of output: 25212


Script:

#!/bin/bash
# Description: Find usages of the old mixin `.component-css-vars-guide()` using fd and xargs with grep -F

fd --type f --extension less | xargs grep -FH '.component-css-vars-guide('

Length of output: 76

// 分页提示文字颜色
--ti-guide-progresss-text-color: #808080;
--tv-Guide-progresss-text-color: var(--tv-color-text-weaken);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Fix typo in variable name 'progresss' (extra 's').

The variable --tv-Guide-progresss-text-color has an extra 's' in 'progress'. Correcting the typo ensures that styles apply correctly without causing any errors.

Apply this diff to fix the typo:

-  --tv-Guide-progresss-text-color: var(--tv-color-text-weaken);
+  --tv-Guide-progress-text-color: var(--tv-color-text-weaken);
📝 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.

Suggested change
--tv-Guide-progresss-text-color: var(--tv-color-text-weaken);
--tv-Guide-progress-text-color: var(--tv-color-text-weaken);

// 引导框按钮宽度
--ti-guide-button-width: calc(var(--ti-common-line-height-8, 60px) + 8px);
--tv-Guide-button-width: 68px;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Replace hardcoded button width with a variable for consistency.

The button width is set to 68px. Utilizing a size variable enhances maintainability and adherence to the design system.

Apply this diff to use a size variable:

-  --tv-Guide-button-width: 68px;
+  --tv-Guide-button-width: var(--tv-size-width-sm);
📝 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.

Suggested change
--tv-Guide-button-width: 68px;
--tv-Guide-button-width: var(--tv-size-width-sm);

Comment on lines +3 to +5
--tv-Guide-arrow-height: 16px;
// 引导框箭头宽度
--ti-guide-arrow-width: var(--ti-common-size-4x, 16px);
// 引导框头部左上边框圆角
--ti-guide-header-border-top-left-radius: var(--ti-common-border-radius-4, 8px);
// 引导框头部右上边框圆角
--ti-guide-header-border-top-right-radius: var(--ti-common-border-radius-4, 8px);
--tv-Guide-arrow-width: 16px;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Consider using existing size variables instead of hardcoded values for arrow dimensions.

The arrow height and width are set to 16px directly. To maintain consistency and ease future theming adjustments, consider using predefined variables like --tv-size-md.

Apply this diff to use size variables:

-  --tv-Guide-arrow-height: 16px;
-  --tv-Guide-arrow-width: 16px;
+  --tv-Guide-arrow-height: var(--tv-size-md);
+  --tv-Guide-arrow-width: var(--tv-size-md);
📝 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.

Suggested change
--tv-Guide-arrow-height: 16px;
// 引导框箭头宽度
--ti-guide-arrow-width: var(--ti-common-size-4x, 16px);
// 引导框头部左上边框圆角
--ti-guide-header-border-top-left-radius: var(--ti-common-border-radius-4, 8px);
// 引导框头部右上边框圆角
--ti-guide-header-border-top-right-radius: var(--ti-common-border-radius-4, 8px);
--tv-Guide-arrow-width: 16px;
--tv-Guide-arrow-height: var(--tv-size-md);
// 引导框箭头宽度
--tv-Guide-arrow-width: var(--tv-size-md);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactoring Refactoring (重构)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant