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(popconfirm): [popconfirm] refactor theme vars #2282

Merged
merged 2 commits into from
Oct 16, 2024
Merged

Conversation

Youyou-smiles
Copy link
Collaborator

@Youyou-smiles Youyou-smiles commented Oct 16, 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 styling for the popconfirm component with new CSS variables for improved consistency and customization.
    • Introduced new variables for the confirm button margin and icon fill colors for different states.
  • Bug Fixes

    • Resolved inconsistencies in padding, font sizes, colors, and margins across various sub-elements of the popconfirm component.

Copy link

coderabbitai bot commented Oct 16, 2024

Walkthrough

The changes in this pull request focus on the popconfirm component's styling by updating the naming conventions and values of CSS variables across two files: index.less and vars.less. The mixin for injecting CSS variables has been renamed, and several variables have transitioned from the ti- prefix to the tv- prefix, affecting various properties such as padding, font sizes, and colors. Additionally, new variables have been introduced for button margins and icon fill colors.

Changes

File Path Change Summary
packages/theme/src/popconfirm/index.less - Replaced mixin .component-css-vars-popconfirm() with .inject-Popconfirm-vars().
- Updated CSS properties to use new variable names prefixed with tv- instead of ti-.
- Adjusted padding, font sizes, colors, and margins for various sub-elements.
- Updated __confirm-button to use a variable for left margin.
packages/theme/src/popconfirm/vars.less - Changed function name from .component-css-vars-popconfirm() to .inject-Popconfirm-vars().
- Renamed CSS variables from --ti- to --tv- prefix, including line heights, font sizes, colors, padding, and margins.
- Added new CSS variables for confirm button margin and icon fill colors for different states.

Possibly related PRs

Suggested reviewers

  • zzcr

🐇 In the meadow, colors bright,
CSS changes bring delight.
From ti- to tv-, a fresh new start,
Popconfirm's style, a work of art.
With margins set and buttons neat,
Hopping forward, we can't be beat! 🌼


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 122eebb and 9ffe80f.

