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

style: updated margins and font styles for editor #5978

Merged
merged 3 commits into from
Nov 11, 2024

Conversation

aaryan610
Copy link
Collaborator

@aaryan610 aaryan610 commented Nov 9, 2024

Improvements:

  1. Updated y-margins for all the editor blocks.
  2. Updated font sizes, weights and line-heights of all the text blocks.
  3. Reduced the code block font size.

Summary by CodeRabbit

  • New Features

    • Enhanced styling for the CustomHorizontalRule in the editor, improving vertical spacing.
    • Updated typography styles for headings and paragraphs to improve visual hierarchy and spacing.
  • Bug Fixes

    • Adjusted line heights for title elements to ensure consistent presentation across different font sizes.
  • Chores

    • Introduced new CSS variables for code elements to allow for more tailored styling within the editor.

Copy link
Contributor

coderabbitai bot commented Nov 9, 2024

Walkthrough

The changes in this pull request primarily focus on updating the HTMLAttributes for the CustomHorizontalRule extension across multiple files, specifically changing its class attribute to adjust vertical spacing. Additionally, several CSS modifications enhance typography and spacing within the editor, including updates to font sizes and line heights for code elements. The overall structure of the editor extensions and components remains unchanged, ensuring existing functionalities are preserved.

Changes

File Path Change Summary
packages/editor/src/core/extensions/core-without-props.ts, packages/editor/src/core/extensions/extensions.tsx, packages/editor/src/core/extensions/read-only-extensions.tsx Updated HTMLAttributes for CustomHorizontalRule: class changed from "my-4 border-custom-border-400" to "py-4 border-custom-border-400". No other changes to extension configurations.
packages/editor/src/styles/editor.css Modified typography styles for headings and paragraphs, replacing margins with paddings. Removed line-height from .ProseMirror and added font-weight. Adjusted task list styles.
packages/editor/src/styles/variables.css Added new CSS variables for font sizes and line heights for code elements in .large-font and .small-font classes.
web/core/components/pages/editor/title.tsx Updated styling for PageEditorTitle: changed font-semibold to font-bold, adjusted line heights for small and large font sizes.

Possibly related PRs

Suggested labels

🌟improvement

Suggested reviewers

  • Palanikannan1437
  • SatishGandham

🐇 In the editor, a rule so fine,
Adjusted spacing, now it shines!
With paddings set and styles anew,
Our code will dance, a joyful view.
So hop along, let's celebrate,
These changes make our work first-rate! 🎉


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
Contributor

@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: 2

🧹 Outside diff range and nitpick comments (4)
web/core/components/pages/editor/title.tsx (1)

28-30: Well-structured implementation of typography changes.

Good practices observed:

  • Consistent use of Tailwind utility classes
  • Maintains responsive design with dynamic font sizing
  • Preserves existing functionality while improving aesthetics

Consider extracting these typography values into a theme configuration for better maintainability and consistency across the application.

packages/editor/src/styles/variables.css (1)

Margin changes are being removed, not added as mentioned in PR objectives

The git diff shows that margin-related changes are actually being removed from the codebase, contrary to the PR objectives that mentioned updating vertical margins. Specifically:

  • Multiple margin-top values (2rem, 1.4rem, 1rem, 0.25rem) are being removed
  • Several margin-bottom values (4px, 1px) are being removed
  • Only one new margin rule is being added: margin: 0 !important

This indicates a discrepancy between the PR objectives and the actual changes being made.

🔗 Analysis chain

Line range hint 1-95: Verify the location of margin updates mentioned in PR objectives.

While the font style changes are well-implemented, the PR objectives mention updating vertical margins (y-margins) for editor blocks. However, these margin changes are not present in this file.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for margin-related changes in editor styles
echo "Searching for margin-related CSS changes in editor files..."
rg -t css "margin|spacing" "packages/editor/src/styles/"

Length of output: 2222


Script:

#!/bin/bash
# Let's check the git diff to see if there are any margin-related changes in this PR
echo "Checking git diff for margin-related changes..."
git diff HEAD~1 -- "packages/editor/src/styles/" | grep -E '(\+|\-).*margin'

