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

[1.0] Fix 100% width code highlight background only being drawn for the vis… #1192

Merged
merged 3 commits into from
Jun 17, 2017

Conversation

fk
Copy link
Contributor

@fk fk commented Jun 17, 2017

…ible area of a container scrolling its overflowing content

… ;) :/. This is going to be fun.

pre code blocks are now wrapped in a div.gatsby-highlight.
Along with the whitespace changes around .highlight-code-line in #1187, we now should fully mimick the approach that the React Tutorial code example uses (see https://facebook.github.io/react/tutorial/tutorial.html).

Essentialy, the new container around our highlighted pre code allows us to apply float:left; min-width:100% to <pre>, which solves the problem of highlighted code line backgrounds not being drawn for the overflowing part of the code block container.
See e. g. https://stackoverflow.com/a/8513330 for a few more pointers as to why and how this works.

To get the new container wrapped around and not appended in between the node's own <code> and the apparently later generated <pre>, we replace the code node and wrap the highlighted code in <pre> and <code> plus our additional <div> ourselves.

Breaking change to namespace CSS class names: span.highlight-code-line is now span.gatsby-highlight-code-line.

Phew! ;)

…ible area of a container scrolling its overflowing content

… ;) :/. This is going to be fun.

`pre code` blocks are now wrapped in a div.gatsby-highlight.
Along with the whitespace changes around `.highlight-code-line` in gatsbyjs#1187, we now should fully mimick the approach that the React Tutorial code example uses (see https://facebook.github.io/react/tutorial/tutorial.html).

Essentialy, the new container around our highlighted `pre code` allows us to apply `float:left; min-width:100%` to <pre>, which solves the problem of highlighted code line backgrounds not being drawn for the overflowing part of the code block container.
See e. g. https://stackoverflow.com/a/8513330 for a few more pointers as to why and how this works.

To get the new container wrapped _around_ and not appended _in between_ the node's own <code> and the apparently later generated <pre>, we replace the code node and wrap the highlighted code in <pre> and <code> plus our additional <div> ourselves.

Breaking change to namespace CSS class names: `span.highlight-code-line` is now `span.gatsby-highlight-code-line`.

Phew! ;)
@gatsbybot
Copy link
Collaborator

gatsbybot commented Jun 17, 2017

Deploy preview ready!

Built with commit 093ceed

https://deploy-preview-1192--using-drupal.netlify.com

@gatsbybot
Copy link
Collaborator

gatsbybot commented Jun 17, 2017

Deploy preview ready!

Built with commit 093ceed

https://deploy-preview-1192--gatsbygram.netlify.com

@gatsbybot
Copy link
Collaborator

gatsbybot commented Jun 17, 2017

Deploy preview ready!

Built with commit 093ceed

https://deploy-preview-1192--gatsbyjs.netlify.com

@fk
Copy link
Contributor Author

fk commented Jun 17, 2017

To illustrate that 💩 of a commit message – before/after:

image

Also made the highlighted blocks a little calmer and increased line-height a little:

image

@fk fk changed the title Fix 100% width code highlight background only being drawn for the vis… [1.0] www: Fix 100% width code highlight background only being drawn for the vis… Jun 17, 2017
@fk fk changed the title [1.0] www: Fix 100% width code highlight background only being drawn for the vis… [1.0] Fix 100% width code highlight background only being drawn for the vis… Jun 17, 2017
@KyleAMathews
Copy link
Contributor

Looking good! Looks like there's just a snapshot that needs updated (due to the new classname) for the tests to pass. Thanks!

Florian Kissling added 2 commits June 17, 2017 15:25
@KyleAMathews KyleAMathews merged commit 8a3f636 into gatsbyjs:1.0 Jun 17, 2017
@KyleAMathews
Copy link
Contributor

Thanks!

@fk
Copy link
Contributor Author

fk commented Jun 17, 2017

Fingers crossed that this is the last time we need to revisit this! 😝

@gatsbybot
Copy link
Collaborator

gatsbybot commented Jun 17, 2017 via email

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