Skip to content

Commit 06cda6b

Browse files
committed
fix sidebar top padding
1 parent 916ec45 commit 06cda6b

File tree

5 files changed

+30
-10
lines changed

5 files changed

+30
-10
lines changed

app/routes/MdxRoute.res

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ let default = () => {
308308
breadcrumbs=?loaderData.breadcrumbs
309309
editHref={`https://github.com/rescript-lang/rescript-lang.org/blob/master${loaderData.filePath->Option.getOrThrow}`}
310310
>
311-
<div className="markdown-body pt-20 md:pt-0"> {component()} </div>
311+
<div className="markdown-body"> {component()} </div>
312312
</DocsLayout>
313313
</>
314314
} else if (pathname :> string)->String.includes("community") {

src/ApiDocs.res

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -196,25 +196,25 @@ module SidebarTree = {
196196
id="sidebar"
197197
className={(
198198
isOpen ? "fixed w-full left-0 h-full z-20 min-w-320" : "hidden "
199-
) ++ " md:block md:w-48 md:-ml-4 lg:w-1/5 h-auto md:relative overflow-y-visible bg-white mt-28 md:mt-0"}
199+
) ++ " md:block md:w-48 md:-ml-4 lg:w-1/5 h-auto md:relative overflow-y-visible bg-white mt-16 md:mt-0"}
200200
>
201201
<aside
202202
id="sidebar-content-api-docs"
203203
className="w-80 h-full relative top-12 px-4 w-full block md:top-28 md:sticky border-r border-gray-20 overflow-y-auto pb-24 max-h-[calc(100vh-7rem)]"
204204
>
205-
<div className="flex justify-between">
206-
<div className="w-3/4 md:w-full"> React.null </div>
205+
<div className="flex justify-between items-center">
206+
{preludeSection}
207207
<button
208208
onClick={evt => {
209209
ReactEvent.Mouse.preventDefault(evt)
210210
toggle()
211211
}}
212-
className="md:hidden h-16"
212+
className="md:hidden h-auto"
213213
>
214214
<Icon.Close />
215215
</button>
216216
</div>
217-
{preludeSection}
217+
218218
<div className="my-10">
219219
<div className="hl-overline block text-gray-80 mt-5 mb-2" dataTestId="overview">
220220
{"Overview"->React.string}

src/components/Icon.res

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ module Table = {
159159
module Close = {
160160
@react.component
161161
let make = (~className: string="") =>
162-
<svg className={"fill-current " ++ className} width="12.728" height="12.728">
162+
<svg className={"fill-current " ++ className} width="16" height="16">
163163
<path d="M12.728 11.313l-1.414 1.414L0 1.414 1.414-.001z" />
164164
<path d="M11.314 0l1.414 1.414L1.415 12.728 0 11.314z" />
165165
</svg>

src/components/VersionSelect.res

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ let make = () => {
2828
{React.string(ver.label)}
2929
</a>
3030
})
31-
<div className="wrapper mt-4 block w-full" dataTestId="version-select">
31+
<div className="wrapper block w-full" dataTestId="version-select">
3232
<div id="older-versions" popover=Auto />
3333
<button
3434
className="trigger text-12 border border-gray-20 bg-gray-10 text-gray-80 inline-block rounded px-4 py-1 font-semibold whitespace-nowrap"

src/layouts/SidebarLayout.res

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,23 @@ module Sidebar = {
132132
) => {
133133
let isItemActive = (navItem: NavItem.t) => navItem.href === (route :> string)
134134

135+
// the height of the navbars above is fluid across pages, and it's easy to get it wrong
136+
// so we calculate it dynamically here
137+
let sidebarTopOffset = isOpen
138+
? {
139+
let mobileNavbarHeight =
140+
Nullable.make(document->WebAPI.Document.getElementById("mobile-navbar"))
141+
->Nullable.map(el => el.clientHeight)
142+
->Nullable.getOr(0)
143+
let docNavbarHeight =
144+
Nullable.make(document->WebAPI.Document.getElementById("doc-navbar"))
145+
->Nullable.map(el => el.clientHeight)
146+
->Nullable.getOr(0)
147+
148+
mobileNavbarHeight + docNavbarHeight + 8
149+
}
150+
: 0
151+
135152
let getActiveToc = (navItem: NavItem.t) => {
136153
if navItem.href === (route :> string) {
137154
activeToc
@@ -142,10 +159,13 @@ module Sidebar = {
142159

143160
<>
144161
<div
162+
style={{
163+
paddingTop: `${sidebarTopOffset->Int.toString}px`,
164+
}}
145165
id="sidebar"
146166
className={(
147167
isOpen ? "fixed w-full left-0 h-full z-20 min-w-320" : "hidden "
148-
) ++ " md:block md:w-48 md:-ml-4 lg:w-1/5 h-auto md:relative overflow-y-visible mt-10 pt-2 bg-white md:mt-0 min-w-48"}
168+
) ++ " md:block md:w-48 md:-ml-4 lg:w-1/5 h-auto md:relative overflow-y-visible pt-2 bg-white md:mt-0 min-w-48"}
149169
>
150170
<aside
151171
id="sidebar-content"
@@ -351,7 +371,7 @@ let make = (
351371
</div>
352372
</div>
353373
<div
354-
className={hasBreadcrumbs ? "mt-20 md:mt-10" : "mt-6 md:-mt-4"}
374+
className={hasBreadcrumbs ? "mt-28 md:mt-10" : "mt-6 md:-mt-4"}
355375
dataTestId="side-layout-children"
356376
>
357377
children

0 commit comments

Comments
 (0)