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

Add vertical scroll and text highlighting for functions #3918

Merged
merged 6 commits into from
Aug 19, 2020

Conversation

ashikmeerankutty
Copy link
Contributor

Summary

Makes progress on #3056

  • Add a vertical scroll for types with lengths exceeding type container .
  • Add highlighting for functions

Before:

Screenshot 2020-08-14 at 9 53 50 PM

After:

Screenshot 2020-08-14 at 9 54 06 PM

Checklist

  • Check against all themes for compatibility in both light and dark modes
  • Checked in mobile
  • Checked in Chrome, Safari,
  • Checked in Edge, and Firefox
    - [ ] Props have proper autodocs
    - [ ] Added documentation
    - [ ] Checked Code Sandbox works for the any docs examples
    - [ ] Added or updated jest tests
    - [ ] Checked for breaking changes and labeled appropriately
    - [ ] Checked for accessibility including keyboard-only and screenreader modes
    - [ ] A changelog entry exists and is marked appropriately

@kibanamachine
Copy link

Since this is a community submitted pull request, a Jenkins build has not been kicked off automatically. Can an Elastic organization member please verify the contents of this patch and then kick off a build manually?

@ashikmeerankutty
Copy link
Contributor Author

This is the result if we add text highlight for all types

image

Did it look good ?

@cchaos
Copy link
Contributor

cchaos commented Aug 14, 2020

I think the code highlight is a great advantage!

I will say though, I really think it's important not to force text-wrap on code elements. For the same reason why code editors don't wrap lines by default. It's really hard to read what is the whole word.

That said, I haven't thought through a real solution, I just know that forcing word-wrap should not be the solution here.

@ashikmeerankutty
Copy link
Contributor Author

That said, I haven't thought through a real solution, I just know that forcing word-wrap should not be the solution here.

@chandlerprall suggested adding a vertical scroll for functions so they will be displayed in a single line. I tried that but I couldn't find which component is causing the word-wrap

@cchaos
Copy link
Contributor

cchaos commented Aug 14, 2020

Jenkins, test this

@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_3918/

@thompsongl
Copy link
Contributor

jenkins test this

@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_3918/

@thompsongl
Copy link
Contributor

I tried that but I couldn't find which component is causing the word-wrap

.euiTableCellContent__text is responsible for the word-wrap/word-break alterations.
Looks like if you add className="eui-textBreakNormal" to the EuiCode element, more "natural" word wrapping occurs.

@ashikmeerankutty
Copy link
Contributor Author

eui-textBreakNormal

So Is there anyway to remove the word wrap completely to use vertical scrolling. I think that would be more readable for functions.

@thompsongl
Copy link
Contributor

Is there anyway to remove the word wrap completely

Likely with CSS, yes.
I think the current changes (with the addition of eui-textBreakNormal) are good for now, but we should have a designer take a look at adjusting the table layout. For instance, the table in the Playground tab moved the 'Note' column, which allows for more available space. Thoughts @cchaos?

@cchaos
Copy link
Contributor

cchaos commented Aug 19, 2020

Sorry, I think I'm a bit confused as to what this is trying to accomplish. I don't think we should limit the height of any of the cells enforcing a scrollbar. They should always be fully visible. If that means we have to have word breaks, that's fine for now.

@thompsongl
Copy link
Contributor

Ah, yeah, so this doesn't add vertical scroll, it add horizontal scroll if necessary. Height is never restricted.

@ashikmeerankutty
Copy link
Contributor Author

So Is there anyway to remove the word wrap completely to use vertical scrolling. I think that would be more readable for functions.

I meant horizontal scroll everywhere in place of vertical scroll. Sorry I messed !!

Comment on lines 356 to 372
if (functionMatches[j]) {
elements.push(
<EuiCode>
<span className="eui-textBreakNormal">{types[i]}</span>
</EuiCode>
);
elements.push(
<EuiCode language="ts">{functionMatches[j][0]}</EuiCode>
);
j++;
} else {
elements.push(
<EuiCode>
<span className="eui-textBreakNormal">{types[i]}</span>
</EuiCode>
);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm working on a direct fix for the overflow stuff, but can you help me better understand when each of these get displayed? Like what does functionMatches do?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, my idea actually here is to find all functions and display them inline using horizontal scroll as suggested here #3554 (review) under long type rendering. I wasn't able to achieve that due to word-wraps. so that I commented it here but unfortunately. I used vertical instead of horizontal and messed things.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Attached screenshot as comment link seems not working as it was a review

image

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm working on a direct fix for the overflow stuff, but can you help me better understand when each of these get displayed? Like what does functionMatches do?

Also functions may appear sometimes in enums also so in that case i tried to extract functions from those enums using regex also

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah ok, so we want the multiple version to horizontally scroll. Ok, let me actually keep playing with my branch off of yours.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fine, that was the idea.

@cchaos
Copy link
Contributor

cchaos commented Aug 19, 2020

@ashikmeerankutty I had to play around with how the table cell styles were interacting with the code blocks so I just ended up creating a PR for you. ashikmeerankutty#6

I see though that all Fragments still need a key prop

@ashikmeerankutty
Copy link
Contributor Author

I see though that all code code blocks still need a key prop

Thank you so much. I will add them

@thompsongl
Copy link
Contributor

jenkins test this

@thompsongl
Copy link
Contributor

jenkins test this

@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_3918/

Copy link
Contributor

@thompsongl thompsongl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great!

@thompsongl thompsongl merged commit d2ab274 into elastic:master Aug 19, 2020
snide pushed a commit to snide/eui that referenced this pull request Aug 20, 2020
* Add vertical scroll and text highlighting for functions

* use code block instead of markdown

* Swap usages of code for code block and fix overflow

* One codeblock with line breaks when multiple functions

* Fixed warnings of missing keys

Co-authored-by: cchaos <caroline.horn@elastic.co>
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.

5 participants