[Code] Add highlightLine prop to CodeBlock #48230
Merged
rylnd merged 6 commits intoelastic:masterfrom Oct 15, 2019
Merged
Conversation
Rather than do the splitting up of lines (for highlighting, numbering) internally, it makes a bit more sense to have the consumer provide an array of strings to be rendered. The biggest win here is the disambiguation of our upcoming `highlightLine` prop: were we to accept an array of line indices, it's unclear whether those should correspond to the monaco index (1-based), internal index (0-based), or formatted (passed through `lineNumber)`. Better to standardize on the lineIndex argument parameter already used for lineNumber, and simply ask the consumer to return a boolean for any given line.
Allows consumers to declare which lines should be highlighted with the more subtle, full-width coloring. * Refactors decoration generation into private methods * Simplifies both lineNumber and highlightLine to be invoked with _just_ the lineIndex, as consumers will now have the array to index into themselves, if necessary.
Because of the way we're currently using Monaco, we need to apply all three of these options to our line decorations. However, all we really need to do is set the background-color. As such, we can remove these redundant/unused css classes and reduce the noise around this functionality. Also, BEM.
This selector is meant to move the folding button over to account for the extra width taken by the Blame sidebar. However, `.code-line-decoration` is the only class that is applied to the blame view, and the selector in question was in fact incorrectly moving the folding button off the screen on any foldable line that was also highlighted. The bug was fixed in the previous commit that removed this class, but this was the last mention of it.
So that we don't have to import a non-standard repo to view the full functionality of this page.
Contributor
|
Pinging @elastic/code (Team:Code) |
daveyholler
approved these changes
Oct 15, 2019
Contributor
💔 Build Failed |
Contributor
Author
|
retest |
Contributor
💔 Build Failed |
Contributor
Author
|
@elasticmachine merge upstream |
Contributor
💚 Build Succeeded |
rylnd
added a commit
to rylnd/kibana
that referenced
this pull request
Oct 15, 2019
* CodeBlock accepts an array of strings, rather than a single string Rather than do the splitting up of lines (for highlighting, numbering) internally, it makes a bit more sense to have the consumer provide an array of strings to be rendered. The biggest win here is the disambiguation of our upcoming `highlightLine` prop: were we to accept an array of line indices, it's unclear whether those should correspond to the monaco index (1-based), internal index (0-based), or formatted (passed through `lineNumber)`. Better to standardize on the lineIndex argument parameter already used for lineNumber, and simply ask the consumer to return a boolean for any given line. * Add highlightLine prop to CodeBlock Allows consumers to declare which lines should be highlighted with the more subtle, full-width coloring. * Refactors decoration generation into private methods * Simplifies both lineNumber and highlightLine to be invoked with _just_ the lineIndex, as consumers will now have the array to index into themselves, if necessary. * Simplify CSS related to line highlighting Because of the way we're currently using Monaco, we need to apply all three of these options to our line decorations. However, all we really need to do is set the background-color. As such, we can remove these redundant/unused css classes and reduce the noise around this functionality. Also, BEM. * Remove errant CSS rule This selector is meant to move the folding button over to account for the extra width taken by the Blame sidebar. However, `.code-line-decoration` is the only class that is applied to the blame view, and the selector in question was in fact incorrectly moving the folding button off the screen on any foldable line that was also highlighted. The bug was fixed in the previous commit that removed this class, but this was the last mention of it. * Update mock data to depend on Typescript-Node-Starter repo So that we don't have to import a non-standard repo to view the full functionality of this page.
7 tasks
rylnd
added a commit
that referenced
this pull request
Oct 16, 2019
* CodeBlock accepts an array of strings, rather than a single string Rather than do the splitting up of lines (for highlighting, numbering) internally, it makes a bit more sense to have the consumer provide an array of strings to be rendered. The biggest win here is the disambiguation of our upcoming `highlightLine` prop: were we to accept an array of line indices, it's unclear whether those should correspond to the monaco index (1-based), internal index (0-based), or formatted (passed through `lineNumber)`. Better to standardize on the lineIndex argument parameter already used for lineNumber, and simply ask the consumer to return a boolean for any given line. * Add highlightLine prop to CodeBlock Allows consumers to declare which lines should be highlighted with the more subtle, full-width coloring. * Refactors decoration generation into private methods * Simplifies both lineNumber and highlightLine to be invoked with _just_ the lineIndex, as consumers will now have the array to index into themselves, if necessary. * Simplify CSS related to line highlighting Because of the way we're currently using Monaco, we need to apply all three of these options to our line decorations. However, all we really need to do is set the background-color. As such, we can remove these redundant/unused css classes and reduce the noise around this functionality. Also, BEM. * Remove errant CSS rule This selector is meant to move the folding button over to account for the extra width taken by the Blame sidebar. However, `.code-line-decoration` is the only class that is applied to the blame view, and the selector in question was in fact incorrectly moving the folding button off the screen on any foldable line that was also highlighted. The bug was fixed in the previous commit that removed this class, but this was the last mention of it. * Update mock data to depend on Typescript-Node-Starter repo So that we don't have to import a non-standard repo to view the full functionality of this page.
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.
Summary
Addresses elastic/code#1685. Motivated by #47974
highlightLineprop to highlight full lines more subtly than individual symbolsCodeBlockto accept an array of strings (lines), rather than a newline-separated string (content)Checklist
Use
strikethroughsto remove checklist items you don't feel are applicable to this PR.For maintainers