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: Add padding to diff code blocks #10996

Merged
merged 2 commits into from
Aug 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion src/components/codeBlock/code-blocks.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,15 @@
margin: 0 0 1rem;
}

/**
* Shift padding on code diffs, so the background highlight covers the whole line
*/
pre[class^='language-']:has(:global(.code-diff)) {
padding-left: 0;
padding-right: 0;

& :global(.token.operator) {
padding-right: 12px;
}
}

pre[class^='language-']:has(:global(.highlight-line)) {
Expand Down Expand Up @@ -70,15 +76,22 @@

/* Diff highlighting, classes provided by rehype-prism-plus */
/* Set inserted line (+) color */
/* Move the margin left and adjust width so we can keep the parent padding */
:global(.diff-inserted),
:global(.inserted) {
background-color: rgba(16, 185, 129, 0.2);
margin-left: -12px;
width: calc(100% + 12px);
}

/* Diff highlighting, classes provided by rehype-prism-plus */
/* Set deleted line (-) color */
Copy link
Member

Choose a reason for hiding this comment

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

Maybe update this comment (and the comment for the above changes) to reflect that we are also setting the padding here

/* Move the margin left and adjust width so we can keep the parent padding */
:global(.diff-deleted),
:global(.deleted) {
background-color: rgba(239, 68, 68, 0.2);
margin-left: -12px;
width: calc(100% + 12px);
}
}

Expand Down
Loading