Skip to content

Commit 730208c

Browse files
committed
migrate GlossaryTooltip
1 parent 6a5c2eb commit 730208c

File tree

2 files changed

+12
-29
lines changed

2 files changed

+12
-29
lines changed

src/components/Glossary/GlossaryTooltip/index.tsx

Lines changed: 10 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import React, { ReactNode } from "react"
22
import { useRouter } from "next/router"
3-
import { Box, Text, VStack } from "@chakra-ui/react"
43

5-
import Heading from "@/components/Heading"
64
import InlineLink from "@/components/Link"
75
import Tooltip, { type TooltipProps } from "@/components/Tooltip"
86
import Translation from "@/components/Translation"
@@ -23,36 +21,36 @@ const GlossaryTooltip = ({
2321
const { asPath } = useRouter()
2422

2523
return (
26-
<Box as="span" display="inline-block">
24+
<span className="inline-block">
2725
<Tooltip
2826
{...props}
2927
content={
30-
<VStack spacing={2} align="stretch" textAlign="start">
31-
<Heading as="h6">
28+
<div className="flex flex-col items-stretch gap-2 text-start">
29+
<h6>
3230
<Translation
3331
id={termKey + "-term"}
3432
options={{ ns: "glossary-tooltip" }}
3533
// Override the default `a` tag transformation to avoid circular
3634
// dependency issues
3735
transform={{ a: InlineLink }}
3836
/>
39-
</Heading>
37+
</h6>
4038
{/**
4139
* `as="span"` prevents hydration warnings for strings that contain
4240
* elements that cannot be nested inside `p` tags, like `ul` tags
4341
* (found in some Glossary definition).
4442
* TODO: Develop a better solution to handle this case.
4543
*/}
46-
<Text as="span">
44+
<span>
4745
<Translation
4846
id={termKey + "-definition"}
4947
options={{ ns: "glossary-tooltip" }}
5048
// Override the default `a` tag transformation to avoid circular
5149
// dependency issues
5250
transform={{ a: InlineLink }}
5351
/>
54-
</Text>
55-
</VStack>
52+
</span>
53+
</div>
5654
}
5755
onBeforeOpen={() => {
5856
trackCustomEvent({
@@ -62,20 +60,11 @@ const GlossaryTooltip = ({
6260
})
6361
}}
6462
>
65-
<Text
66-
as="u"
67-
textDecorationStyle="dotted"
68-
textUnderlineOffset="3px"
69-
_hover={{
70-
textDecorationColor: "primary.hover",
71-
color: "primary.hover",
72-
}}
73-
cursor="help"
74-
>
63+
<u className="cursor-help decoration-dotted underline-offset-3 hover:text-primary-hover hover:decoration-primary-hover">
7564
{children}
76-
</Text>
65+
</u>
7766
</Tooltip>
78-
</Box>
67+
</span>
7968
)
8069
}
8170

src/components/Tooltip/index.tsx

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import React, { ReactNode, useEffect } from "react"
2-
import { PopoverProps } from "@chakra-ui/react"
32

43
import { isMobile } from "@/lib/utils/isMobile"
54

@@ -12,18 +11,13 @@ import {
1211

1312
import { useDisclosure } from "@/hooks/useDisclosure"
1413

15-
export interface TooltipProps extends PopoverProps {
14+
export type TooltipProps = {
1615
content: ReactNode
1716
children?: ReactNode
1817
onBeforeOpen?: () => void
1918
}
2019

21-
const Tooltip = ({
22-
content,
23-
children,
24-
onBeforeOpen,
25-
// ...rest
26-
}: TooltipProps) => {
20+
const Tooltip = ({ content, children, onBeforeOpen }: TooltipProps) => {
2721
const { isOpen, onOpen, onClose } = useDisclosure()
2822

2923
// Close the popover when the user scrolls.

0 commit comments

Comments
 (0)