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

Added tooltips for context help in ping and metric fields. Fixes #293 #300

Merged
merged 2 commits into from
Jan 11, 2021

Conversation

nfebe
Copy link
Contributor

@nfebe nfebe commented Jan 3, 2021

This PR addresses #293

Method

  • Introduce an info icon svg
  • Created a ToolTip component, that accepts a child element on which the tooltip would linger over.

Notes

  • Tailwind was not used immediately for convenience (styles can easily be swapped if approach is approved)
  • Thinking of an effective way to keep the tooltips hanging for a while after hover, so users can click on link in tooltips.
  • Check metrics detail page to see how it works

Preview

tooltip

@wlach wlach self-requested a review January 4, 2021 15:08
Copy link
Contributor

@wlach wlach left a comment

Choose a reason for hiding this comment

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

This looks like a great start! A few things in addition to the comments:

  1. The tooltips sometimes go off the screen-- I think using sveltejs-tippy (which builds off the tippy library) instead of rolling our own should fix it.

image

  1. I think instead of persisting the tooltip so the user can click "Learn More", we can just make the help icons link to the documentation. This is what the old glean dictionary does and I think it works ok.
  2. The pull request title should specify the issue fixed (Add tooltips with contextual help for application, ping and metric fields #293). See the contributing docs.

<td>Relevant Bugs</td>
<td>
Relevant Bugs
<ToolTip top={true} tip={getHelpMessage('bugs')}>
Copy link
Contributor

Choose a reason for hiding this comment

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

It probably makes sense to create a small component for this (in another project, I called a similar thing HelpHoverable)

@@ -0,0 +1,20 @@
export default {
Copy link
Contributor

Choose a reason for hiding this comment

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

This is the right idea, but I'd probably put this file in src/data/help.js (I don't think there's any need to specify that they have to do with tooltips specifically)

bugs: {
text:
"Required. A list of bugs (e.g. Bugzilla or GitHub) that are relevant to this metric. For example, bugs that track its original implementation or later changes to it.",
more_info:
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we can just call this link, for simplicity

Suggested change
more_info:
link:

@nfebe nfebe changed the title Added tooltips for context help in ping and metric fields. Added tooltips for context help in ping and metric fields. Fixes #293 Jan 4, 2021
@wlach
Copy link
Contributor

wlach commented Jan 7, 2021

It looks like sveltejs-tippy including the tippy library directly causes some minor issues. In particular, we need to import a plugin to postprocess the css, as well. This is the same as mdauner/sveltejs-tippy#117

After fixing this, I noticed the additional problem of the tippy library referencing something we don't have in a browser context (process). I fixed this using rollup-plugin-replace, but rollup-plugin-babel might do the same thing (it seems to work for sveltejs-tippy's demo) and would be a cleaner solution:

https://github.com/mdauner/sveltejs-tippy/blob/master/package.json#L35
https://github.com/mdauner/sveltejs-tippy/blob/master/rollup.config.js#L50

The following patch, if applies, makes things work again (though the styling still needs some work):

https://gist.github.com/wlach/bdaab17805e0a24fdabff718d15e9a12

Do you want to experiment with applying that, and maybe the babel thing I mention?

@nfebe
Copy link
Contributor Author

nfebe commented Jan 7, 2021

Ok, I see! I could fix that now that it's clear, however, if we style need to do some styling, Why don't we eliminate this dependency all together, the overflow issue can easily be stripped down with a few tailwind classes.

@wlach
Copy link
Contributor

wlach commented Jan 7, 2021

Ok, I see! I could fix that now that it's clear, however, if we style need to do some styling, Why don't we eliminate this dependency all together, the overflow issue can easily be stripped down with a few tailwind classes.

I think the underlying tippy library does a lot of stuff, I'm a bit skeptical that the behaviour can be reproduced just with CSS. You're definitely welcome to try though!

@nfebe
Copy link
Contributor Author

nfebe commented Jan 7, 2021

I checked the tipsy library again, it offers a lot (way more than we need) but the flexibility is enormous so I went with it.

Copy link
Contributor

@wlach wlach left a comment

Choose a reason for hiding this comment

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

This looks really good! I have some concerns about the implementation, hopefully they won't be too hard to address. Once we have an initial draft of this working, we can start using this in more places. :)

package-lock.json Show resolved Hide resolved
src/components/ToolTip.svelte Outdated Show resolved Hide resolved
src/components/ToolTip.svelte Outdated Show resolved Hide resolved
src/components/ToolTip.svelte Outdated Show resolved Hide resolved
src/components/ToolTip.svelte Outdated Show resolved Hide resolved
src/components/ToolTip.svelte Outdated Show resolved Hide resolved
src/components/ToolTip.svelte Outdated Show resolved Hide resolved
src/components/ToolTip.svelte Outdated Show resolved Hide resolved
src/components/ToolTip.svelte Outdated Show resolved Hide resolved
Copy link
Contributor

@wlach wlach left a comment

Choose a reason for hiding this comment

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

Hey, so a few things:

I think maybe some of my feedback got a bit garbled / misunderstood. Just to reframe again (maybe a bit more concretely):

  1. I would rename ToolTip.svelte to HelpHoverable.svelte and define the various types of behaviour we want (the info icon, etc.) inside it.
  2. The file you renamed to HelpHoverable.js can just be removed (since it's just an abstraction layer over the actual data which we don't need, at least not right now).

After the above suggestions are applied, MetricDetail.svelte should look something like this:

<script>
  ...
  import HelpHoverable from "../components/HelpHoverable.svelte"
  import HelpStrings from "../data/help";
  ...
</script>

...
<td>Send in Pings <HelpHoverable content={help.send_in_pings.content} link={help.send_in_pings.link} /></td>
...

package-lock.json Outdated Show resolved Hide resolved
@nfebe nfebe force-pushed the help-tooltips branch 2 times, most recently from 6a2fed7 to e6e840b Compare January 11, 2021 16:53
Copy link
Contributor

@wlach wlach left a comment

Choose a reason for hiding this comment

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

This looks great, just have a few last requests for changes before we land.

src/components/HelpHoverable.svelte Outdated Show resolved Hide resolved
src/components/HelpHoverable.svelte Outdated Show resolved Hide resolved
src/components/HelpHoverable.svelte Show resolved Hide resolved
src/components/HelpHoverable.svelte Show resolved Hide resolved
rollup.config.js Show resolved Hide resolved
src/data/help.js Outdated Show resolved Hide resolved
src/pages/MetricDetail.svelte Outdated Show resolved Hide resolved
Copy link
Contributor

@wlach wlach 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, just one change (which I'll make), then we can land. @Iinh -- we'll need to rebase the protocol work on top of this at some point-- the amount of tailwind styling in here is pretty minimal so hopefully merging won't be so bad.

src/components/HelpHoverable.svelte Outdated Show resolved Hide resolved
@wlach wlach merged commit b0ae349 into mozilla:main Jan 11, 2021
@wlach
Copy link
Contributor

wlach commented Jan 11, 2021

Thanks for your persistence on this @fenn-cs!

@wlach wlach mentioned this pull request Jan 15, 2021
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.

2 participants