File tree 3 files changed +30
-6
lines changed
packages/fern-docs/bundle/src/components
3 files changed +30
-6
lines changed Original file line number Diff line number Diff line change
1
+ "use client" ;
2
+
3
+ import { useDispatchSidebarAction } from "@/state/navigation" ;
4
+
5
+ import { FernLink } from "./FernLink" ;
6
+
7
+ export function FernLinkTab ( {
8
+ children,
9
+ ...props
10
+ } : React . ComponentProps < typeof FernLink > ) {
11
+ const dispatch = useDispatchSidebarAction ( ) ;
12
+ return (
13
+ < FernLink
14
+ { ...props }
15
+ onClick = { ( ) => {
16
+ dispatch ( { type : "collapse-all" } ) ;
17
+ } }
18
+ >
19
+ { children }
20
+ </ FernLink >
21
+ ) ;
22
+ }
Original file line number Diff line number Diff line change @@ -7,9 +7,10 @@ import { TabChild, hasRedirect } from "@fern-api/fdr-sdk/navigation";
7
7
import { cn } from "@fern-docs/components" ;
8
8
import { slugToHref } from "@fern-docs/utils" ;
9
9
10
- import { FernLink } from "@/components/FernLink" ;
11
10
import { FaIconServer } from "@/components/fa-icon-server" ;
12
11
12
+ import { FernLinkTab } from "../FernLinkTab" ;
13
+
13
14
export function HeaderTabsList ( {
14
15
tabs,
15
16
children,
@@ -21,22 +22,23 @@ export function HeaderTabsList({
21
22
< Tabs . TabsList >
22
23
{ tabs . map ( ( tab ) => (
23
24
< Tabs . TabsTrigger key = { tab . id } value = { tab . id } asChild >
24
- < FernLink
25
+ < FernLinkTab
25
26
className = { cn ( { "opacity-50" : tab . type !== "link" && tab . hidden } ) }
26
27
href = {
27
28
tab . type === "link"
28
29
? tab . url
29
30
: slugToHref ( hasRedirect ( tab ) ? tab . pointsTo : tab . slug )
30
31
}
31
32
scroll = { true }
33
+ id = { tab . id }
32
34
>
33
35
{ tab . type !== "link" && tab . authed ? (
34
36
< Lock />
35
37
) : (
36
38
tab . icon && < FaIconServer icon = { tab . icon } />
37
39
) }
38
40
< span className = "truncate" > { tab . title } </ span >
39
- </ FernLink >
41
+ </ FernLinkTab >
40
42
</ Tabs . TabsTrigger >
41
43
) ) }
42
44
{ children }
Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ import { TabChild, hasRedirect } from "@fern-api/fdr-sdk/navigation";
7
7
import { cn } from "@fern-docs/components" ;
8
8
import { slugToHref } from "@fern-docs/utils" ;
9
9
10
- import { FernLink } from "@/components/FernLink " ;
10
+ import { FernLinkTab } from "@/components/FernLinkTab " ;
11
11
import { FaIconServer } from "@/components/fa-icon-server" ;
12
12
13
13
export function SidebarTabsList ( {
@@ -21,7 +21,7 @@ export function SidebarTabsList({
21
21
< Tabs . TabsList className = "-my-2" >
22
22
{ tabs . map ( ( tab ) => (
23
23
< Tabs . TabsTrigger key = { tab . id } value = { tab . id } asChild >
24
- < FernLink
24
+ < FernLinkTab
25
25
className = { cn (
26
26
"min-h-8 lg:min-h-9" ,
27
27
"hover:text-(color:--accent) rounded-2 group flex min-w-0 flex-1 select-none items-center justify-start py-2 text-base lg:px-3 lg:text-sm" ,
@@ -51,7 +51,7 @@ export function SidebarTabsList({
51
51
< span className = "truncate font-medium group-data-[state=active]:font-semibold" >
52
52
{ tab . title }
53
53
</ span >
54
- </ FernLink >
54
+ </ FernLinkTab >
55
55
</ Tabs . TabsTrigger >
56
56
) ) }
57
57
{ children }
You can’t perform that action at this time.
0 commit comments