Skip to content

fix: add background color for preview-only examples - #55

Merged
3w36zj6 merged 3 commits into
typst-community:mainfrom
YDX-2147483647:page
Mar 16, 2026
Merged

3w36zj6 merged 3 commits into
typst-community:mainfrom
YDX-2147483647:page

Conversation

@YDX-2147483647

@YDX-2147483647 YDX-2147483647 commented Mar 13, 2026 •

Copy link
Copy Markdown
Member

Page borders are crucial in some examples, but they are invisible without @apply bg-gray-200 p-4.

The new example for page.footer-descent is an instance. To test it, you can download the corresponding docs.json from docs-main.2026-03-10.530c127 - GitHub Actions - Typst dev builds.

Before:
图片

After:

图片

Page borders are crucial in some examples, but they are invisible without `@apply bg-gray-200 p-4`.
@netlify

netlify Bot commented Mar 13, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for typst-docs-web ready!

Name Link
🔨 Latest commit 797db1f
🔍 Latest deploy log https://app.netlify.com/projects/typst-docs-web/deploys/69b744c38777e20008eeb9b4
😎 Deploy Preview https://deploy-preview-55--typst-docs-web.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@YDX-2147483647
YDX-2147483647 marked this pull request as ready for review March 13, 2026 07:51
@YDX-2147483647
YDX-2147483647 requested a review from 3w36zj6 as a code owner March 13, 2026 07:51
Comment thread src/globals.css
/* Side-by-side examples need additional styles for preview images. */
.previewed-code & {
@apply flex-1 flex-wrap flex items-center justify-center lg:min-w-1/2;
}

@YDX-2147483647 YDX-2147483647 Mar 13, 2026 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

.preview {…} is put before .previewed-code .preview {…} (and hence mix into other .preview-code *** {…}) because of the lint rule noDescendingSpecificity | Biome.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adjusts global preview styling so “preview-only” examples (not rendered in side-by-side code/preview blocks) get a background + padding, making page borders visible in rendered docs examples.

Changes:

  • Adds a base .preview style (bg-gray-200 p-4) for preview-only examples.
  • Refactors side-by-side preview styling into a nested .previewed-code & rule to keep layout behavior for .previewed-code .preview.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/globals.css Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

@3w36zj6 3w36zj6 left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

For consistency in design, it needs to have rounded corners.

diff --git a/src/globals.css b/src/globals.css
index f5ba0b3..0a32b8c 100644
--- a/src/globals.css
+++ b/src/globals.css
@@ -95,11 +95,13 @@ samp {
 
 .preview {
 	/* Preview-only examples are not wrapped in `.previewed-code`, but they also need styles to make borders visible */
-	@apply bg-gray-200 p-4;
+	@apply rounded-md overflow-hidden bg-gray-200 p-4;
 
 	/* Side-by-side examples need additional styles for preview images. */
 	.previewed-code & {
 		@apply flex-1 flex-wrap flex items-center justify-center lg:min-w-1/2;
+		/* Do not round the inner edges when in a side-by-side layout. */
+		@apply rounded-none;
 	}
 }
 

Co-Authored-by: 3w36zj6 <52315048+3w36zj6@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Updates global preview styling so “preview-only” examples (not wrapped by .previewed-code) get a background/padding treatment that makes page borders visible, while preserving the side-by-side preview layout behavior.

Changes:

  • Introduce a base .preview style (bg-gray-200 p-4, rounding/overflow handling) to support preview-only examples.
  • Move side-by-side preview layout styles under a nested .previewed-code & selector to keep those behaviors scoped to side-by-side examples.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@3w36zj6 3w36zj6 changed the title fix: also add background color for preview-only examples fix: add background color for preview-only examples Mar 16, 2026
@3w36zj6
3w36zj6 merged commit c1ae8d2 into typst-community:main Mar 16, 2026
21 checks passed
@YDX-2147483647
YDX-2147483647 deleted the page branch March 16, 2026 01:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants