-
Notifications
You must be signed in to change notification settings - Fork 13
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
Conversation
This file contains 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
The spec from this PR is available at https://preview.sesh.rs/previews/eecs485staff/primer-spec/165/. (Available until Fri May 13 2022.) |
Sesh, thanks for the update. It will be nice to be able to set site-wide code block variant to no-line-numbers instead of useLegacyCodeBlocks to be a binary choice between enhanced and legacy. Either that or make no-line-numbers, instead of enhanced, the default. Thanks.
Regards,
—
sugih
… On Apr 12, 2022, at 01:42, Sesh Sadasivam ***@***.***> wrote:
Context
Resolves #159.
@awdeorio noted that line numbers don't work great for all code blocks. ***@***.*** 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)
Documentation
See the documentation in the demo URL: TODO
(After this PR is merged into main, the docs will be live at: TODO)
Validation
Visit the demo at: [TODO]
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:
You can view, comment on, or merge this pull request online at:
#165
Commit Summary
• 1020e07 Refactor codeblocks to handle generic variant input
• 237c7db Add new code-block variant to hide line numbers
File Changes (9 files)
• M _layouts/spec.html (8)
• M _sass/spec/base.scss (25)
• M demo/enhanced-code-blocks.md (84)
• M demo/page-configuration-options.md (6)
• M docs/USAGE_ADVANCED.md (24)
• M src_js/Config.ts (13)
• A src_js/components/main_content/types.ts (5)
• M src_js/components/main_content/useEnhancedCodeBlocks.tsx (96)
• M src_js/global.d.ts (3)
Patch Links:
• https://github.com/eecs485staff/primer-spec/pull/165.patch
• https://github.com/eecs485staff/primer-spec/pull/165.diff
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you were mentioned.
|
@eecs441staff thanks! I missed to mention in the description of this PR that I added a new configuration option (Will update the PR description with this.) |
Looks great! |
This was referenced Apr 13, 2022
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.
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 toenhanced
, 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 toenhanced
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)After this PR, the
useLegacyCodeBlocks
config options are deprecated. They will continue to work for now, but may be removed in a futuremajor
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: