Code Monkey home page Code Monkey logo

Comments (7)

tvkhoa avatar tvkhoa commented on May 10, 2024 1

Hi @ismail-codar, I found a better solution for dynamic and interactive tooltip.
Could you please check https://github.com/tvkhoa/react-tippy for that ? (disabled and html props)

Btw, @atomiks Thanks for your beautiful tooltip project. I port it to React component so that react user can use it conveniently. :)

from tippyjs.

atomiks avatar atomiks commented on May 10, 2024

I see, will definitely add this in for the next release, which will probably be v0.4 with the new Popper release which fixed some bugs. Thanks!

from tippyjs.

atomiks avatar atomiks commented on May 10, 2024

Do you think it's more appropriate to call this callback wait, like:

// In library:
const show = () => this.callbacks.wait ? this.callbacks.wait(_show) : _show()

// Usage:
new Tippy(domNode, {
    wait(show) {
     // Do stuff
     setTimeout(() => {
       // stuff
       show()
     }, 0)
    }
})

or maybe even manual, since you want to control the show of the tooltip... not sure

from tippyjs.

ismail-codar avatar ismail-codar commented on May 10, 2024

Same idea but yours looks better 👍 I did not send a pull request because I think you should give the code structure.

from tippyjs.

atomiks avatar atomiks commented on May 10, 2024

This is included as wait in v0.4.0 for now (there may be a better solution, but it's there if need be)

from tippyjs.

ismail-codar avatar ismail-codar commented on May 10, 2024

Hi @tvkhoa The following method is not appropriate for me..

<Tooltip
  html={(
    <div>Name: {name}</div>
  )}
>
  <button onClick={changeName}>Change Name</button>
</Tooltip>

Not appropriate because my tooltip content is a large component and available in hundreds of places.
This means this large component renders to html hundreds of times via html={....}. If i use it.
So was my preference is a custom method as mentioned here.

If react-tippy have a working solution similar to following it can be usefull. So tooltip template content must be render on demand.

<div id="my-tooltip-template">Name: {name}</div>
<Tooltip html="my-tooltip-template">
  <button onClick={changeName}>Change Name</button>
</Tooltip>
<Tooltip html="my-tooltip-template">
  <button onClick={changeName}>Change Name</button>
</Tooltip>

from tippyjs.

tvkhoa avatar tvkhoa commented on May 10, 2024

Hi @ismail-codar , I miss the notification so sorry for the late response.
You can pass the react element to html prop. It's sth like that

const TooltipContent = ({ name }) => (
  <div>
    <p>Name: {name}</p>
    ...
  </div>
);
...
<Tooltip html={<TooltipContent name={name} />}>
  <button onClick={changeName}>Change Name</button>
</Tooltip>

I think your current solution in React is an error-prone. Example: you can not pass the event like onChange or onClick to your tooltip content.

from tippyjs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.