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(rich-text-editor): refactor rich-text-editor style #2346

Merged
merged 1 commit into from
Oct 22, 2024

Conversation

gimmyhehe
Copy link
Member

@gimmyhehe gimmyhehe commented Oct 22, 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 rich text editor to enhance visual consistency with new CSS variables.
    • Improved hover and disabled states for toolbar buttons.
  • Bug Fixes
    • Resolved inconsistencies in variable references for various editor elements, ensuring a cohesive theme.
  • Chores
    • Removed outdated CSS variables and replaced them with new ones to align with the updated theming strategy.

@gimmyhehe gimmyhehe added the refactoring Refactoring (重构) label Oct 22, 2024
Copy link

coderabbitai bot commented Oct 22, 2024

Walkthrough

The changes in this pull request focus on updating the CSS variable references in the rich text editor's styling files. The index.less file has been modified to use new variable prefixes, improving consistency across the editor's styles. The vars.less file has seen the removal of outdated variable definitions and the introduction of new ones, aligning with a broader theming strategy. These updates enhance maintainability and ensure a cohesive design throughout the rich text editor component.

Changes

File Path Change Summary
packages/theme/src/rich-text-editor/index.less Updated CSS variable references for styling elements and toolbar, modified hover and disabled states.
packages/theme/src/rich-text-editor/vars.less Removed outdated CSS variables prefixed with --ti-rich-text-editor- and introduced new variables prefixed with --tv-RichTextEditor-.

Possibly related PRs

Suggested reviewers

  • zzcr

Poem

In the garden of code where the variables play,
New colors and styles bloom bright every day.
With a hop and a skip, the editor shines,
Consistency reigns in its well-dressed designs.
So let’s cheer for the changes, both fresh and anew,
A theme full of joy, just waiting for you! 🐇✨


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.

Copy link

[e2e-test-warn]
The component to be tested is missing.

The title of the Pull request should look like "fix(vue-renderless): [action-menu, alert] fix xxx bug".

Please make sure you've read our contributing guide

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/rich-text-editor/vars.less (1)

4-5: LGTM: Consistent naming and reuse of global variable. Consider updating the comment.

The new variable --tv-RichTextEditor-line-height follows the updated naming convention and reuses the global --tv-line-height-number variable, promoting consistency.

Consider updating the comment "富文本行号" (rich text line number) to "富文本行高" (rich text line height) for clarity, as this variable sets the line height, not a line number.

packages/theme/src/rich-text-editor/index.less (1)

646-646: Consider using a CSS variable for image handle background color

The background color for the image handle has been set to a hardcoded value #d2e4ff. To maintain consistency with the rest of the component and improve theming flexibility, consider using a CSS variable instead.

Suggestion:

- background: #d2e4ff;
+ background: var(--tv-RichTextEditor-image-handle-bg-color, #d2e4ff);

Don't forget to add this new variable to the vars.less file.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between ade6d45 and a320cef.

📒 Files selected for processing (2)
  • packages/theme/src/rich-text-editor/index.less (8 hunks)
  • packages/theme/src/rich-text-editor/vars.less (1 hunks)
🧰 Additional context used
🔇 Additional comments (15)
packages/theme/src/rich-text-editor/vars.less (7)

3-3: LGTM: Consistent naming and reuse of global variable.

The new variable --tv-RichTextEditor-border-color follows the updated naming convention and reuses the global --tv-color-border variable, promoting consistency across the theme.


6-7: LGTM: Consistent naming and reuse of global variable.

The new variable --tv-RichTextEditor-icon-color-hover follows the updated naming convention and reuses the global --tv-color-icon-hover variable, ensuring consistency with the overall theme for hover states.


8-9: LGTM: Consistent naming and reuse of global variable.

The new variable --tv-RichTextEditor-icon-color-disabled follows the updated naming convention and reuses the global --tv-color-icon-disabled variable, ensuring consistency with the overall theme for disabled states.


13-13: LGTM: Consistent naming and reuse of global variable.

The new variable --tv-RichTextEditor-options-box-shadow follows the updated naming convention and reuses the global --tv-shadow-3-down variable, ensuring consistency with the overall theme for shadow effects.


15-15: LGTM: Consistent naming and reuse of global variable.

The new variable --tv-RichTextEditor-options-border-radius follows the updated naming convention and reuses the global --tv-border-radius-md variable, ensuring consistency with the overall theme for border radius values.


16-19: LGTM: Consistent naming and reuse of global variables.

The new variables --tv-RichTextEditor-options-text-color and --tv-RichTextEditor-options-item-bg-color follow the updated naming convention and reuse global variables (--tv-color-text and --tv-color-bg-hover respectively). This ensures consistency with the overall theme for text colors and hover background colors.


1-19: Overall, excellent refactoring of rich-text-editor variables.

This refactoring significantly improves the consistency and maintainability of the rich-text-editor component. The new variable naming convention (--tv-RichTextEditor-*) and the extensive use of global theme variables enhance the component's integration with the overall theme system.

Key improvements:

  1. Consistent naming convention across all variables.
  2. Increased use of global theme variables, promoting better theme cohesion.
  3. Clear separation of concerns for different aspects of the rich-text-editor (border, icons, options, etc.).

These changes align well with the PR objectives of refactoring the rich-text-editor style. The only minor suggestions are to update a comment for clarity and consider using a global variable for the options background color.

Great work on this refactoring!

packages/theme/src/rich-text-editor/index.less (8)

64-64: LGTM: Updated border color variable

The change from --ti-rich-text-editor-box-border-color to --tv-RichTextEditor-border-color aligns with the new naming convention, improving consistency across the component's styling.


87-87: LGTM: Updated icon color variables for hover and disabled states

The changes to use --tv-RichTextEditor-icon-color-hover and --tv-RichTextEditor-icon-color-disabled provide more specific control over icon colors in different states, aligning with the new naming convention.

Also applies to: 99-99


134-134: LGTM: Updated style variables for options menu

The changes to use --tv-RichTextEditor-options-bg-color, --tv-RichTextEditor-options-border-radius, --tv-RichTextEditor-options-box-shadow, and --tv-RichTextEditor-line-height provide more specific control over various style properties of the options menu, aligning with the new naming convention.

Also applies to: 137-138, 145-145


281-281: LGTM: Updated style variables for line height options

The changes continue the pattern of using the new --tv-RichTextEditor-* variables for styling. The addition of --tv-RichTextEditor-options-item-bg-color and --tv-RichTextEditor-options-text-color for hover states provides more granular control over the UI.

Also applies to: 284-285, 292-292, 295-296


319-321: LGTM: Consistent updates to font size options styling

The changes in this segment maintain consistency with the previous updates, using the new --tv-RichTextEditor-* variables for styling the font size options. This ensures a uniform approach to theming across different parts of the rich text editor.

Also applies to: 328-328, 331-332, 338-338


614-614: LGTM: Consistent border color variable update

The change from --ti-rich-text-editor-box-border-color to --tv-RichTextEditor-border-color is consistent with the earlier update (line 64), ensuring uniform border styling across the rich text editor component.


651-651: LGTM: Consistent border color variable update

The change from --ti-rich-text-editor-box-border-color to --tv-RichTextEditor-border-color is consistent with the earlier updates (lines 64 and 614), ensuring uniform border styling across the rich text editor component, including the image resize functionality.


Line range hint 1-681: Overall: Consistent and improved styling updates

The changes in this file successfully implement the new naming convention for CSS variables (--tv-RichTextEditor-*) throughout the rich text editor component. This update enhances consistency and improves the overall maintainability of the styles. The only minor suggestion is to consider using a CSS variable for the image handle background color (line 646) to maintain full theming flexibility.

// 头部图标弹出下拉框背景色
--ti-rich-text-editor-options-bg-color: var(--ti-common-color-bg-white-normal, #ffffff);
--tv-RichTextEditor-options-bg-color: #ffffff;
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 global variable for the background color.

While the new variable --tv-RichTextEditor-options-bg-color follows the updated naming convention, it uses a hardcoded color value "#ffffff". For better theme flexibility and consistency, consider using a global background color variable instead.

Replace the hardcoded value with a global variable:

- --tv-RichTextEditor-options-bg-color: #ffffff;
+ --tv-RichTextEditor-options-bg-color: var(--tv-color-bg-normal);

Ensure that --tv-color-bg-normal or a similar global variable exists in your theme system.

📝 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-RichTextEditor-options-bg-color: #ffffff;
--tv-RichTextEditor-options-bg-color: var(--tv-color-bg-normal);

@zzcr zzcr merged commit 8dd8a7e into dev Oct 22, 2024
10 of 14 checks passed
@kagol kagol deleted the cgm/refactor-rich-text 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