npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@justinribeiro/toggle-tooltip

v2.0.0

Published

An accessible, fast, and WCAG 2.1 compliant toggle style tooltip web component using role=status.

Downloads

75,968

Readme

toggle-tooltip

A small (8KB), accessible, fast, and WCAG 2.1 compliant toggle style tooltip web component using role=status.

Features

  1. WCAG 2.1 compliant:
  2. Fast: no jank repaint (turn on paint flashing in DevTools...nada)
  3. Screen reader friendly (interaction model allows explicit feedback)
  4. Supports optional hover (which is also compliant with WCAG 1.4.13)
  5. Basic styling with CSS custom properties

Demo / Screen Reader

To see the tooltip in action within JAWS 2020, see https://www.youtube.com/watch?v=PNH0RTB9alg

Install with Tools

Install the component:

npm i @justinribeiro/toggle-tooltip
# or
yarn add @justinribeiro/toggle-tooltip

Install with CDN

If you want the paste-and-go version, you can simply load it via CDN:

<script type="module" src="https://cdn.jsdelivr.net/npm/@justinribeiro/[email protected]/dist/index.js">

Usage

Fire it up:

<script type="module">
   import '@justinribeiro/toggle-tooltip/index.js';
</script>
<toggle-tooltip>
  ⓘ
  <span slot="tooltip">
    I'm a tooltip!
  </span>
</toggle-tooltip>

See other uses in demo/index.html.

Development

$ git clone [email protected]:justinribeiro/toggle-tooltip.git
$ cd toggle-tooltip
$ yarn install
$ yarn start

# run the tests
$ yarn test

Properties

| Property | Attribute | Type | Default | Description | |----------|-----------|-----------|---------------|--------------------------------------------------| | hover | hover | boolean | false | Setting hover as attribute on component allows for the mouseover andmouseout events to become active for this instance of the toggle-tooltipNote: this mode is complaint with WCAG SC 1.4.13 Content on Hover or FocusTODO: I suppose I could watch for the change and then add/remove the eventhandlers...but I don't have a use case for the at the moment | | label | label | string | "'more info'" | Define the internal button aria-label when an svg icon or other non-textis used | | show | show | boolean | "'more info'" | Define the internal button aria-label when an svg icon or other non-textis used |

Methods

| Method | Type | Description | |---------|-------------------------------|--------------------------------------------------| | close | (noReFocus?: boolean): void | Close the tooltipoReFocus: Don't refocus to the button (probably because wetabbed off and are moving through the document) | | open | (): void | Open the tooltip and focus to it |

Slots

| Name | Description | |-----------|--------------------------------------------------| | | Default slot injects into button value, useful for icon | | tooltip | Any message or links you'd like in the tooltip status message |

CSS Custom Properties

| Property | Default | |--------------------------------------------|------------------| | --toggle-tooltip-button-background-color | "transparent" | | --toggle-tooltip-button-border | "none" | | --toggle-tooltip-button-padding | 0 | | --toggle-tooltip-status-background-color | "#fafafa" | | --toggle-tooltip-status-border | "1px solid #ccc" | | --toggle-tooltip-status-border-radius | "0.5rem" | | --toggle-tooltip-status-box-shadow | "none" | | --toggle-tooltip-status-padding | "1rem" |