📒 Files selected for processing (1)
  • packages/theme/src/popconfirm/vars.less (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/theme/src/popconfirm/vars.less

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 Oct 16, 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: 1

🧹 Outside diff range and nitpick comments (2)
packages/theme/src/popconfirm/vars.less (1)

15-40: Standardize CSS variable naming convention

While the prefix --tv-Popconfirm- is consistently used, there's an inconsistency in the naming convention for the rest of the variable names. Some use kebab-case (e.g., popover-title-line-height), while others use camelCase (e.g., popoverTitleLineHeight). It's recommended to standardize this for better maintainability and consistency.

Consider using kebab-case for all variable names, as it's more common in CSS. For example:

--tv-Popconfirm-popover-title-line-height
--tv-Popconfirm-popover-content-line-height
--tv-Popconfirm-popover-footer-font-size
// ... and so on
packages/theme/src/popconfirm/index.less (1)

48-51: Approve icon styling updates and suggest documentation review.

The addition of fixed dimensions for the icon (20px x 20px) ensures consistent sizing, while the use of CSS variables for margins improves customizability. These changes enhance both the consistency and flexibility of the component.

Consider updating the component documentation to reflect these new styling options, particularly the ability to customize icon margins through CSS variables.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between ade7165 and 122eebb.

📒 Files selected for processing (2)
  • packages/theme/src/popconfirm/index.less (3 hunks)
  • packages/theme/src/popconfirm/vars.less (1 hunks)
🧰 Additional context used
🔇 Additional comments (14)
packages/theme/src/popconfirm/vars.less (8)

13-13: LGTM: Improved function naming

The function name change from .component-css-vars-popconfirm() to .inject-Popconfirm-vars() is a good improvement. It's more descriptive and consistent with the component name.


15-17: LGTM: Consistent line height variables

The changes to the title and content line height variables are good. They now follow the new naming convention and use a consistent value var(--tv-line-height-number).


19-21: LGTM: Improved font size and color variables

The updates to footer font size and color variables are good. They now use global theme variables, which improves consistency and makes future theme changes easier.


23-28: LGTM: Consistent spacing variables

The changes to padding and margin variables are good. They now follow the new naming convention and use global spacing variables, which improves consistency across the theme.


30-32: LGTM: Improved title style variables

The updates to title style variables (font size, weight, and color) are good. They now use global theme variables, which improves consistency and makes future theme changes easier.


34-35: LGTM: Updated margin variables and new confirm button margin

The changes to margin variables are good. They now follow the new naming convention and use global spacing variables. The addition of --tv-Popconfirm-popover-confirm-button-margin-left is a nice improvement for more granular control over the layout.


37-40: LGTM: New icon fill color variables

The addition of icon fill color variables for different states (info, error, warning, success) is a great improvement. This allows for more granular control over the appearance of icons and ensures consistency with the global color scheme.


13-40: Verify impact of variable renaming across the codebase

The extensive renaming of variables from --ti- to --tv- prefix and the changes in referenced global theme variables may have a widespread impact on the codebase. It's crucial to ensure that all references to these variables are updated accordingly.

Please run the following script to identify any remaining references to the old variable names:

This will help identify any places where the old variable names are still in use and need to be updated.

✅ Verification successful

Please run the following updated script to accurately search for old and new variable names across .less, .js, and .vue files:


Variable renaming fully verified

No remaining references to the old variable names (--ti-popconfirm) were found. All references have been successfully updated to --tv-Popconfirm.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Search for any remaining references to old variable names

# Test: Search for old variable names
echo "Searching for old variable names..."
rg --type less --type vue --type js '\-\-ti\-popconfirm'

# Test: Verify new variable usage
echo "Verifying new variable usage..."
rg --type less --type vue --type js '\-\-tv\-Popconfirm'

echo "Please review the results and update any remaining references to old variable names."

Length of output: 506


Script:

#!/bin/bash
# Description: Search for any remaining references to old and verify new variable names

# Search for old variable names
echo "Searching for old variable names..."
rg '\-\-ti\-popconfirm' -g '*.less' -g '*.js' -g '*.vue'

# Verify new variable usage
echo "Verifying new variable usage..."
rg '\-\-tv\-Popconfirm' -g '*.less' -g '*.js' -g '*.vue'

echo "Please review the results and update any remaining references to old variable names."

Length of output: 4011

packages/theme/src/popconfirm/index.less (6)

44-44: Approve margin-bottom variable update.

The change to use a CSS variable for the margin-bottom property of the popconfirm header is consistent with the new naming convention and improves the component's customizability.


55-57: Approve title and content styling variable updates.

The transition to using CSS variables with the tv- prefix for all title and content styling properties is consistent with the new naming convention. This change enhances the component's customizability and maintains a uniform approach to styling across the component.

Also applies to: 61-62


72-72: Approve confirm button margin update.

The use of a CSS variable for the margin-left property of the confirm button is consistent with the new naming convention and improves the component's customizability.


20-20: Approve mixin renaming and suggest usage verification.

The mixin renaming from .component-css-vars-popconfirm() to .inject-Popconfirm-vars() improves clarity and consistency. This change aligns with best practices for naming conventions.

To ensure this change doesn't break any existing imports or usage, please run the following script:

✅ Verification successful

Mixin renaming verified successfully.

The old mixin component-css-vars-popconfirm is no longer present in the codebase, and the new mixin inject-Popconfirm-vars is used consistently in the following files:

  • packages/theme/src/popconfirm/vars.less
  • packages/theme/src/popconfirm/index.less
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of the renamed mixin across the codebase.

# Test: Search for any remaining usage of the old mixin name
rg --type less "component-css-vars-popconfirm"

# Test: Confirm the new mixin name is used consistently
rg --type less "inject-Popconfirm-vars"

Length of output: 294


81-81: Approve icon fill color updates and suggest theme consistency check.

The transition to using CSS variables with the tv- prefix for all icon fill colors is consistent with the new naming convention. This change enhances the component's customizability for different states (info, error, warning, success).

To ensure color consistency across different themes, please run the following script:

Also applies to: 85-85, 89-89, 93-93

✅ Verification successful

Icon fill color updates verified successfully.

All fill properties in packages/theme/src/popconfirm/index.less now consistently use the tv- prefixed CSS variables. This standardization ensures enhanced customizability and maintains consistency across different states (info, error, warning, success).

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the consistency of icon fill colors across themes.

# Test: Check the values assigned to these variables in different theme files
rg --type less "tv-Popconfirm-icon-(info|error|warning|success)-fill"

Length of output: 2149


Script:

#!/bin/bash
# Description: Verify the consistency of icon fill colors across all theme files.

# Search for the usage of the new tv-Popconfirm-icon-* fill variables in all .less files
rg --type less "var\(--tv-Popconfirm-icon-(info|error|warning|success)-fill\)" packages/theme/src/

Length of output: 459


36-38: Approve CSS variable renaming and suggest comprehensive check.

The update of CSS variable names from ti- prefix to tv- prefix for the popover container styling improves consistency across the component library. This change aligns with the new naming convention while maintaining the same styling functionality.

To ensure all variables have been updated consistently, please run the following script:

✅ Verification successful

CSS variable renaming verified successfully.

All instances of ti- prefixed variables have been removed, and the tv- prefix is used consistently across the popconfirm package. The renaming enhances consistency within the component library without affecting styling functionality.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the consistent usage of the new CSS variable prefix.

# Test: Search for any remaining `ti-` prefixed variables in this file
rg --type less "var\(--ti-" packages/theme/src/popconfirm/index.less

# Test: Confirm the new `tv-` prefix is used consistently
rg --type less "var\(--tv-" packages/theme/src/popconfirm/index.less

Length of output: 2149


Script:

#!/bin/bash
# Description: Verify the absence of `ti-` prefixed variables and confirm consistent usage of `tv-` prefixes in the popconfirm package.

# Test 1: Search for any remaining `ti-` prefixed variables in the popconfirm package
rg --type less "var\(--ti-" packages/theme/src/popconfirm/

# Test 2: Confirm the consistent usage of `tv-` prefixes across the popconfirm package
rg --type less "var\(--tv-" packages/theme/src/popconfirm/

Length of output: 3682

Comment on lines +67 to +68
justify-content: right;
margin-top: var(--tv-Popconfirm-popover-footer-margin-top);
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Approve margin-top update, but justify-content value needs correction.

The use of a CSS variable for margin-top is consistent with the new naming convention and improves customizability. However, the justify-content property has an invalid value.

The justify-content: right is not a valid CSS value. Please update it to a valid value, such as flex-end or end. Here's the suggested fix:

-    justify-content: right;
+    justify-content: flex-end;
📝 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
justify-content: right;
margin-top: var(--tv-Popconfirm-popover-footer-margin-top);
justify-content: flex-end;
margin-top: var(--tv-Popconfirm-popover-footer-margin-top);

--tv-Popconfirm-icon-info-fill: var(--tv-color-info-text);
--tv-Popconfirm-icon-error-fill: var(--tv-color-error-text);
--tv-Popconfirm-icon-warning-fill: var(--tv-color-warning-text);
--tv-Popconfirm-icon-success-fill: var(--tv-color-success-text);
Copy link
Member

Choose a reason for hiding this comment

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

以上四个明明图标填充色,为啥要用字体颜色呢?改成:--tv-color-info-icon、--tv-color-error-icon、--tv-color-warn-icon、--tv-color-success-icon

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.

2 participants