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

[Code Blocks] no-line-numbers variant #165

Merged
merged 3 commits into from
Apr 13, 2022
Merged

[Code Blocks] no-line-numbers variant #165

merged 3 commits into from
Apr 13, 2022

Conversation

seshrs
Copy link
Member

@seshrs seshrs commented Apr 12, 2022

Context

Resolves #159.

@awdeorio noted that line numbers don't work great for all code blocks. (@eecs441staff shared the same feedback with me earlier this year.)

This PR introduces a new code-block "variant" called no-line-numbers. This variant is exactly identical to enhanced, except that line numbers aren't shown. (Other "enhanced" features are retained — copying the block, clicking a line, highlighting lines, etc. continue to work!)

With these changes, the data-variant attribute on code blocks supports these three options:

  • enhanced (the default)
  • no-line-numbers (identical to enhanced but without line numbers)
  • legacy (the old style)

Additionally, this PR adds a new page-wide/site-wide configuration option defaultCodeblockVariant that can be used to set the global default variant!

Documentation

See the documentation in the demo URL: https://preview.sesh.rs/previews/eecs485staff/primer-spec/165/demo/enhanced-code-blocks.html#no-line-numbers

(After this PR is merged into main, the docs will be live at: https://eecs485staff.github.io/primer-spec/165/demo/enhanced-code-blocks.html#no-line-numbers)

⚠️ DEPRECATION NOTICE

After this PR, the useLegacyCodeBlocks config options are deprecated. They will continue to work for now, but may be removed in a future major release.

Instead, use defaultCodeblockVariant (see the documentation pages for usage info).

Validation

Visit the demo at: https://preview.sesh.rs/previews/eecs485staff/primer-spec/165/demo/enhanced-code-blocks.html#no-line-numbers

Notice that the code block looks identical to the enhanced variant — hover over the block to see the "copy" button, and click on the left-margin to select lines.

Screenshot:
image

@seshrs seshrs added the semver/minor Pull Request proposes "minor" change label Apr 12, 2022
@seshrs seshrs added this to the SP/SU 22 milestone Apr 12, 2022
@seshrs seshrs changed the title No line numbers [Code Blocks] no-line-numbers variant Apr 12, 2022
@github-actions
Copy link
Contributor

github-actions bot commented Apr 12, 2022

The spec from this PR is available at https://preview.sesh.rs/previews/eecs485staff/primer-spec/165/.

(Available until Fri May 13 2022.)

@seshrs seshrs marked this pull request as ready for review April 12, 2022 05:45
@eecs441staff
Copy link

eecs441staff commented Apr 12, 2022 via email

@seshrs
Copy link
Member Author

seshrs commented Apr 12, 2022

@eecs441staff thanks! I missed to mention in the description of this PR that I added a new configuration option defaultCodeblockVariant. You can use this to set page-wide or site-wide defaults 😃

(Will update the PR description with this.)

@awdeorio
Copy link
Contributor

Looks great!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
semver/minor Pull Request proposes "minor" change
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants