Skip to content

Commit 80f04d2

Browse files
committed
convert arrow to chakra
1 parent 12baa13 commit 80f04d2

File tree

1 file changed

+18
-13
lines changed

1 file changed

+18
-13
lines changed

src/components/Tooltip.tsx

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,8 @@
11
import React, { ReactNode, useState } from "react"
22
import styled from "@emotion/styled"
3-
import { Box, calc } from "@chakra-ui/react"
3+
import { Box } from "@chakra-ui/react"
44
import * as utils from "../utils/isMobile"
55

6-
const Arrow = styled.span`
7-
position: absolute;
8-
bottom: -0.5rem;
9-
left: calc(50% - 6px);
10-
border-right: 10px solid transparent;
11-
border-top: 10px solid ${({ theme }) => theme.colors.background};
12-
border-left: 10px solid transparent;
13-
`
14-
156
// Invisible full screen div "below" the clickable link
167
// Added so clicking away anywhere will hide Tooltip
178
const ModalReturn = styled.div`
@@ -30,7 +21,7 @@ export interface IProps {
3021

3122
// TODO add `position` prop
3223
const Tooltip: React.FC<IProps> = ({ content, children }) => {
33-
const [isVisible, setIsVisible] = useState<boolean>(false)
24+
const [isVisible, setIsVisible] = useState<boolean>(true)
3425
const isMobile = utils.isMobile()
3526

3627
return (
@@ -45,7 +36,7 @@ const Tooltip: React.FC<IProps> = ({ content, children }) => {
4536
cursor="pointer"
4637
title="More info"
4738
onMouseEnter={!isMobile ? () => setIsVisible(true) : undefined}
48-
onMouseLeave={!isMobile ? () => setIsVisible(false) : undefined}
39+
onMouseLeave={!isMobile ? () => setIsVisible(true) : undefined}
4940
onClick={isMobile ? () => setIsVisible(!isVisible) : undefined}
5041
>
5142
{children}
@@ -70,7 +61,21 @@ const Tooltip: React.FC<IProps> = ({ content, children }) => {
7061
left="25%"
7162
transform="translateX(-50%)"
7263
>
73-
<Arrow />
64+
<Box
65+
as="span"
66+
position="absolute"
67+
bottom={-2}
68+
left="calc(50% - 6px)"
69+
borderRightWidth={10}
70+
borderRightStyle="solid"
71+
borderRightColor="transparent"
72+
borderTopWidth={10}
73+
borderTopStyle="solid"
74+
borderTopColor="background"
75+
borderLeftWidth={10}
76+
borderLeftStyle="solid"
77+
borderLeftColor="transparent"
78+
/>
7479
{content}
7580
</Box>
7681
)}

0 commit comments

Comments
 (0)