Skip to content

Commit 78c1fd5

Browse files
committed
fix: some react router followup fixes
1 parent b74adaf commit 78c1fd5

File tree

9 files changed

+459
-207
lines changed

9 files changed

+459
-207
lines changed

app/root.res

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,17 +52,13 @@ let default = () => {
5252
<html>
5353
<head>
5454
<style> {React.string("html {opacity:0;}")} </style>
55-
<link rel="preload" href={mainCss} as_="css" />
56-
// Preload the fonts used for the above the fold on the homepage
57-
<link rel="preload" href="/fonts/subset-Inter-Bold.woff2" as_="font" />
58-
<link rel="preload" href="/fonts/subset-Inter-Regular.woff2" as_="font" />
55+
<link rel="preload" href={mainCss} as_="style" />
5956
<link rel="stylesheet" href={mainCss} />
60-
61-
<Links />
62-
<Meta />
6357
<link rel="stylesheet" href={hljsCss} />
6458
<link rel="stylesheet" href={utilsCss} />
6559
<link rel="icon" href="/favicon.ico" />
60+
<Links />
61+
<Meta />
6662
<meta
6763
name="viewport"
6864
content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1, minimal-ui"

generate-route-types.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ const paths = routes.map((route) => `#"/${route.path}"`).join(" |\n");
1818
await fs.writeFile(
1919
"src/Path.res",
2020
`type t = [
21+
#"/" |
2122
${paths}
2223
]
2324
`,

src/ApiDocs.res

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ type item =
4646

4747
module RightSidebar = {
4848
@react.component
49-
let make = (~items: array<item>) => {
49+
let make = (~items: array<item>, ~onClick) => {
5050
items
5151
->Array.map(item => {
5252
switch item {
@@ -67,10 +67,11 @@ module RightSidebar = {
6767
let title = `${Option.isSome(deprecatedIcon) ? "Deprecated " : ""}` ++ name
6868
let result =
6969
<li className="my-3" key={href}>
70-
<a
70+
<ReactRouter.Link.String
7171
title
7272
className="flex items-center w-full font-normal text-14 text-gray-40 leading-tight hover:text-gray-80"
73-
href
73+
to=href
74+
onClick={_ => onClick()}
7475
>
7576
<div
7677
className={`${bgColor} min-w-[20px] min-h-[20px] w-5 h-5 mr-3 flex justify-center items-center rounded-xl`}
@@ -84,7 +85,7 @@ module RightSidebar = {
8485
| Some(icon) => icon
8586
| None => React.null
8687
}}
87-
</a>
88+
</ReactRouter.Link.String>
8889
</li>
8990
result
9091
}
@@ -115,7 +116,7 @@ module SidebarTree = {
115116
| true =>
116117
<div className={"xl:hidden ml-5"} dataTestId={`submenu-${node.name}`}>
117118
<ul className={"list-none py-0.5"}>
118-
<RightSidebar items />
119+
<RightSidebar items onClick=toggle />
119120
</ul>
120121
</div>
121122
| false => React.null
@@ -286,9 +287,14 @@ module DocstringsStylize = {
286287
}
287288

288289
let make = (props: props) => {
290+
let (_, setScrollLock) = ScrollLockContext.useScrollLock()
289291
let (isSidebarOpen, setSidebarOpen) = React.useState(_ => true)
290292

291-
let toggleSidebar = () => setSidebarOpen(prev => !prev)
293+
let toggleSidebar = () =>
294+
setSidebarOpen(prev => {
295+
setScrollLock(_ => !prev)
296+
!prev
297+
})
292298

293299
let children = {
294300
open Markdown
@@ -337,7 +343,7 @@ let make = (props: props) => {
337343
{"Types and values"->React.string}
338344
</div>
339345
<ul>
340-
<RightSidebar items />
346+
<RightSidebar items onClick=toggleSidebar />
341347
</ul>
342348
</aside>
343349
</div>

0 commit comments

Comments
 (0)