Skip to content

Commit fd95a74

Browse files
committed
Convert modalReturn to chakra
1 parent 80f04d2 commit fd95a74

File tree

1 file changed

+13
-15
lines changed

1 file changed

+13
-15
lines changed

src/components/Tooltip.tsx

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,31 @@
11
import React, { ReactNode, useState } from "react"
2-
import styled from "@emotion/styled"
32
import { Box } from "@chakra-ui/react"
43
import * as utils from "../utils/isMobile"
54

6-
// Invisible full screen div "below" the clickable link
7-
// Added so clicking away anywhere will hide Tooltip
8-
const ModalReturn = styled.div`
9-
position: fixed;
10-
top: 0;
11-
left: 0;
12-
width: 100%;
13-
height: 100%;
14-
z-index: 1;
15-
`
16-
175
export interface IProps {
186
content: ReactNode
197
children?: React.ReactNode
208
}
219

2210
// TODO add `position` prop
2311
const Tooltip: React.FC<IProps> = ({ content, children }) => {
24-
const [isVisible, setIsVisible] = useState<boolean>(true)
12+
const [isVisible, setIsVisible] = useState<boolean>(false)
2513
const isMobile = utils.isMobile()
2614

2715
return (
2816
<>
2917
{isVisible && isMobile && (
30-
<ModalReturn onClick={() => setIsVisible(false)} />
18+
// Invisible full screen div "below" the clickable link
19+
// Added so clicking away anywhere will hide Tooltip
20+
<Box
21+
position="fixed"
22+
top={0}
23+
left={0}
24+
w="full"
25+
h="full"
26+
zIndex={1}
27+
onClick={() => setIsVisible(false)}
28+
/>
3129
)}
3230
<Box
3331
position="relative"
@@ -36,7 +34,7 @@ const Tooltip: React.FC<IProps> = ({ content, children }) => {
3634
cursor="pointer"
3735
title="More info"
3836
onMouseEnter={!isMobile ? () => setIsVisible(true) : undefined}
39-
onMouseLeave={!isMobile ? () => setIsVisible(true) : undefined}
37+
onMouseLeave={!isMobile ? () => setIsVisible(false) : undefined}
4038
onClick={isMobile ? () => setIsVisible(!isVisible) : undefined}
4139
>
4240
{children}

0 commit comments

Comments
 (0)