# Also check for any new margin-related CSS variables that might have been added
echo -e "\nChecking for margin-related CSS variables..."
rg -t css "var\(.*margin.*\)" "packages/editor/src/styles/"

Length of output: 718

packages/editor/src/core/extensions/extensions.tsx (1)

81-81: Consider keeping margin-based spacing for horizontal rules

The change from my-4 to py-4 switches from margin to padding-based spacing. While both provide visual spacing, margins are typically preferred for horizontal rules as they:

  • Better handle margin collapse with adjacent elements
  • Follow conventional HTML5 semantic spacing patterns
  • Provide more predictable spacing behavior

Consider reverting to margin-based spacing or verify that padding specifically addresses a layout requirement:

-        class: "py-4 border-custom-border-400",
+        class: "my-4 border-custom-border-400",
packages/editor/src/styles/editor.css (1)

312-320: Consider documenting the margin reset strategy

The use of !important to reset margins is quite aggressive. While this appears to be part of a transition to padding-based spacing, it would be beneficial to:

  1. Document why this approach was chosen
  2. Add a comment explaining that spacing is handled via padding
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 13083a7 and 3937dc6.

📒 Files selected for processing (6)
  • packages/editor/src/core/extensions/core-without-props.ts (1 hunks)
  • packages/editor/src/core/extensions/extensions.tsx (1 hunks)
  • packages/editor/src/core/extensions/read-only-extensions.tsx (1 hunks)
  • packages/editor/src/styles/editor.css (2 hunks)
  • packages/editor/src/styles/variables.css (4 hunks)
  • web/core/components/pages/editor/title.tsx (1 hunks)
🔇 Additional comments (7)
web/core/components/pages/editor/title.tsx (1)

28-30: Font weight and line height adjustments look good, but consider accessibility.

The changes align well with the PR objectives to improve readability:

  • Increased line heights provide better vertical spacing
  • Bolder font weight enhances visual hierarchy

However, ensure that the contrast between the title and background remains sufficient with the new font weight, especially for users with visual impairments.

Let's verify the color contrast ratio for the title:

packages/editor/src/styles/variables.css (1)

49-49: Well-chosen typography for large font code blocks!

The code font size (0.85rem) maintains readability while being appropriately smaller than regular text (1rem). The line height (1.5rem) creates comfortable spacing and maintains vertical rhythm with regular text.

Also applies to: 59-59

packages/editor/src/core/extensions/core-without-props.ts (1)

49-49: 🛠️ Refactor suggestion

Consider using margin instead of padding for horizontal rule spacing.

Changing from my-4 (margin) to py-4 (padding) for a horizontal rule might not achieve the desired spacing effect. Horizontal rules (<hr>) are typically styled with margins rather than padding since they are self-closing elements, and padding might not render consistently across browsers.

Consider reverting to margin-based spacing:

-      class: "py-4 border-custom-border-400",
+      class: "my-4 border-custom-border-400",

Let's verify the visual impact of this change:

packages/editor/src/core/extensions/read-only-extensions.tsx (1)

70-70: Consider the implications of switching from margin to padding.

The change from my-4 (margin-y) to py-4 (padding-y) might affect the visual spacing differently:

  • Margins collapse between adjacent elements while paddings don't
  • This could lead to inconsistent spacing in different contexts (e.g., when horizontal rules are placed next to other block elements)

Let's verify the spacing consistency:

Consider using CSS custom properties for spacing to maintain consistency:

-        class: "py-4 border-custom-border-400",
+        class: "my-block-spacing border-custom-border-400",

This would allow for easier maintenance and consistency of spacing across the editor.

✅ Verification successful

Based on the analysis of the codebase, I can now provide a final response:

The change from margin to padding is consistent with the codebase's styling approach

The switch from my-4 to py-4 for horizontal rules is actually beneficial because:

  • The change is consistently applied across all editor configurations (core-without-props.ts, read-only-extensions.tsx, and extensions.tsx)
  • The Tailwind configuration shows custom spacing scale where both margin and padding use the same scale (0.9rem for spacing-4)
  • The editor's typography styles already handle spacing between block elements using padding in most cases
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for any other margin/padding classes used with horizontal rules
# and verify consistency across the codebase

