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

Merged
merged 2 commits into from
Oct 19, 2024

Conversation

zzcr
Copy link
Member

@zzcr zzcr commented Oct 18, 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 Popeditor component, enhancing visual consistency and control.
    • Introduced a new naming convention for CSS variables, improving clarity and organization.
  • Bug Fixes
    • Adjusted padding, margin, and alignment settings for a more polished appearance.
  • Refactor
    • Consolidated and refined the structure of the Popeditor component's styles, focusing on fixed values and new variable usage.

Copy link

coderabbitai bot commented Oct 18, 2024

Walkthrough

The pull request introduces significant updates to the popeditor component's styling by modifying the LESS files. Key changes include the replacement of a mixin for injecting CSS variables, adjustments to padding and margin values, and a shift from --ti- to --tv- prefixes for various CSS variables. The updates refine the component's structure and visibility settings, ensuring a consistent appearance with new styles and improved control over the component's design.

Changes

File Path Change Summary
packages/theme/src/popeditor/index.less - Replaced .component-css-vars-popeditor() with .inject-Popeditor-vars().
- Adjusted padding, margin, text alignment, and width for various elements.
- Updated color variables from --ti- to --tv- prefix.
- Refined component structure with fixed values and visibility settings.
packages/theme/src/popeditor/vars.less - Renamed several CSS variables from --ti- to --tv- prefix.
- Removed certain variables related to margins and paddings.
- Maintained overall structure while focusing on variable name updates.
examples/sites/demos/pc/app/popeditor/size-composition-api.vue - Adjusted the ordering of tiny-popeditor component instances without changing attributes or functionality.
examples/sites/demos/pc/app/popeditor/size.vue - Made nominal changes to tiny-popeditor size attributes that did not affect functionality or structure.

Possibly related PRs

🐰 In the meadow, colors bright,
The popeditor shines with new light.
Variables renamed, styles refined,
A hop and a skip, all perfectly aligned!
With padding and margins set just right,
Our component now feels so light! 🌼


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 18, 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: 12

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between bc0ffc5 and 8a0b982.

📒 Files selected for processing (2)
  • packages/theme/src/popeditor/index.less (11 hunks)
  • packages/theme/src/popeditor/vars.less (1 hunks)
🧰 Additional context used
🔇 Additional comments (17)
packages/theme/src/popeditor/vars.less (1)

13-39: Consistent renaming of CSS variables and mixin

The changes in this file show a systematic update of CSS variable names from the --ti- prefix to --tv-. This change appears to be part of a larger refactoring effort to standardize variable naming across the project. The mixin name has also been updated to .inject-Popeditor-vars(), which aligns with the new naming convention.

A few points to consider:

  1. The consistency in renaming is commendable and should help maintain a uniform codebase.
  2. The comments for each variable have been retained, which is good for code readability and maintainability.
  3. Some variable values have been updated to use the new --tv- prefix, ensuring internal consistency.

To ensure that these changes don't introduce any unintended side effects, please run the following verification script:

This script will help identify any inconsistencies in the renaming process across the codebase.

packages/theme/src/popeditor/index.less (16)

23-23: Use of new mixin .inject-Popeditor-vars()

Including .inject-Popeditor-vars(); ensures that the component correctly injects the updated Popeditor variables, aligning with the new theming approach.


45-45: Update icon fill color to use theme variable

Changing to fill: var(--tv-Popeditor-icon-color-disabled); aligns the disabled icon color with the new theme variables.


56-56: Update icon fill color for disabled state

Consistently using fill: var(--tv-Popeditor-icon-color-disabled); ensures the disabled icons adhere to the theme.


82-82: Update icon hover fill color to theme variable

Setting fill: var(--tv-Popeditor-icon-color-hover); for hover states keeps the icon colors consistent with the theme.


92-95: Use theme variables for icon styling

Applying theme variables for height, line-height, font-size, and fill improves consistency and maintainability.


99-99: Update icon hover fill color

Consistently using fill: var(--tv-Popeditor-icon-color-hover); for hover effects aligns with the theme.


127-127: Set text alignment to left for search labels

Ensuring text-align: left; for .@{popeditor-prefix-cls}__search-label maintains consistent label alignment.


130-130: Use theme variable for search item width

Applying width: var(--tv-Popeditor-search-item-width); promotes consistency and easy theming.


182-182: Reset padding for tabs head

Setting padding: 0; ensures there is no unintended spacing in the tabs header.


184-184: Set tabs head height using theme variable

Using height: var(--tv-Popeditor-tabs-li-height); promotes consistent sizing across components.


189-189: Use theme variable for tabs list height

Applying height: var(--tv-Popeditor-tabs-li-height); ensures uniformity in tab dimensions.


201-202: Use theme variables for line-height and font-size in tabs

Applying line-height and font-size theme variables promotes consistency in text styling.


205-207: Apply theme variables for selected tab styling

Using variables for color, border-bottom, and font-weight ensures consistent highlighting of selected tabs.


236-236: Ensure visibility of input prefix

Setting visibility: visible; for .tiny-input__prefix ensures the prefix icon is displayed as intended.


240-240: Hide input suffix as intended

Applying visibility: hidden; to .tiny-input__suffix correctly hides the suffix element.


251-251: Include Popeditor variables in dialog box

Adding .inject-Popeditor-vars(); ensures the dialog box uses the updated theme variables.


.@{input-prefix-cls} {
&.@{popeditor-prefix-cls}-readonly .@{input-prefix-cls}__inner {
padding-left: var(--ti-popeditor-input-padding-left);
padding-left: 8px;
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 a variable for padding-left

Hardcoding padding-left: 8px; reduces flexibility. Using a variable allows for easier theming and future adjustments.

@@ -122,21 +121,21 @@
display: flex;
justify-content: flex-end;
align-items: center;
margin-bottom: var(--ti-popeditor-search-item-margin-bottom);
margin-bottom: 24px;
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 a variable for margin-bottom

Using margin-bottom: 24px; directly may limit flexibility. A variable would allow for easier theme adjustments.

}

&:nth-child(2n + 1) {
padding-right: var(--ti-popeditor-search-item-padding-right);
padding-right: 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 a variable for padding-right

Hardcoding padding-right: 16px; may reduce adaptability. A variable would enhance theme flexibility.

}

&:nth-child(2n) {
padding-left: var(--ti-popeditor-search-item-padding-left);
padding-left: 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 a variable for padding-left

Using a variable instead of padding-left: 16px; can improve maintainability and theming capabilities.

Comment on lines +149 to +150
text-align: right;
margin: 0 auto 24px;
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 variables for text-align and margin

Replacing text-align: right; and margin: 0 auto 24px; with theme variables can enhance consistency.

Comment on lines +197 to +200
padding: 0 32px 0 0;
color: var(--tv-Popeditor-tabs-text-color);
min-width: 90px;
height: var(--ti-popeditor-tabs-li-height);
line-height: var(--ti-popeditor-tabs-li-line-height);
font-size: var(--ti-popeditor-tabs-font-size);
margin-right: var(--ti-popeditor-tabs-li-margin-right);
height: var(--tv-Popeditor-tabs-li-height);
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 variables for padding and min-width in tabs

Using variables instead of padding: 0 32px 0 0; and min-width: 90px; can enhance maintainability and theming flexibility.

}
}
}
}

.@{popeditor-prefix-cls}__tabs-body {
.tabs-body-item {
padding: var(--ti-popeditor-tabs-body-item-padding-top) var(--ti-popeditor-tabs-body-item-padding-horizontal)
var(--ti-popeditor-tabs-body-item-padding-bottom);
padding: 16px 0 0;
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 a variable for padding in tab body

Replacing padding: 16px 0 0; with a theme variable can improve maintainability.


.@{pager-prefix-cls} {
padding-top: var(--ti-popeditor-pager-padding-top);
padding-top: 12px;
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 a variable for padding-top in pager

Using padding-top: 12px; directly may reduce flexibility. A variable would allow for consistent theming.

Comment on lines +230 to +232
.tiny-input__inner {
padding-left: 28px;
padding-right: 8px;
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 variables for padding in .tiny-input__inner

Hardcoding padding-left: 28px; and padding-right: 8px; limits theming capabilities. Variables would enhance flexibility.

Comment on lines +254 to +255
text-align: right;
padding-top: 24px;
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 a variable for padding-top in dialog footer

Using padding-top: 24px; directly may limit flexibility. A variable allows for better theme customization.

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: 0

🧹 Outside diff range and nitpick comments (1)
examples/sites/demos/pc/app/popeditor/size-composition-api.vue (1)

Line range hint 21-28: LGTM! Consider reordering for consistency.

The reordering of the tiny-popeditor components doesn't affect functionality and is acceptable. However, for better consistency and readability, consider arranging the components in a logical order based on their sizes.

You might want to consider the following order:

  1. mini
  2. small
  3. default (no size specified)
  4. medium

This would provide a clear visual progression from smallest to largest size.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 8a0b982 and 70ca32b.

📒 Files selected for processing (2)
  • examples/sites/demos/pc/app/popeditor/size-composition-api.vue (1 hunks)
  • examples/sites/demos/pc/app/popeditor/size.vue (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • examples/sites/demos/pc/app/popeditor/size.vue
🧰 Additional context used

@kagol kagol merged commit 94783bc into dev Oct 19, 2024
6 checks passed
@kagol kagol deleted the refactor-popeditor-theme-vars branch November 4, 2024 06:16
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