1
1
'use client' ;
2
2
import { tcls } from '@/lib/tailwind' ;
3
3
import { Icon } from '@gitbook/icons' ;
4
- import * as Tooltip from '@radix-ui/react-tooltip' ;
5
4
import { Fragment } from 'react' ;
6
- import { Button , StyledLink } from '../../primitives' ;
5
+ import { Button , HoverCard , HoverCardRoot , HoverCardTrigger , StyledLink } from '../../primitives' ;
7
6
8
7
export function InlineLinkTooltipImpl ( props : {
9
8
isSamePage : boolean ;
@@ -21,89 +20,76 @@ export function InlineLinkTooltipImpl(props: {
21
20
const { isSamePage, isExternal, openInNewTabLabel, target, breadcrumbs, children } = props ;
22
21
23
22
return (
24
- < Tooltip . Provider delayDuration = { 200 } >
25
- < Tooltip . Root >
26
- < Tooltip . Trigger asChild > { children } </ Tooltip . Trigger >
27
- < Tooltip . Portal >
28
- < Tooltip . Content className = "z-40 w-screen max-w-md animate-present px-4 sm:w-auto" >
29
- < div className = "overflow-hidden rounded-md straight-corners:rounded-none shadow-lg shadow-tint-12/4 ring-1 ring-tint-subtle dark:shadow-tint-1 " >
30
- < div className = "bg-tint-base p-4" >
31
- < div className = "flex items-start gap-4" >
32
- < div className = "flex flex-col" >
33
- { breadcrumbs && breadcrumbs . length > 0 ? (
34
- < div className = "mb-1 flex grow flex-wrap items-center gap-x-2 gap-y-0.5 font-semibold text-tint text-xs uppercase leading-tight tracking-wide" >
35
- { breadcrumbs . map ( ( crumb , index ) => {
36
- const Tag = crumb . href ? StyledLink : 'div' ;
23
+ < HoverCardRoot >
24
+ < HoverCardTrigger > { children } </ HoverCardTrigger >
25
+ < HoverCard className = "p-4" >
26
+ < div className = "flex items-start gap-4" >
27
+ < div className = "flex flex-col" >
28
+ { breadcrumbs && breadcrumbs . length > 0 ? (
29
+ < div className = "mb-1 flex grow flex-wrap items-center gap-x-2 gap-y-0.5 font-semibold text-tint text-xs uppercase leading-tight tracking-wide" >
30
+ { breadcrumbs . map ( ( crumb , index ) => {
31
+ const Tag = crumb . href ? StyledLink : 'div' ;
37
32
38
- return (
39
- < Fragment key = { crumb . label } >
40
- { index !== 0 ? (
41
- < Icon
42
- icon = "chevron-right"
43
- className = "size-3 text-tint-subtle"
44
- />
45
- ) : null }
46
- < Tag
47
- className = { tcls (
48
- 'flex gap-1' ,
49
- crumb . href &&
50
- 'links-default:text-tint no-underline hover:underline contrast-more:underline contrast-more:decoration-current'
51
- ) }
52
- href = { crumb . href ?? '#' }
53
- >
54
- { crumb . icon ? (
55
- < span className = "mt-0.5 text-tint-subtle empty:hidden" >
56
- { crumb . icon }
57
- </ span >
58
- ) : null }
59
- { crumb . label }
60
- </ Tag >
61
- </ Fragment >
62
- ) ;
63
- } ) }
64
- </ div >
65
- ) : null }
66
- < div
67
- className = { tcls (
68
- 'flex gap-2 leading-snug' ,
69
- isExternal && 'text-sm [overflow-wrap:anywhere]'
70
- ) }
71
- >
72
- { target . icon ? (
73
- < div className = "mt-1 text-tint-subtle empty:hidden" >
74
- { target . icon }
75
- </ div >
33
+ return (
34
+ < Fragment key = { crumb . label } >
35
+ { index !== 0 ? (
36
+ < Icon
37
+ icon = "chevron-right"
38
+ className = "size-3 text-tint-subtle"
39
+ />
76
40
) : null }
77
- < h5 className = "font-semibold" > { target . text } </ h5 >
78
- </ div >
79
- </ div >
80
- { ! isSamePage && target . href ? (
81
- < Button
82
- className = { tcls (
83
- '-mx-2 -my-2 ml-auto' ,
84
- breadcrumbs ?. length === 0
85
- ? 'place-self-center'
86
- : null
87
- ) }
88
- variant = "blank"
89
- href = { target . href }
90
- target = "_blank"
91
- label = { openInNewTabLabel }
92
- size = "small"
93
- icon = "arrow-up-right-from-square"
94
- iconOnly = { true }
95
- />
96
- ) : null }
97
- </ div >
98
- { target . subText ? (
99
- < p className = "mt-1 text-sm text-tint" > { target . subText } </ p >
100
- ) : null }
41
+ < Tag
42
+ className = { tcls (
43
+ 'flex gap-1' ,
44
+ crumb . href &&
45
+ 'links-default:text-tint no-underline hover:underline contrast-more:underline contrast-more:decoration-current'
46
+ ) }
47
+ href = { crumb . href ?? '#' }
48
+ >
49
+ { crumb . icon ? (
50
+ < span className = "mt-0.5 text-tint-subtle empty:hidden" >
51
+ { crumb . icon }
52
+ </ span >
53
+ ) : null }
54
+ { crumb . label }
55
+ </ Tag >
56
+ </ Fragment >
57
+ ) ;
58
+ } ) }
101
59
</ div >
60
+ ) : null }
61
+ < div
62
+ className = { tcls (
63
+ 'flex gap-2 leading-snug' ,
64
+ isExternal && 'text-sm [overflow-wrap:anywhere]'
65
+ ) }
66
+ >
67
+ { target . icon ? (
68
+ < div className = "mt-1 text-tint-subtle empty:hidden" >
69
+ { target . icon }
70
+ </ div >
71
+ ) : null }
72
+ < h5 className = "font-semibold" > { target . text } </ h5 >
102
73
</ div >
103
- < Tooltip . Arrow className = "fill-tint-1" />
104
- </ Tooltip . Content >
105
- </ Tooltip . Portal >
106
- </ Tooltip . Root >
107
- </ Tooltip . Provider >
74
+ </ div >
75
+ { ! isSamePage && target . href ? (
76
+ < Button
77
+ className = { tcls (
78
+ '-mx-2 -my-2 ml-auto' ,
79
+ breadcrumbs ?. length === 0 ? 'place-self-center' : null
80
+ ) }
81
+ variant = "blank"
82
+ href = { target . href }
83
+ target = "_blank"
84
+ label = { openInNewTabLabel }
85
+ size = "small"
86
+ icon = "arrow-up-right-from-square"
87
+ iconOnly = { true }
88
+ />
89
+ ) : null }
90
+ </ div >
91
+ { target . subText ? < p className = "mt-1 text-sm text-tint" > { target . subText } </ p > : null }
92
+ </ HoverCard >
93
+ </ HoverCardRoot >
108
94
) ;
109
95
}
0 commit comments