CSS Tooltips built on Tether. #hubspot-open-source

Overview

Tooltip

GitHub version

Tooltip.js is a Javascript and CSS library for creating styleable tooltips.

Install

Dependencies

Installing via npm and bower will bring in the above dependencies as well.

npm

$ npm install tether-tooltip

bower

$ bower install tether-tooltip

Usage

let tooltipInstance = new Tooltip({
  target: document.querySelector('.tooltip-target'),
  content: "My awesome <b>content</b>.",
  classes: 'tooltip-tether-arrows',
  position: 'top left'
})

API Documentation

Demo

Contributing

We encourage contributions of all kinds. If you would like to contribute in some way, please review our guidelines for contributing.

License

Copyright © 2015 HubSpot - MIT License

Comments
  • Better support for Browserify

    Better support for Browserify

    Hi,

    I tried to use Tooltip from Browserify (see #27) and got an error.

    The problem is that when you do var Tooltip = require("tether-tooltip/tooltip"); it does not export Tooltip constructor but Tether constructor.

    Also it would be nice to have an main/index.js entry point for the lib so that we can simply call var Tooltip = require("tether-tooltip");

    It is still possible to use this lib with Browserify by accessing the global variable Tooltip. What I did in a TetherTooltip.js file:

    require("tether-tooltip/tooltip");
    module.exports = Tooltip;
    
    in-progress 
    opened by slorber 15
  • Cannot read property 'classList' of null

    Cannot read property 'classList' of null

    Uncaught TypeError: Cannot read property 'classList' of null tooltip.js:1661
    hasClass tooltip.js:1661
    DropInstance.isOpened tooltip.js:3138
    DropInstance.close tooltip.js:3176(anonymous function)
    

    This happens sometimes

    in-progress 
    opened by slorber 9
  • Updating tooltip position when target moves

    Updating tooltip position when target moves

    Hi!

    Not sure if this is supposed to happen, but when the tooltip's target element changes position, the tooltip doesn't move with it. Here's a quick example gif:

    Tooltip

    In this example the tooltip is attached to the icon, but when the icon moves down on hover, the tooltip stays where it was. Is this a feature or just a bug?

    On another note, the tooltips themselves behave kind of oddly. Here's a screenshot of a tooltip attached to the black bar, with the position set as "right middle":

    Tooltip

    While the tooltip is on the right side of the bar, it certainly isn't in the middle. It's also missing the arrow.

    Let me know if you want any information about my setup in case you think this is on my end, I'll provide it gladly.

    opened by aapokiiso 9
  • Add ARIA attributes

    Add ARIA attributes

    @thejameskyle Re: #50, this PR adds the role=tooltip attribute to the tooltip content element, and the aria-describedby attribute to the tooltip target.

    Note that these changes require Drop v1.4.2 in order to work, due to the issue described at HubSpot/drop#134.

    It would be nice to have aria-hidden as well, but that's really a change that should be made to Drop, since it's not Tooltip-specific. I'll take a crack at that later.

    opened by TrevorBurnham 6
  • Allow setting openOn via html data attribute

    Allow setting openOn via html data attribute

    I need to be able to do something like data-tooltip-openOn="hover focus" for some elements.

    Is there a particular reason for not having support for this?

    cheers

    opened by huoxito 5
  • Mustn't go outside of visible viewport

    Mustn't go outside of visible viewport

    i.e. if you want it positioned to the right of an element which is against the right-side of the page, then it should be moved to the top / bottom.

    I would've assumed since this relies on Tether that this would already be a given.

    duplicate 
    opened by adam-lynch 5
  • Support tooltips that we can hover

    Support tooltips that we can hover

    I use tooltip in a special way, as I mount ReactJS components inside the tooltip.

    These tooltips have buttons inside.

    I was able to make it work with:

    .tooltip-element.tooltip-theme-arrows {
      pointer-events: none;
      &.tooltip-hoverable {
        pointer-events: auto;
      }
    }
    

    And by adding the tooltip-hoverable class. Drop seems clever and does not close the tooltip when it's hovered.

    It would be nice to add that option in default themes as well as in the tooltip API

    opened by slorber 3
  • Uncaught TypeError: Cannot read property 'close' of undefined

    Uncaught TypeError: Cannot read property 'close' of undefined

    Hi,

    I've included tether (0.6.5), drop (0.2.9) and tooltip (0.2.6).

    I get that error on my page:

    Uncaught TypeError: Cannot read property 'close' of undefined 
    

    any clue where it might be coming from?

    Thanks

    opened by agenteo 3
  • a11y

    a11y

    It would be awesome if this library could follow a11y best practices. Basically:

    When shown:

    <div aria-describedby="tooltip-1">A nice element</div>
    <div id="tooltip-1" role="tooltip" aria-hidden="false">A nice tooltip</div>
    

    When not shown:

    <div aria-describedby="tooltip-1">A nice element</div>
    <div id="tooltip-1" role="tooltip" aria-hidden="true">A nice tooltip</div>
    
    opened by jamiebuilds 2
  • Support for require

    Support for require

    Tooltip, Drop and Tether should have support for require. In my case, I don't really want those vars in the global window since it's a bad practice. I would prefer to use require and amd the three: Tooltip, Drop and Tether. From what I gather, Tether already does this.

    I'll try and pull request this. The problem, from what I see, is Tether needing to access the window to get Tether or Drop. There should be some strategy like the Tether one to use whatever is available.

    Correct me if I'm wrong.

    in-progress 
    opened by joesantosio 2
  • Tether Error: Both element and target must be defined

    Tether Error: Both element and target must be defined

    I'm using Browserify with TetherTooltip. require("tether-tooltip/tooltip"); works fine to get the code.

    However, Tether gives me the error Tether Error: Both element and target must be defined

    Versions are:

    /*! tether-tooltip 0.2.6 */
    /*! tether 0.6.5 */
    

    Notice that I have this error even with the code sample

    new Tooltip({
      target: targetElement,
      position: 'top left',
      content: "My awesome <b>content</b>.",
      classes: 'my-tether-theme'
    });
    

    I see in my debugger the call to setOptions with the attributes

    options: Object
      classes: "my-tether-theme"
      content: "My awesome <b>content</b>."
      position: "top left"
      target: div.space-overview-shared-with-count
    

    So is it a bug? At least I don't understand what I am supposed to pass as element

    opened by slorber 2
  • Javascript gets executed when the tooltip content has javascript script

    Javascript gets executed when the tooltip content has javascript script

    Hi, So i came up with this issue where if the content data has JavaScript code script then its gets executed.

    Examples:

    const data = {
      "email": "<img src=x onerror=prompt(1)>@x.y",
      "firstName": "Sabin",
      "lastName": "Bogati"
    }
    
    <Tooltip content={JSON.stringify(data, null, 2)} className="json-tooltip">
      <span className="text-body">
        Placeholder....
      </span>
    </Tooltip>
    

    how do i disable JavaScript from executing?

    opened by sabinbogati1 0
  • Tooltips not working, possible rookie issue

    Tooltips not working, possible rookie issue

    I came across this by chance, while looking for a way to add tooltips to a Hubspot CMS page. I am not a developer, barely a front-end developer, and I cannot get this to work at all. I'm also completely willing to be told it's my fault.

    It is worth noting that I have no idea how to use npm or bower, and am simply trying to link all the relevant js and css files on a Hubspot page to make some custom tooltips work. I've been adding in this code as per the documentation, but with no luck. I can't even get the example html (included in the ZIP file) to work, and that's after I've added in the dependent urls myself.

    opened by mistereid 0
  • how to modify the font size of the content of tooltip

    how to modify the font size of the content of tooltip

    hello, I feel the font size of the content of tooltip is small, but I spend much time to find solution but failed, So I made a 'popover'. When I click a span element like:

    <span name="explanation" class="explanation-tooltip glyphicon glyphicon-question-sign" data-container="body" data-toggle="popover" data-title="hello!" data-original-title="" title=""></span>

    the 'popover' function is normal and it shows 'hello!'. But when mouse hover the above span, the 'tooltip' still shows tip:hello! So how to disable the content of tooltip when I use 'popover' ? can you give some advises. looking forward to your reply.

    opened by PapaMadeleine2022 0
  • Tooltip doesn't show

    Tooltip doesn't show

    So, the JS is working, 'cause i see it creates a few classes when i hover the element. However, doesn't show any tooltip.

    I already called tether, drop and then tooltip, as well the CSS. There's no error, just doesn't show.

    opened by jhones-dev 0
Releases(v1.1.0)
Extends Bootstrap Tooltips and Popovers by adding custom classes. Available for Bootstrap 3 and Bootstrap 4.

Bootstrap Tooltip Custom Class Extends Bootstrap Tooltips and Popovers by adding custom classes. Available for Bootstrap 3 and Bootstrap 4. Define you

Andrei Victor Bulearca 14 Feb 10, 2022
A lightweight JavaScript library for implementing tooltips.

Tooltipper A lightweight (1kB) JavaScript library for implementing tooltips. Installation Install via NPM: npm i -S tooltipper Install via CDN: <scrip

Kyle Andrews 9 Nov 2, 2022
Reference for How to Write an Open Source JavaScript Library - https://egghead.io/series/how-to-write-an-open-source-javascript-library

Reference for How to Write an Open Source JavaScript Library The purpose of this document is to serve as a reference for: How to Write an Open Source

Sarbbottam Bandyopadhyay 175 Dec 24, 2022
An Open-Source Platform to certify open-source projects.

OC-Frontend This includes the frontend for Open-Certs. ?? After seeing so many open-source projects being monetized ?? without giving any recognition

Open Certs 15 Oct 23, 2022
Shikhar 4 Oct 9, 2022
This is a project for open source enthusiast who want to contribute to open source in this hacktoberfest 2022. 💻 🎯🚀

HACKTOBERFEST-2022-GDSC-IET-LUCKNOW Beginner-Hacktoberfest Need Your first pr for hacktoberfest 2k22 ? come on in About Participate in Hacktoberfest b

null 8 Oct 29, 2022
Complete Open Source Front End Candy Machine V2 Minter dAPP Built For The Frog Nation NFT Solana Project. Built With React, Candy Machine V2, Typescript

Complete Open Source Front End Candy Machine V2 Minter dAPP Built For The Frog Nation NFT Solana Project. Built With React, Candy Machine V2, Typescript

null 17 Sep 24, 2022
A recreation of a startpage posted on Reddit without the source, so I rewrote it in Next.js + Tailwind for the open source community.

Startpage "Figma Balls" Rewrite Why Did I Make This I saw a startpage posted on the subreddit r/startpages that I thought looked nice, but when I look

Thomas Leon Highbaugh 5 Mar 29, 2022
Let's participate in Hacktoberfest and contribute to open-source. Star the repo and open a PR to get accepted.

Let's Contribute To Open-source First Contributions This project aims to simplify and guide the way, beginners can make their first contribution towar

Ehmad Saeed⚡ 5 Dec 3, 2022
LunaSec - Open Source Security Software built by Security Engineers. Scan your dependencies for Log4Shell, or add Data Tokenization to prevent data leaks. Try our live Tokenizer demo: https://app.lunasec.dev

Our Software We're a team of Security Engineers on a mission to make awesome Open Source Application Security tooling. It all lives in this repo. Here

LunaSec 1.2k Jan 7, 2023
(🔗, 🌲) Web3 Link Tree is a free & open-source alternative to Linktree built with React.js, Next.js, Tailwind and Web3-React

Getting Started Read the detailed guide here Customize Add your name, wallet address, social media links and more in config.ts Images Save images to t

Naut 35 Sep 20, 2022
Open source data infrastructure platform. Designed for developers, built for speed.

Gigahex is a web based data infrastructure platform to deploy and manage Apache Spark™, Apache Kafka and Apache Hadoop clusters. Currently, it support

Gigahex 22 Dec 6, 2022
Open source data infrastructure platform. Designed for developers, built for speed.

Gigahex is a web based data infrastructure platform to deploy and manage Apache Spark™, Apache Kafka and Apache Hadoop clusters. Currently, it support

Gigahex 21 Apr 1, 2022
🆙 Upscayl - Free and Open Source AI Image Upscaler for Linux, MacOS and Windows built with Linux-First philosophy.

v1.3 will come around 12 September Upscayl ?? Free and Open Source AI Image Upscaler simplescreenrecorder-2022-08-23_20.17.02.mp4 Upscayl is a cross-p

Upscayl 8.7k Jan 9, 2023
Open Source two factor authenticator. Built during #SupaLaunchWeek 5!

Archived This repository is archived, please go to https://github.com/otentikapp/clients for future development. Introduction Feeling bothered about h

Aris Ripandi 18 Dec 29, 2022
Aniso is an open-source ASCII tool built by Studio Freight to generate and customize character-based imagery.

Aniso Aniso is an open-source ASCII tool built by Studio Freight to generate and customize character-based imagery. Features Granularity control Chara

Studio Freight Darkroom 10 Dec 16, 2022
The open source Community Operating System, built with developers in mind.

IMPORTANT: This project is still under active development. Be aware that future releases can lead to breaking changes. The open source Community OS, b

crowd.dev 383 Dec 29, 2022
🆙 Upscayl - Free and Open Source AI Image Upscaler for Linux, MacOS and Windows built with Linux-First philosophy.

Upscayl ?? Free and Open Source AI Image Upscaler Upsacyl.Demo.mp4 Upscayl is a cross-platform application built with the Linux-first philosophy. This

Upscayl 5.1k Sep 21, 2022