2.1.4 • Published 4 months ago

@saekitominaga/customelements-tooltip-trigger v2.1.4

Weekly downloads
17
License
MIT
Repository
github
Last release
4 months ago

Tooltip UI

npm version test status

Features

  • The overall behavior is similar to Wikipedia footnotes.
  • Automatically copies the HTML of footnotes on the page and displays them as tooltips.
    • Markup such as <a href> and <code> can be used in tooltips.
    • However, id attributes inside footnote are removed. This is to prevent duplicate IDs from existing in the document.
  • A tooltip is displayed on hovering or clicking the trigger element.
    • The tooltip is generated the first time a request is made to display the tooltip, not when the web page loads. This minimizes DOM processing at load time when a large number of tooltips are embedded in the page.
  • Customizable delay time for showing and hiding for mouse operations.
  • The <dialog> element is used to represent the tooltip. (Firefox 98+, Safari 15.4+, Chrome 37+)

Demo

Examples

<!-- ↓ The following element are automatically inserted from JavaScript in `<head>` when the page loads -->
<link rel="preload" as="image" href="/assets/tooltip-close.svg">

<a is="x-tooltip-trigger"
  href="#footnote-1"
>[1]</a>

<a is="x-tooltip-trigger"
  href="#footnote-2"
  data-tooltip-label="Note"
  data-tooltip-class="mytooltip"
  data-tooltip-close-text="Close"
  data-tooltip-close-image-src="/assets/tooltip-close.svg"
  data-tooltip-mouseenter-delay="250"
  data-tooltip-mouseleave-delay="250"
>[1]</a>

<ul class="footnotes">
<li id="footnote-1">Footnote text. <a href="#">link</a> <code>code</code> <em>emphasis</em></li>
<li id="footnote-2">Footnote text.</li>
</ul>

<!-- ↓ The following element are automatically inserted from JavaScript just before `</body>` when the first request to display the tooltip is made -->
<x-tooltip>...</x-tooltip>

Attributes

Overview of update from version 1 to version 2

There are major incompatible changes in version 2.

  • @saekitominaga/customelements-tooltip installation is no longer required.
  • Some data-* attribute names have been changed.
  • Customizing the appearance of tooltips requires writing your own CSS.
2.1.4

4 months ago

2.1.3

5 months ago

2.1.2

2 years ago

2.1.1

2 years ago

2.1.0

2 years ago

2.0.0

2 years ago

1.2.2

3 years ago

1.2.1

3 years ago

1.2.0

3 years ago

1.1.2

3 years ago

1.1.1

3 years ago

1.1.0

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago