-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Replace current tooltip with Popper.js * Merge tooltip and title for top stats * Format bounce rate and visit duration numbers in tooltip * Add 'width=manual' mode for embed * Add changelog entry * Use helper function canMetricBeGraphed
- Loading branch information
Showing
8 changed files
with
200 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import React, { useState } from "react"; | ||
import { usePopper } from 'react-popper'; | ||
import classNames from 'classnames' | ||
|
||
export function Tooltip({ children, info, className, onClick }) { | ||
const [visible, setVisible] = useState(false); | ||
const [referenceElement, setReferenceElement] = useState(null); | ||
const [popperElement, setPopperElement] = useState(null); | ||
const [arrowElement, setArrowElement] = useState(null); | ||
const { styles, attributes } = usePopper(referenceElement, popperElement, { | ||
placement: 'top', | ||
modifiers: [ | ||
{ name: 'arrow', options: { element: arrowElement } }, | ||
{ | ||
name: 'offset', | ||
options: { | ||
offset: [0, 4], | ||
}, | ||
}, | ||
], | ||
}); | ||
|
||
return ( | ||
<div className={classNames('relative', className)}> | ||
<div ref={setReferenceElement} onMouseEnter={() => setVisible(true)} onMouseLeave={() => setVisible(false)} onClick={onClick}> | ||
{children} | ||
|
||
</div> | ||
{info && visible && <div ref={setPopperElement} style={styles.popper} {...attributes.popper} className="z-50 p-2 rounded text-sm text-gray-100 font-bold popper-tooltip" role="tooltip"> | ||
{info} | ||
<div ref={setArrowElement} style={styles.arrow} className="tooltip-arrow"></div> | ||
</div> | ||
} | ||
</div> | ||
) | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters