-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #75 from SocketDotTech/fix/replace-tooltip-lib
feat: replaced tippy with floating-ui lib
- Loading branch information
Showing
10 changed files
with
130 additions
and
55 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
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
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,53 @@ | ||
import { | ||
useFloating, | ||
useHover, | ||
useInteractions, | ||
offset, | ||
flip, | ||
shift, | ||
} from "@floating-ui/react"; | ||
import { ReactNode, useState } from "react"; | ||
|
||
export const Tooltip = ({ | ||
children, | ||
tooltipContent, | ||
}: { | ||
children: ReactNode; | ||
tooltipContent: ReactNode; | ||
}) => { | ||
const [isOpen, setIsOpen] = useState(false); | ||
|
||
const { refs, floatingStyles, context } = useFloating({ | ||
open: isOpen, | ||
onOpenChange: setIsOpen, | ||
middleware: [offset(5), flip(), shift()], | ||
}); | ||
|
||
const hover = useHover(context); | ||
|
||
const { getReferenceProps, getFloatingProps } = useInteractions([hover]); | ||
|
||
return ( | ||
<> | ||
<div | ||
ref={refs.setReference} | ||
{...getReferenceProps()} | ||
className="skt-w skt-w-flex" | ||
> | ||
{children} | ||
</div> | ||
{isOpen && ( | ||
<div | ||
ref={refs.setFloating} | ||
style={floatingStyles} | ||
className="skt-w-px-3 skt-w-z-50" | ||
{...getFloatingProps()} | ||
> | ||
<div className="skt-w skt-w-text-xs skt-w-text-white skt-w-text-left skt-w-bg-[#262636] skt-w-border skt-w-border-widget-secondary-text skt-w-border-opacity-40 skt-w-rounded-md skt-w-p-2"> | ||
{tooltipContent} | ||
</div> | ||
</div> | ||
)} | ||
</> | ||
); | ||
}; |
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 |
---|---|---|
|
@@ -1875,6 +1875,43 @@ | |
"@ethersproject/properties" "^5.7.0" | ||
"@ethersproject/strings" "^5.7.0" | ||
|
||
"@floating-ui/core@^1.4.1": | ||
version "1.4.1" | ||
resolved "https://registry.yarnpkg.com/@floating-ui/core/-/core-1.4.1.tgz#0d633f4b76052668afb932492ac452f7ebe97f17" | ||
integrity sha512-jk3WqquEJRlcyu7997NtR5PibI+y5bi+LS3hPmguVClypenMsCY3CBa3LAQnozRCtCrYWSEtAdiskpamuJRFOQ== | ||
dependencies: | ||
"@floating-ui/utils" "^0.1.1" | ||
|
||
"@floating-ui/dom@^1.3.0": | ||
version "1.5.1" | ||
resolved "https://registry.yarnpkg.com/@floating-ui/dom/-/dom-1.5.1.tgz#88b70defd002fe851f17b4a25efb2d3c04d7a8d7" | ||
integrity sha512-KwvVcPSXg6mQygvA1TjbN/gh///36kKtllIF8SUm0qpFj8+rvYrpvlYdL1JoA71SHpDqgSSdGOSoQ0Mp3uY5aw== | ||
dependencies: | ||
"@floating-ui/core" "^1.4.1" | ||
"@floating-ui/utils" "^0.1.1" | ||
|
||
"@floating-ui/react-dom@^2.0.1": | ||
version "2.0.1" | ||
resolved "https://registry.yarnpkg.com/@floating-ui/react-dom/-/react-dom-2.0.1.tgz#7972a4fc488a8c746cded3cfe603b6057c308a91" | ||
integrity sha512-rZtAmSht4Lry6gdhAJDrCp/6rKN7++JnL1/Anbr/DdeyYXQPxvg/ivrbYvJulbRf4vL8b212suwMM2lxbv+RQA== | ||
dependencies: | ||
"@floating-ui/dom" "^1.3.0" | ||
|
||
"@floating-ui/react@^0.25.0": | ||
version "0.25.0" | ||
resolved "https://registry.yarnpkg.com/@floating-ui/react/-/react-0.25.0.tgz#2dcc79b0892b570641484355ca27a0f25793c12b" | ||
integrity sha512-0ulipo5ZTmCpTlVPjIbLyqReO7S3gwyQSiIm0TjKU5LPN97BmMZ2crJZcNMQ4GZz/V4qurMibGl4z3+TjF5tRA== | ||
dependencies: | ||
"@floating-ui/react-dom" "^2.0.1" | ||
"@floating-ui/utils" "^0.1.0" | ||
aria-hidden "^1.2.3" | ||
tabbable "^6.0.1" | ||
|
||
"@floating-ui/utils@^0.1.0", "@floating-ui/utils@^0.1.1": | ||
version "0.1.1" | ||
resolved "https://registry.yarnpkg.com/@floating-ui/utils/-/utils-0.1.1.tgz#1a5b1959a528e374e8037c4396c3e825d6cf4a83" | ||
integrity sha512-m0G6wlnhm/AX0H12IOWtK8gASEMffnX08RtKkCgTdHb9JpHKGloI7icFfLg9ZmQeavcvR0PKmzxClyuFPSjKWw== | ||
|
||
"@gar/promisify@^1.0.1": | ||
version "1.1.3" | ||
resolved "https://registry.npmjs.org/@gar/promisify/-/promisify-1.1.3.tgz" | ||
|
@@ -2087,11 +2124,6 @@ | |
schema-utils "^3.0.0" | ||
source-map "^0.7.3" | ||
|
||
"@popperjs/core@^2.9.0": | ||
version "2.11.8" | ||
resolved "https://registry.yarnpkg.com/@popperjs/core/-/core-2.11.8.tgz#6b79032e760a0899cd4204710beede972a3a185f" | ||
integrity sha512-P1st0aksCrn9sGZhp8GMYwBnQsbvAWsZAX44oXNNvLHGqAOcoVxmjZiohstwQ7SqKnbR47akdNi+uleWD8+g6A== | ||
|
||
"@rainbow-me/rainbowkit@^0.4.1": | ||
version "0.4.1" | ||
resolved "https://registry.npmjs.org/@rainbow-me/rainbowkit/-/rainbowkit-0.4.1.tgz" | ||
|
@@ -3135,13 +3167,6 @@ | |
dependencies: | ||
"@babel/runtime" "^7.12.5" | ||
|
||
"@tippyjs/react@^4.2.6": | ||
version "4.2.6" | ||
resolved "https://registry.yarnpkg.com/@tippyjs/react/-/react-4.2.6.tgz#971677a599bf663f20bb1c60a62b9555b749cc71" | ||
integrity sha512-91RicDR+H7oDSyPycI13q3b7o4O60wa2oRbjlz2fyRLmHImc4vyDwuUP8NtZaN0VARJY5hybvDYrFzhY9+Lbyw== | ||
dependencies: | ||
tippy.js "^6.3.1" | ||
|
||
"@trysound/[email protected]": | ||
version "0.2.0" | ||
resolved "https://registry.npmjs.org/@trysound/sax/-/sax-0.2.0.tgz" | ||
|
@@ -3939,6 +3964,13 @@ argparse@^1.0.7: | |
dependencies: | ||
sprintf-js "~1.0.2" | ||
|
||
aria-hidden@^1.2.3: | ||
version "1.2.3" | ||
resolved "https://registry.yarnpkg.com/aria-hidden/-/aria-hidden-1.2.3.tgz#14aeb7fb692bbb72d69bebfa47279c1fd725e954" | ||
integrity sha512-xcLxITLe2HYa1cnYnwCjkOO1PqUHQpozB8x9AR0OgWN2woOBi5kSDVxKfd0b7sb1hw5qFeJhXm9H1nu3xSfLeQ== | ||
dependencies: | ||
tslib "^2.0.0" | ||
|
||
aria-query@^5.0.0: | ||
version "5.0.0" | ||
resolved "https://registry.npmjs.org/aria-query/-/aria-query-5.0.0.tgz" | ||
|
@@ -10940,6 +10972,11 @@ synchronous-promise@^2.0.15: | |
resolved "https://registry.npmjs.org/synchronous-promise/-/synchronous-promise-2.0.15.tgz" | ||
integrity sha512-k8uzYIkIVwmT+TcglpdN50pS2y1BDcUnBPK9iJeGu0Pl1lOI8pD6wtzgw91Pjpe+RxtTncw32tLxs/R0yNL2Mg== | ||
|
||
tabbable@^6.0.1: | ||
version "6.2.0" | ||
resolved "https://registry.yarnpkg.com/tabbable/-/tabbable-6.2.0.tgz#732fb62bc0175cfcec257330be187dcfba1f3b97" | ||
integrity sha512-Cat63mxsVJlzYvN51JmVXIgNoUokrIaT2zLclCXjRd8boZ0004U4KCs/sToJ75C6sdlByWxpYnb5Boif1VSFew== | ||
|
||
tailwindcss@^3.1.3: | ||
version "3.1.3" | ||
resolved "https://registry.npmjs.org/tailwindcss/-/tailwindcss-3.1.3.tgz" | ||
|
@@ -11088,13 +11125,6 @@ timers-browserify@^2.0.4: | |
dependencies: | ||
setimmediate "^1.0.4" | ||
|
||
tippy.js@^6.3.1: | ||
version "6.3.7" | ||
resolved "https://registry.yarnpkg.com/tippy.js/-/tippy.js-6.3.7.tgz#8ccfb651d642010ed9a32ff29b0e9e19c5b8c61c" | ||
integrity sha512-E1d3oP2emgJ9dRQZdf3Kkn0qJgI6ZLpyS5z6ZkY1DF3kaQaBsGZsndEpHwx+eC+tYM41HaSNvNtLx8tU57FzTQ== | ||
dependencies: | ||
"@popperjs/core" "^2.9.0" | ||
|
||
[email protected]: | ||
version "1.0.5" | ||
resolved "https://registry.npmjs.org/tmpl/-/tmpl-1.0.5.tgz" | ||
|