-
Notifications
You must be signed in to change notification settings - Fork 1
feat: add side-by-side layout for previewed code blocks #27
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds support for displaying code blocks in a side-by-side layout with their preview output. The implementation uses CSS flexbox to show code and preview content adjacently.
Key Changes
- Added CSS classes for side-by-side code/preview layout using flexbox
- Modified background color declaration to use
!importantto override external styles
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could the modification be limited to wide screens? On narrow screens, the original layout is easier to read.
Update: The example for place.flush also looks better in the original layout.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
67bbb1d to
46f699e
Compare
|
I found something strange. Regarding Identifiers on the Syntax page, in the official docs, the |
|
Interesting, the source code does not have anything related to big either. The official docs only uses the typst-docs library ( You can ask the typst team on Discord if you care. |
|
Let's move forward by considering this out of scope for this PR for now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have some codes with horizontal scroll bars.
Maybe it could be improved by
- adding
lg:flex-wrapfor.previewed-code, - adding
lg:flex-[1_0_auto]for.previewed-code pre, - and adding
lg:min-w-1/2for.previewed-code .preview(orlg:min-w-2/5to be more flexible).
Edit: I realize that Fixed.flex-[1_0_auto] doesn't look good on narrow screens, because it will make the whole page overflow horizontally…
Explanation:
flex-[1_0_auto] means the base size is the original width, and it can grow but not shrink.
When the browser displays .previewed-code, it first puts <pre> in its original size and puts .preview as 1/2 = 50%.
If their total width is smaller than that of container, then both <pre> and .preview grow to fit all width in the container.
Otherwise, .preview is wrapped into the next line, and <pre> and .preview still grow, but they fit each one's own width.
Before:
After:
Co-authored-by: Y.D.X. <[email protected]>
|
Could you merge git merge origin/main # or upstream/main, depending on your local settings |
…ide-layout-for-previewed-code
✅ Deploy Preview for typst-docs-web ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
src/globals.css
Outdated
| } | ||
|
|
||
| .previewed-code pre { | ||
| @apply flex-1 m-0 rounded-none whitespace-pre lg:flex-[1_0_auto]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After adding whitespace-pre, the <pre> may cause the page to overflow horizontally on narrow screens.
Example: (en-US v0.14.0 /reference/styling/, window.innerWidth = 450)
| @apply flex-1 m-0 rounded-none whitespace-pre lg:flex-[1_0_auto]; | |
| @apply flex-1 m-0 rounded-none whitespace-pre overflow-x-auto lg:flex-[1_0_auto]; |
| <div class="container mx-auto max-w-8xl px-4 sm:px-6 lg:px-8 flex relative"> |
Adding overflow-x-auto here, and changing this flex in <BaseTemplate> to lg:flex would make <pre> scrollable and avoid the page from overflowing horizontally.
|
Added |








close #1
This pull request introduces a side-by-side layout for previewed code blocks.