1
1
import { ComponentProps } from "react"
2
- import { type HeadingProps , Text , VStack } from "@chakra-ui/react"
3
2
4
- import Heading from "@/components/Heading"
5
3
import IdAnchor from "@/components/IdAnchor"
6
- import InlineLink from "@/components/Link"
7
4
import Translation from "@/components/Translation"
5
+ import { Stack } from "@/components/ui/flex"
6
+ import InlineLink from "@/components/ui/Link"
7
+
8
+ import { cn } from "@/lib/utils/cn"
8
9
9
10
import { DEFAULT_GLOSSARY_NS } from "@/lib/constants"
10
11
@@ -25,42 +26,30 @@ const GlossaryDefinition = ({
25
26
size = "md" ,
26
27
options = { ns : DEFAULT_GLOSSARY_NS } ,
27
28
} : GlossaryDefinitionProps ) => {
28
- const textStyles = size === "sm" ? { mb : 0 } : { }
29
-
30
- const headingPropsForAnchor = ( id ?: string ) : HeadingProps => {
31
- if ( ! id ) return { }
32
- return {
33
- scrollMarginTop : 28 ,
34
- id,
35
- "data-group" : true ,
36
- position : "relative" ,
37
- } as HeadingProps
38
- }
29
+ const textClasses = size === "sm" ? "mb-0" : ""
39
30
40
31
return (
41
- < VStack spacing = { 4 } align = "stretch" textAlign = "start" mb = { 8 } >
42
- < Heading size = "md" { ...headingPropsForAnchor ( term ) } >
32
+ < Stack className = "mb-8 items-stretch gap-4 text-start" >
33
+ < h4
34
+ className = { term ? "relative scroll-mt-28" : "" }
35
+ { ...( term ? { "data-group" : true , id : term } : { } ) }
36
+ >
43
37
< IdAnchor id = { term } />
44
38
< Translation
45
39
id = { term + "-term" }
46
40
options = { options }
47
41
transform = { components }
48
42
/>
49
- </ Heading >
50
- { /**
51
- * `as="span"` prevents hydration warnings for strings that contain
52
- * elements that cannot be nested inside `p` tags, like `ul` tags
53
- * (found in some Glossary definition).
54
- * TODO: Develop a better solution to handle this case.
55
- */ }
56
- < Text as = "span" { ...textStyles } >
43
+ </ h4 >
44
+
45
+ < div className = { cn ( "inline-block" , textClasses ) } >
57
46
< Translation
58
47
id = { term + "-definition" }
59
48
options = { options }
60
49
transform = { components }
61
50
/>
62
- </ Text >
63
- </ VStack >
51
+ </ div >
52
+ </ Stack >
64
53
)
65
54
}
66
55
0 commit comments