-
Notifications
You must be signed in to change notification settings - Fork 842
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
[EuiCodeBlock] Add line numbers #4993
Conversation
@miukimiu Would you please take a look at this from a design perspective before I open for full review? |
Preview documentation changes for this PR: https://eui.elastic.co/pr_4993/ |
Preview documentation changes for this PR: https://eui.elastic.co/pr_4993/ |
I'm pretty sure that would be the behavior that we want (not copying the line-numbers). So perhaps there's a setting that is actually only working in Safari? You can also pass |
Yes, I think I worded that poorly. All browsers do not copy the line numbers, which is good. Safari is the only browser that makes it appear as though the line numbers are selected. Other browsers:
This is there already but has no effect on what Safari does. |
Looks like it's because it's technically still highlighting the generic row. What you'll need to do is apply the setting the whole wrapper, then add it back on with |
Preview documentation changes for this PR: https://eui.elastic.co/pr_4993/ |
Opening this up for review, but very much open to design changes 🙇♂️ |
Preview documentation changes for this PR: https://eui.elastic.co/pr_4993/ |
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.
This is a great feature, and it's looking good! 😍
I found a few issues.
When we have a non-virtualized code block and a vertical scrollbar appears the line numbers get out of the container:
I used the following example in eui/src-docs/src/views/code/code_block.js
: https://gist.github.com/miukimiu/4c01830ecaa0dd2e442780ba16c98a5b.
Screen size 1440 x 1024
.
Another issue is when we have a whiteSpace="pre"
. All the content scrolls and the numbers overlap the text.
Ideally, the horizontal scrollbar should start after the line numbers:
Screen.Recording.2021-09-09.at.03.18.PM.mov
Preview documentation changes for this PR: https://eui.elastic.co/pr_4993/ |
Preview documentation changes for this PR: https://eui.elastic.co/pr_4993/ |
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.
Looks good @thompsongl! 🎉
Tested again in Chrome, Safari, Edge, and Firefox.
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.
Sorry for the millions of questions, it's my first time looking at this component so I have a lot of really annoying q's/comments 😅 QA itself looks great and amazing, so mostly just very nitty stuff from me
Preview documentation changes for this PR: https://eui.elastic.co/pr_4993/ |
}, | ||
children: [], | ||
}, | ||
{ | ||
type: 'element', | ||
tagName: 'span', | ||
properties: { | ||
style: { marginLeft: width + 8 }, // 8px is $euiSizeS | ||
className: ['euiCodeBlock__line__text'], | ||
style: { marginLeft: width + $euiSizeS }, |
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.
TIL variables can start with a special character! Awesome 🤯
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.
Changes and a quick QA of the docs look great! 🎉 My above unit testing comment is 100% optional
Preview documentation changes for this PR: https://eui.elastic.co/pr_4993/ |
Summary
Closes #3140 by adding an option to render line numbers in EuiCodeBlock. Works with virtualization and fullscreen, and does not impact copy functionality.
Checklist
fec4925