fix(block): constrain line-number gutter width on the frontend - #308
Open
faisalahammad wants to merge 1 commit into
Open
fix(block): constrain line-number gutter width on the frontend#308faisalahammad wants to merge 1 commit into
faisalahammad wants to merge 1 commit into
Conversation
- Add block-scoped CSS capping gutter width at fit-content - Keep gutter and code cells on one row via inline-table display - Register and inject dist/blocks.style.build.css on block pages only Fixes Automattic#287
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #287
Changes proposed in this Pull Request
.wp-block-syntaxhighlighter-code) uses the v3 highlighter table, wheretable-layout: auto+width: 100%on the table andtd.codestretches thetd.guttercell, so line numbers sit far from the code. On narrow screens the gutter and code cells also split onto separate rows.src/code-block/style.scss(built intodist/blocks.style.build.css):max-width: fit-contenton the gutter cell, anddisplay: inline-tableon the row so the number stays on the same line as its code.dist/blocks.style.build.csswas built but never loaded before. It is now registered assyntaxhighlighter-blocks-cssand injected on the frontend only when the page contains asyntaxhighlighter/codeblock (or a reusable block), using the same JS link-injection patternmaybe_output_scripts()already uses for the core/theme styles.[sourcecode]etc.) has no block wrapper, so it is untouched.Testing instructions
[sourcecode php]shortcode on another post. Its gutter/layout looks unchanged.npm run build).