File tree 10 files changed +103
-17
lines changed
10 files changed +103
-17
lines changed Original file line number Diff line number Diff line change
1
+ import "server-only" ;
2
+
3
+ import { FernNavigation } from "@fern-api/fdr-sdk" ;
4
+ import { slugjoin } from "@fern-api/fdr-sdk/navigation" ;
5
+
6
+ import { getFernToken } from "@/app/fern-token" ;
7
+ import { ProductDropdown } from "@/components/header/ProductDropdown" ;
8
+ import { createCachedDocsLoader } from "@/server/docs-loader" ;
9
+
10
+ export default async function VersionSelectPage ( {
11
+ params,
12
+ } : {
13
+ params : Promise < { host : string ; domain : string ; slug : string } > ;
14
+ } ) {
15
+ const { host, domain, slug } = await params ;
16
+ const loader = await createCachedDocsLoader (
17
+ host ,
18
+ domain ,
19
+ await getFernToken ( )
20
+ ) ;
21
+
22
+ const rootPromise = loader . getRoot ( ) ;
23
+
24
+ // preload:
25
+ await loader . getLayout ( ) ;
26
+ await loader . getAuthState ( ) ;
27
+ await loader . getEdgeFlags ( ) ;
28
+
29
+ const foundNode = FernNavigation . utils . findNode (
30
+ await rootPromise ,
31
+ slugjoin ( slug )
32
+ ) ;
33
+ if ( foundNode . type !== "found" ) {
34
+ return null ;
35
+ }
36
+
37
+ return < ProductDropdown loader = { loader } /> ;
38
+ }
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ export default async function Layout({
10
10
headertabs,
11
11
sidebar,
12
12
versionSelect,
13
+ productSelect,
13
14
logo,
14
15
explorer,
15
16
} : {
@@ -18,6 +19,7 @@ export default async function Layout({
18
19
headertabs : React . ReactNode ;
19
20
sidebar : React . ReactNode ;
20
21
versionSelect : React . ReactNode ;
22
+ productSelect : React . ReactNode ;
21
23
logo : React . ReactNode ;
22
24
explorer : React . ReactNode ;
23
25
} ) {
@@ -30,6 +32,7 @@ export default async function Layout({
30
32
loader = { loader }
31
33
headertabs = { headertabs }
32
34
versionSelect = { versionSelect }
35
+ productSelect = { productSelect }
33
36
sidebar = { sidebar }
34
37
logo = { logo }
35
38
>
Original file line number Diff line number Diff line change
1
+ import "server-only" ;
2
+
3
+ import { FernNavigation } from "@fern-api/fdr-sdk" ;
4
+ import { slugjoin } from "@fern-api/fdr-sdk/navigation" ;
5
+
6
+ import { getFernToken } from "@/app/fern-token" ;
7
+ import { ProductDropdown } from "@/components/header/ProductDropdown" ;
8
+ import { createCachedDocsLoader } from "@/server/docs-loader" ;
9
+
10
+ export default async function VersionSelectPage ( {
11
+ params,
12
+ } : {
13
+ params : Promise < { host : string ; domain : string ; slug : string } > ;
14
+ } ) {
15
+ const { host, domain, slug } = await params ;
16
+ const loader = await createCachedDocsLoader (
17
+ host ,
18
+ domain ,
19
+ await getFernToken ( )
20
+ ) ;
21
+
22
+ const rootPromise = loader . getRoot ( ) ;
23
+
24
+ // preload:
25
+ await loader . getLayout ( ) ;
26
+ await loader . getAuthState ( ) ;
27
+ await loader . getEdgeFlags ( ) ;
28
+
29
+ const foundNode = FernNavigation . utils . findNode (
30
+ await rootPromise ,
31
+ slugjoin ( slug )
32
+ ) ;
33
+ if ( foundNode . type !== "found" ) {
34
+ return null ;
35
+ }
36
+
37
+ return < ProductDropdown loader = { loader } /> ;
38
+ }
Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ export default async function Layout({
9
9
headertabs,
10
10
sidebar,
11
11
versionSelect,
12
+ productSelect,
12
13
logo,
13
14
explorer,
14
15
} : {
@@ -17,6 +18,7 @@ export default async function Layout({
17
18
headertabs : React . ReactNode ;
18
19
sidebar : React . ReactNode ;
19
20
versionSelect : React . ReactNode ;
21
+ productSelect : React . ReactNode ;
20
22
logo : React . ReactNode ;
21
23
explorer : React . ReactNode ;
22
24
} ) {
@@ -27,6 +29,7 @@ export default async function Layout({
27
29
loader = { loader }
28
30
headertabs = { headertabs }
29
31
versionSelect = { versionSelect }
32
+ productSelect = { productSelect }
30
33
sidebar = { sidebar }
31
34
logo = { logo }
32
35
>
Original file line number Diff line number Diff line change @@ -41,7 +41,7 @@ export function HeaderContent({
41
41
>
42
42
< div className = "fern-header-logo-container" >
43
43
< div className = "flex items-center gap-2" >
44
- < div className = "flex items-start gap-2" >
44
+ < div className = "flex items-center gap-2 lg:items-start " >
45
45
{ logo }
46
46
{ productSelect }
47
47
</ div >
Original file line number Diff line number Diff line change @@ -85,10 +85,10 @@ export function ProductDropdownClient({
85
85
side = "bottom"
86
86
align = "start"
87
87
>
88
- < button className = "rounded-3/2 hover:bg-(color:--grayscale-a4) flex cursor-pointer items-center gap-1 self-baseline px-2 transition-[background-color]" >
89
- { currentProduct ?. title }
88
+ < div className = "product-dropdown-trigger rounded-3/2 hover:bg-(color:--grayscale-a4) flex cursor-pointer items-center gap-1 self-baseline px-2 transition-[background-color]" >
89
+ < p className = "product-item-title" > { currentProduct ?. title } </ p >
90
90
< ChevronDown className = "size-icon transition-transform data-[state=open]:rotate-180" />
91
- </ button >
91
+ </ div >
92
92
</ FernProductDropdown >
93
93
) ;
94
94
Original file line number Diff line number Diff line change @@ -13,21 +13,22 @@ import { DocsLoader } from "@/server/docs-loader";
13
13
import { isLocal } from "@/server/isLocal" ;
14
14
import { createCachedMdxSerializer } from "@/server/mdx-serializer" ;
15
15
16
- import { ProductDropdown } from "./header/ProductDropdown" ;
17
16
import { LoginButton } from "./login-button" ;
18
17
19
18
export default async function SharedLayout ( {
20
19
children,
21
20
headertabs,
22
21
sidebar,
23
22
versionSelect,
23
+ productSelect,
24
24
loader,
25
25
logo,
26
26
} : {
27
27
children : React . ReactNode ;
28
28
headertabs : React . ReactNode ;
29
29
sidebar ?: React . ReactNode ;
30
30
versionSelect : React . ReactNode ;
31
+ productSelect : React . ReactNode ;
31
32
loader : DocsLoader ;
32
33
logo : React . ReactNode ;
33
34
} ) {
@@ -85,9 +86,7 @@ export default async function SharedLayout({
85
86
< React . Suspense fallback = { null } > { versionSelect } </ React . Suspense >
86
87
}
87
88
productSelect = {
88
- < React . Suspense fallback = { null } >
89
- < ProductDropdown loader = { loader } />
90
- </ React . Suspense >
89
+ < React . Suspense fallback = { null } > { productSelect } </ React . Suspense >
91
90
}
92
91
showSearchBar = { layout . searchbarPlacement === "HEADER" }
93
92
navbarLinks = { < NavbarLinks loader = { loader } /> }
Original file line number Diff line number Diff line change @@ -60,7 +60,6 @@ import { FernFonts, generateFonts } from "./generateFonts";
60
60
import { getDocsUrlMetadata } from "./getDocsUrlMetadata" ;
61
61
import { isLocal } from "./isLocal" ;
62
62
import { loadWithUrl as uncachedLoadWithUrl } from "./loadWithUrl" ;
63
- import { MOCK_DATA_WITH_PRODUCTS } from "./mock-data" ;
64
63
import { postToEngineeringNotifs } from "./slack" ;
65
64
import { FernColorTheme , FernLayoutConfig , FileData } from "./types" ;
66
65
import { cleanBasePath } from "./utils/clean-base-path" ;
@@ -597,9 +596,6 @@ const getRoot = async (
597
596
root = pruneWithAuthState ( authState , authConfig , root ) ;
598
597
}
599
598
600
- // TODO: remove this to restore the real root. this overrides to show the mock root for testing
601
- root = MOCK_DATA_WITH_PRODUCTS ;
602
-
603
599
FernNavigation . utils . mutableUpdatePointsTo ( root ) ;
604
600
605
601
return root ;
Original file line number Diff line number Diff line change 20
20
}
21
21
}
22
22
23
+ /* Styles for making the product dropdown trigger look like an icon button on mobile. */
24
+ .product-dropdown-trigger {
25
+ @apply py-2 lg :py- 0;
26
+ @apply rounded-2 bg- (color :--grayscale-a2 ) lg :bg- transparent;
27
+ }
28
+ .product-item-title {
29
+ @apply hidden lg :block ;
30
+ }
31
+
23
32
/* We define the styles for the product dropdown item outside of the .fern-dropdown class since it is reused within
24
33
multiple dropdowns. */
25
34
.fern-product-item {
26
- @apply rounded- 3/2 flex cursor-pointer items-center gap-2 border-none px-2 py- 1 ;
27
- @apply max-w- [ min (300 px ,100%)] ;
35
+ @apply rounded- 3/2 flex cursor-pointer items-center gap-2 border-none py-1 pl-1 pr- 4 ;
36
+ @apply w-full ;
28
37
@apply transition-all duration-200 ease-in-out ;
29
38
30
39
.fern-product-item-icon {
31
40
@apply rounded- 3/2 border- (color :--grayscale-a9 ) border ;
32
- @apply m-1 flex h- [42px ] w- [42px ] shrink-0 items-center justify-center p- 1;
41
+ @apply m-1 flex h- [56px ] w- [56px ] shrink-0 items-center justify-center p- 1;
33
42
svg {
34
43
@apply block h- [60%] w- [60%];
35
44
}
Original file line number Diff line number Diff line change @@ -25,8 +25,8 @@ export function FernProductItem({
25
25
>
26
26
< div className = "fern-product-item-icon" > { option . icon } </ div >
27
27
28
- < div className = "flex flex-col" >
29
- < p className = "text-sm font-medium leading-tight" > { option . title } </ p >
28
+ < div className = "flex flex-col gap-1 " >
29
+ < p className = "text-sm font-bold leading-tight" > { option . title } </ p >
30
30
{ option . subtitle ? (
31
31
< p className = "text-(color:--grayscale-a9) text-sm leading-tight" >
32
32
{ option . subtitle }
You can’t perform that action at this time.
0 commit comments