# Search for other horizontal rule configurations
rg -l "CustomHorizontalRule" | xargs rg "my-|py-" -A 5 -B 5

# Look for related CSS classes that might affect spacing
rg "\.prose.*hr|horizontal-rule" --type css

Length of output: 2766


Script:

#!/bin/bash
# Let's check for any existing margin/padding styles in the CSS files
# and also look for any Tailwind configuration files that might define
# custom spacing for horizontal rules

# Search for CSS files with hr styling
rg "hr\s*{[^}]*}" --type css -A 5 -B 5

# Search for Tailwind configuration files
fd "tailwind.config" --exec cat {}

# Search for any prose styling configuration
rg "prose" --type css -A 5 -B 5

Length of output: 26030

packages/editor/src/core/extensions/extensions.tsx (1)

Line range hint 1-182: Verify implementation of all style updates mentioned in PR objectives

The PR objectives mention updates to font sizes, weights, and line-heights for text blocks, as well as reduced font size for code blocks. However, these changes are not visible in the current file. Please ensure that:

  1. Font style updates are implemented somewhere in the codebase
  2. Code block font size reduction is properly applied

Let's check for any related style changes in the codebase:

packages/editor/src/styles/editor.css (2)

325-383: LGTM! Well-structured heading hierarchy

The heading styles demonstrate:

  • Consistent vertical rhythm (28px/20px top padding based on heading level)
  • Uniform bottom padding (4px)
  • Good use of CSS variables for maintainable typography

15-15: Verify text readability after line-height removal

While setting a base font-weight is good, the removal of line-height from .ProseMirror could affect text readability. Ensure that all text elements have appropriate line-height values set individually.

✅ Verification successful

Line-height is properly maintained throughout text elements

The codebase shows comprehensive line-height definitions:

  • Base text has 1.5 line-height
  • All heading levels (h1-h6) use custom CSS variables for line-height
  • Regular text and lists have dedicated line-height variables
  • The only zero line-height appears to be intentional, likely for a specific UI element
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if line-height is properly set for all text elements
rg "line-height:" packages/editor/src/styles/

Length of output: 774

packages/editor/src/styles/variables.css Outdated Show resolved Hide resolved
packages/editor/src/styles/editor.css Outdated Show resolved Hide resolved
Copy link
Contributor

@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 (2)
packages/editor/src/styles/editor.css (2)

15-15: Consider removing redundant font-weight declaration

The font-weight: 400; may be unnecessary if this is the default value or already inherited. Removing redundant declarations can help keep the CSS clean and maintainable.


312-320: Avoid using !important to reset margins

Using !important can make the CSS harder to override and maintain. Consider increasing selector specificity or adjusting the cascade to achieve the desired effect without relying on !important.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 3937dc6 and d8aafd7.

📒 Files selected for processing (2)
  • packages/editor/src/styles/editor.css (2 hunks)
  • packages/editor/src/styles/variables.css (4 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/editor/src/styles/variables.css
🔇 Additional comments (2)
packages/editor/src/styles/editor.css (2)

325-325: Verify consistency of padding-top values for headings

The padding-top is set to 28px for headings h1 to h4, while h5 and h6 use 20px. Please confirm that this difference aligns with the design specifications.

Also applies to: 336-336, 347-347, 358-358, 369-369, 380-380


398-400: Duplicate paragraph spacing rules still exist

As previously noted, there are duplicate rules affecting paragraph spacing:

  1. Within .prose :where(p): Lines 398-400 set padding-bottom: 4px;
  2. Standalone rule p + p: Lines 410-412 set padding-top: 8px !important;

Consider consolidating these rules to avoid conflicts and simplify maintenance.

Also applies to: 410-412

@pushya22 pushya22 merged commit 97eb8d4 into preview Nov 11, 2024
14 of 15 checks passed
@pushya22 pushya22 deleted the style/editor-typography branch November 11, 2024 10:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants