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

@evo/tooltip

v0.4.0

Published

Tooltip component

Downloads

419

Readme

Tooltip

Компонент позволяет выводить подсказку (тултип) при ховере или клике на элемент.

Usage

Пример:

import Tooltip from '@evo/tooltip'
import tooltipStyle from '@evo/tooltip/dist/themeWhite.css'

const Example = () => (
	<Tooltip
		css={tooltipStyle}
		placement='right-start'
		content={<span>some text goes here</span>}
		isHover
	>
		reference element
	</Tooltip>
);

Dependencies

В проекте, который будет использовать данный компонент, должны быть установлены следующие зависимости:

"peerDependencies": {
    "classnames": "^2.2.5",
    "react": "^16.3.2",
    "react-dom": "^16.3.2",
    "prop-types": "^15.6.1",
    "react-onclickoutside": "^6.7.1"
},

API

Tooltip компонент принимает в себя css, content, placement, isHover, isFixed, isVisible, stickToViewport, delay

css

Используется для стилизирования компонента. Существует две темы themeWhite и themeBlack

Для подключения темы на проект:

import tooltipStyle from '@evo/tooltip/dist/themeBlack.css'
...
<Tooltip
	css={tooltipStyle}
	...
>
	...
</Tooltip>
...

Подключение своих стилей:

import tooltipStyle from 'path_to_your_styles.css'
...
<Tooltip
	css={tooltipStyle}
	...
>
	...
</Tooltip>
...

content

Собственно сам контент, может быть как текст так и React-компонент.

placement

Управляет позиционированием тултипа относительно элемента для которого вызван. placement может быть как top, right, bottom, left так и с суфиксами -start, -end чтобы прикрепить тултип к краю элемента относительно которого он вызывается.
По умолчанию:

placement='bottom'

isHover

Заставляет тултип показыватся при наведении.
По умолчанию:

isHover={false}

isFixed

Делает тултип display: fixed. По умолчанию тултип позиционируется абсолютно относительно родителя, но иногда нужно чтобы он позиционировался относительно <body>.
По умолчанию:

isFixed={false}

isVisible

Делает тултип видимым по умолчанию.
По умолчанию:

isVisible={false}

stickToViewport

Делает тултип максимально видимым пока reference-элемент находится в зоне видимости окна.
По умолчанию:

stickToViewport={false}

delay

Задержка для срабатывания mouseLeave при isHover.
По умолчанию:

delay={100}