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

fix(color): the text color selection does not show a checkmark #184

Merged
merged 1 commit into from
Jan 2, 2025

Conversation

qwangry
Copy link
Contributor

@qwangry qwangry commented Dec 31, 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: #173

What is the new behavior?

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

Summary by CodeRabbit

  • Style
    • Updated color palette for the toolbar with a new set of predefined color values.
    • Reformatted color definitions to use quoted string values.
    • Expanded font size options in the toolbar's picker group.

Copy link

coderabbitai bot commented Dec 31, 2024

Walkthrough

The pull request involves significant updates to the $colorGroup and $pickerGroup variables in the packages/fluent-editor/src/assets/toolbar.scss file. The $colorGroup variable has been changed to include a new set of color values formatted as strings, replacing the previous hex codes. Additionally, the $pickerGroup variable has been expanded to include new font sizes. The overall structure and styling rules remain unchanged.

Changes

File Change Summary
packages/fluent-editor/src/assets/toolbar.scss Updated $colorGroup variable with a new set of quoted color values, replacing previous unquoted hex codes; expanded $pickerGroup variable to include new font sizes: '18px', '20px', '36px', and '72px'.

Possibly related PRs

  • fix: toolbar icon center #86: This PR modifies the toolbar.scss file to enhance the styling and layout of toolbar components, which is directly related to the changes made to the $colorGroup and $pickerGroup variables in the same file.
  • fix: move the styles inside the ql-toolbar to avoid style pollution #117: This PR also involves changes to the toolbar.scss file, specifically updating hover and active states for buttons and labels, which relates to the overall styling and visual feedback of the toolbar affected by the main PR.
  • fix: set font family doesn't effect #145: Although this PR primarily addresses font family settings, it modifies the font-style.ts file, which may indirectly relate to the $pickerGroup variable updates in the main PR that includes new font size values.

Poem

🎨 Colors dancing, a palette anew,
Hex codes transformed, with quotes so true.
Toolbar's hues shift, a rabbit's delight,
Styling magic in soft pixel 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 generate docstrings to generate docstrings for this PR. (Beta)
  • @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

Walkthrough

This pull request addresses a bug fix related to the text color selection in the toolbar, where the checkmark was not displaying correctly. The changes involve updating the color palette used in the toolbar's SCSS file.

Changes

File Summary
packages/fluent-editor/src/assets/toolbar.scss Updated the $colorGroup variable with a new set of color values to ensure the checkmark displays correctly during text color selection.

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 comments (1)
packages/fluent-editor/src/assets/toolbar.scss (1)

Line range hint 315-368: Add checkmark styling for selected color items

The color picker items are missing the checkmark styling that's present in other picker types. This is why selected colors don't show a checkmark indicator.

Add the following styles to show checkmarks for selected colors:

 .ql-picker-item {
   width: 20px;
   height: 20px;
   margin: 0 5px 5px 0;
   display: inline-flex;
   align-items: center;
+  justify-content: center;
   color: #fff;

+  &.ql-selected::after {
+    content: '\2713';  /* Unicode checkmark */
+    font-size: 14px;
+    font-weight: bold;
+  }

   &:hover {
     color: #fff;
   }

This change will:

  1. Center-align the content in color picker items
  2. Add a checkmark (✓) to selected colors
  3. Style the checkmark to be visible on any background color
🧹 Nitpick comments (1)
packages/fluent-editor/src/assets/toolbar.scss (1)

Line range hint 161-368: Summary of findings and recommendations

While the color palette update is valid, it doesn't address the core issue of missing checkmarks in the color selection UI. The actual fix requires adding proper styling for selected color items. I recommend:

  1. Keep the color palette changes
  2. Add the suggested checkmark styling
  3. Consider adding a test case to verify the visual indicator works

Would you like me to help create a test case for this UI component?

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7348f47 and 4cde329.

📒 Files selected for processing (1)
  • packages/fluent-editor/src/assets/toolbar.scss (1 hunks)

Signed-off-by: wangry <qwangry123@163.com>
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 comments (1)
packages/fluent-editor/src/assets/toolbar.scss (1)

Color and background pickers need checkmark styles for selected items

Based on the search results, I can confirm that while header pickers have proper checkmark styles using ::after pseudo-elements, the color and background pickers lack these styles. Specifically:

  • Header picker items have checkmark styles:
    &.ql-header .ql-picker-item[data-value='1']::after {
      font-size: 2em;
    }
  • Color and background pickers only have basic hover styles:
    .ql-picker-item:hover {
      color: #252b3a;
      background-color: #f2f5fc;
    }

The selected state is managed through the .ql-selected class, but there's no visual checkmark indicator for the color and background pickers to show which option is currently selected.

🔗 Analysis chain

Line range hint 208-251: Verify checkmark implementation across pickers

The file shows checkmark styles for other pickers (header, font, lineheight) but not for the color picker. Let's verify this pattern across the codebase.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Compare checkmark implementations across different pickers

# Search for checkmark styles in picker implementations
echo "Searching for checkmark styles in pickers..."
rg -A 5 "ql-picker.*::after" --type scss

# Search for selected state styles
echo "Searching for selected state styles..."
rg -A 5 "ql-selected" --type scss

Length of output: 320


Script:

#!/bin/bash
# Description: Compare checkmark implementations across different pickers without file type filtering

# Search for checkmark styles in picker implementations
echo "Searching for checkmark styles in pickers..."
rg -A 5 "ql-picker.*::after"

# Search for selected state styles
echo "Searching for selected state styles..."
rg -A 5 "ql-selected"

# Also search for general picker styles to understand the pattern
echo "Searching for picker style patterns..."
rg -A 5 "\.ql-picker-item"

Length of output: 10307

🧹 Nitpick comments (1)
packages/fluent-editor/src/assets/toolbar.scss (1)

214-216: Unrelated changes to font sizes

The additions to $pickerGroup are unrelated to the text color selection checkmark issue. Consider moving these font size changes to a separate PR to maintain focused changes.

Also applies to: 234-234, 236-236, 241-241, 244-244

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4cde329 and 3206c80.

📒 Files selected for processing (1)
  • packages/fluent-editor/src/assets/toolbar.scss (3 hunks)
🔇 Additional comments (1)
packages/fluent-editor/src/assets/toolbar.scss (1)

161-164: ⚠️ Potential issue

Color palette update alone won't fix the checkmark issue

While the color values have been updated, this change doesn't address the core issue of missing checkmark styles for selected colors.

The color picker needs styles for the selected state, similar to other pickers. Add the following CSS:

.ql-toolbar {
  .ql-picker.ql-expanded {
    &.ql-color,
    &.ql-background {
      .ql-picker-item {
+       position: relative;
+       
+       &.ql-selected::after {
+         content: '✓';
+         position: absolute;
+         right: 4px;
+         top: 50%;
+         transform: translateY(-50%);
+         color: white;
+         text-shadow: 0 0 2px rgba(0, 0, 0, 0.8);
+       }
+       
+       &.ql-selected[data-value='#ffffff']::after,
+       &.ql-selected[data-value='#facccc']::after,
+       &.ql-selected[data-value='#ffebcc']::after,
+       &.ql-selected[data-value='#ffffcc']::after,
+       &.ql-selected[data-value='#cce8cc']::after,
+       &.ql-selected[data-value='#cce0f5']::after,
+       &.ql-selected[data-value='#ebd6ff']::after {
+         color: #252b3a;
+         text-shadow: none;
+       }
      }
    }
  }
}

Likely invalid or redundant comment.

@qwangry
Copy link
Contributor Author

qwangry commented Dec 31, 2024

测试发现label的选项有的也不显示对勾,然后发现有些信息比如字号大小是用户自定义配置的,这样在css中如何处理呢?遍历的话也太多了🤔

@kagol kagol added the bug Something isn't working label Jan 2, 2025
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 comments (1)
packages/fluent-editor/src/assets/toolbar.scss (1)

Line range hint 279-397: Fix missing checkmark in color selection

The color picker lacks the checkmark styles that other pickers have. To fix this, add checkmark styles for selected color items:

  .ql-color-picker {
    .ql-picker-item {
      width: 20px;
      height: 20px;
      margin: 0 5px 5px 0;
      display: inline-flex;
      align-items: center;
      color: #fff;
+     position: relative;  /* Added for checkmark positioning */

+     &.ql-selected::after {
+       content: '✓';
+       position: absolute;
+       top: 50%;
+       left: 50%;
+       transform: translate(-50%, -50%);
+       font-size: 14px;
+       color: inherit;
+     }

      &:hover {
        color: #fff;
      }

This solution:

  1. Adds relative positioning to color picker items
  2. Implements checkmark using ::after pseudo-element for selected items
  3. Centers the checkmark within the color box
  4. Inherits text color from parent for proper contrast
🧹 Nitpick comments (1)
packages/fluent-editor/src/assets/toolbar.scss (1)

214-216: Unrelated changes to picker options

These additions to $pickerGroup expand the header levels and font size options but are unrelated to the color selection checkmark issue. Consider moving these changes to a separate PR to maintain focused commits.

Also applies to: 234-234, 236-236, 241-241, 244-244

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3206c80 and 4967e9c.

📒 Files selected for processing (1)
  • packages/fluent-editor/src/assets/toolbar.scss (3 hunks)
🔇 Additional comments (1)
packages/fluent-editor/src/assets/toolbar.scss (1)

161-164: Color palette update looks good, but won't fix the checkmark issue

While the color values are properly formatted, changing the color palette alone won't address the missing checkmark in the color selection UI.

The core issue lies in the missing checkmark styles for selected colors, not in the color values themselves.

@kagol kagol merged commit 4871fe8 into opentiny:main Jan 2, 2025
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants