yew-bootstrap icon indicating copy to clipboard operation
yew-bootstrap copied to clipboard

Draft: Tooltips / Popper support

Open micolous opened this issue 5 months ago • 0 comments

Based on #45

This adds support for tooltips with popper-rs.

Bootstrap tooltips are built with Popper. Both Yew and Popper assume they have complete control of the DOM, so Popper needs some extra wiring to handle the component lifecycle correctly, which popper-rs provides.

This takes some ideas from react-bootstrap's Tooltip implementation, but goes for a slightly simpler model, where Tooltips are dropped into a portal directly (like popper-rs' example), and the Tooltip component is responsible for all the event handling (rather than Overlay and OverlayTrigger).

To position the tooltip correctly and mark the target element with accessibility attributes, you need to expose a NodeRef for each component you want to add a tooltip to. I've exposed NodeRefs for Button, FormControl and Link.

Unlike regular Bootstrap, this doesn't support tooltips from data attributes.

I've added examples using all of those controls, and also a direct ref= attribute on a HTML elements.

micolous avatar Sep 08 '24 02:09 micolous