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

@financial-times/o3-tooltip

v1.0.4

Published

Provides a viewport-aware tooltip for annotating or or highlighting other aspects of a product's UI

Downloads

141

Readme

o3-tooltipMIT licensed

o3-tooltip is hosting two components: o3-tooltip-onboarding and o3-tooltip-toggle. Onboarding Tooltips help for a smoother introduction to new features or functionality. Toggletips are compact pieces of information designed to offer additional insights when needed. See our design guidelines for usage information and brand support.

Markup

We provide custom elements <o3-tooltip-onboarding> and <o3-tooltip-toggle>. React users may include these using our JSX template.

<o3-tooltip-onboarding> is used to display a tooltip on a HTML target element that can have an aria-describedby attribute. It is used to provide additional information about the target element and is shown immediately once the page is loaded. It can be only closed by clicking the close button.

<o3-tooltip-toggle> does not have a close button and is used with an information icon. It can be triggered by clicking on the information icon and will be removed from the DOM if the user clicks outside of the tooltip, presses ESC, or clicks the info icon again.

Below are examples of how to use <o3-tooltip-onboarding> and <o3-tooltip-toggle> custom elements:

<!-- <o3-tooltip-onboarding> -->
<div data-o3-brand="[your brand]">
 <button
  id="demo-o3-tooltip-id"
  class="o3-button o3-button--secondary o3-button--big demo-tooltip-target"
  aria-describedby="demo-o3-tooltip-content"
 >
  Share
 </button>
 <o3-tooltip-onboarding
  role="tooltip"
  placement="top"
  target-id="demo-o3-tooltip-id"
  class="o3-tooltip"
  content="Tool tip content that is quite long, Tool tip content that is quite long, Tool tip content that is quite long"
  title="Title"
  content-id="demo-o3-tooltip-content"
 >
 </o3-tooltip-onboarding>
</div>

content-id is used to link the tooltip to the target element. It is used to provide additional information about the target element.

<!-- <o3-tooltip-toggle> -->
<div data-o3-brand="[your brand]">
 <o3-tooltip-toggle
  placement="bottom"
  class="o3-tooltip"
  content="click the button to see the tooltip"
  title="Title"
  info-label="more information"
 >
 </o3-tooltip-toggle> 
</div>

info-label attribute is used to provide a label for info icon to have better screen reader experience. By default, it is set to "more information".

JavaScript

No code will run automatically unless you import the client side JavaScript. To import the JavaScript, you can use the following code:

import '@financial-times/o3-tooltip';

css

To style o3-tooltip import brand specific css, this varies depending on your project. For example:

@import '@financial-times/o3-tooltip/css/[your brand].css';

JSX

o3-tooltip exports two JSX templates, TooltipOnboarding and TooltipToggle for each tooltip component. JSX templates are exported as cjs (common JS) and esm (ECMAScript) modules, so depending on your system configuration, you may need to import the correct module type. TSX templates can help to avoid copy-pasting html. For example:

import {
 TooltipOnboarding,
 TooltipToggle,
} from '@financial-times/o3-tooltip/cjs';

import '@financial-times/o3-tooltip'; // import the JavaScript needed for custom elements on client side

import '@finacial-times/o3-tooltip/css/[your brand].css'; // tooltip styling

<div className="o3-brand-[your brand]">
 <button id="target" aria-describedby="contentId">
  Target element
 </button>
 <TooltipOnboarding {...props} />;
 <TooltipToggle {...props} />
</div>;

TooltipOnboarding

The TooltipOnboarding JSX element accepts the following props:

type Placement =
 | 'top'
 | 'bottom'
 | 'left'
 | 'right'
 | 'top-start'
 | 'top-end'
 | 'bottom-start'
 | 'bottom-end'
 | 'left-start'
 | 'left-end'
 | 'right-start'
 | 'right-end';

| Prop | type | required | default | description | | :-------: | :---------: | :------: | :-----: | :---------------------------------: | | targetId | string | true | - | Target element to attach tooltip to | | content | string | true | - | Content of the tooltip | | title | string | false | - | Title of the tooltip | | contentId | string | true | - | id for aria-describedby element | | placement | Placement | false | 'top' | Placement of the tooltip |

TooltipToggle

The ToggleTooltip JSX element accepts the following props:

type Placement = 'top' | 'bottom' | 'left' | 'right';

| Prop | type | required | default | description | | :-------: | :---------: | :------: | :----------------: | :----------------------: | | content | string | true | - | Content of the tooltip | | title | string | false | - | Title of the tooltip | | placement | Placement | false | 'top' | Placement of the tooltip | | infoLabel | string | false | more information | Label for screen readers |

Migration Guide

| State | Major Version | Last Minor Release | Migration guide | | :-------: | :-----------: | :----------------: | :-------------: | | ✨ active | 0 | 0.0.1 | N/A |

Contact

If you have any questions or comments about this component, or need help using it, please either raise an issue, visit #origami-support or email Origami Support.


Licence

This software is published by the Financial Times under the MIT licence.