Skip to content

Conversation

@jeroenransijn
Copy link
Contributor

@jeroenransijn jeroenransijn commented Jul 19, 2018

This PR implements the support of putting a Tooltip inside of a Popover.

Preview

popover tooltip styled

Code Example

The above example is rendered by the following code.

<Popover content={<PopoverContentWithTextInput />}>
  <Tooltip content="Click me">
    <Button marginRight={20}>Tooltip Card + Popover</Button>
  </Tooltip>
</Popover>
<Popover content={<PopoverContentWithTextInput />}>
  <Tooltip
    appearance="card"
    content={
      <React.Fragment>
        <Heading>Heading</Heading>
        <Paragraph color="muted" marginTop={4}>
          Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do
          eiusmod tempor incididunt ut labore et dolore magna aliqua.
        </Paragraph>
      </React.Fragment>
    }
    statelessProps={{
      paddingY: 24,
      paddingX: 24,
      maxWidth: 280
    }}
  >
    <Button>Tooltip + Popover</Button>
  </Tooltip>
</Popover>

Other additions

This PR also adds the support for 2 appearances on a Tooltip: default and card.

@jeroenransijn jeroenransijn requested review from Rowno and mshwery July 19, 2018 22:31
@jeroenransijn jeroenransijn changed the base branch from master to v4 July 19, 2018 22:36
mshwery and others added 2 commits July 20, 2018 10:29
* add padding for icon on Select, add SelectField, add docs

* wip. include in docs

* wip
@mshwery
Copy link
Contributor

mshwery commented Jul 20, 2018

I'm wondering if this is a pattern we should even support (or encourage)? Curious about your thoughts on why we should pursue this @jeroenransijn ?


renderTarget = ({ getRef, isShown }) => {
const { children } = this.props
const isTooltipInside = children.type === Tooltip
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it possible to not pass children? If so we may want to check that it exists first.

.toString()
const getTooltipProps = appearance => {
switch (appearance) {
case 'card':
Copy link
Contributor

Choose a reason for hiding this comment

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

This might be a misunderstanding of the semantics, but I've often followed the rule of thumb that a Tooltip is simple, short content. It cannot contain html or other components, only strings. With those semantics, things that look like a raised "card" would qualify as a Popover IMO.

Not sure if this meshes with Evergreen's component semantics, but thought it was worth mentioning here (if it allows us to simplify 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.

The distinction currently between Tooltip and Popover is the interaction kind: hover vs. click. We might want to consider supporting something like <Popover interaction={InteractionKind.HOVER} /> similar to BlueprintJS at one point. I think we should leave that for a future major release.

* This is an implementation detail. Please ignore.
* This is passed when a Tooltip is inside a Popover.
*/
popoverProps: PropTypes.object
Copy link
Contributor

Choose a reason for hiding this comment

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

I would omit it from the propTypes if this is meant for internal use only.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It will throw a warning if it's not in propTypes right?

@@ -1,12 +1,70 @@
import React, { PureComponent } from 'react'
import PropTypes from 'prop-types'
Copy link
Contributor

Choose a reason for hiding this comment

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

Were these changes to ListItem intentional?

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 am not sure why this is showing up, since this is already in v4.

@jeroenransijn jeroenransijn deleted the v4-tooltip-inside-popover branch July 20, 2018 21:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants