Skip to content

Commit ce34743

Browse files
committed
Fix Sidebarlayout for ipad vertical size
1 parent 019cfb0 commit ce34743

File tree

3 files changed

+69
-60
lines changed

3 files changed

+69
-60
lines changed

src/layouts/SidebarLayout.js

Lines changed: 23 additions & 28 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/layouts/SidebarLayout.res

Lines changed: 45 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ module Toc = {
3232
{Belt.Array.map(entries, ({header, href}) =>
3333
<li key=header className="pl-2 mt-3 first:mt-1">
3434
<Link href>
35-
<a
36-
className="font-medium block text-sm text-gray-40 leading-tight hover:text-gray-80"> //links, nested
37-
{React.string(header)}
35+
<a className="font-medium block text-sm text-gray-40 leading-tight hover:text-gray-80">
36+
{//links, nested
37+
React.string(header)}
3838
</a>
3939
</Link>
4040
</li>
@@ -64,7 +64,9 @@ module Sidebar = {
6464
~isItemActive: t => bool=_nav => false,
6565
~isHidden=false,
6666
~items: array<t>,
67-
) => <ul className="mt-2 text-14 font-medium"> {Belt.Array.map(items, m => {
67+
) =>
68+
<ul className="mt-2 text-14 font-medium">
69+
{Belt.Array.map(items, m => {
6870
let hidden = isHidden ? "hidden" : "block"
6971
let active = isItemActive(m)
7072
? j` bg-fire-10 text-fire leading-5 -ml-2 pl-2 font-medium block hover:bg-fire-10 `
@@ -93,7 +95,8 @@ module Sidebar = {
9395
| None => React.null
9496
}}
9597
</li>
96-
})->React.array} </ul>
98+
})->React.array}
99+
</ul>
97100
}
98101

99102
module Category = {
@@ -136,8 +139,7 @@ module Sidebar = {
136139
id="sidebar"
137140
className={(
138141
isOpen ? "fixed w-full left-0 h-full z-20 min-w-320" : "hidden "
139-
) ++ " md:block md:w-48 md:-ml-4 lg:w-1/5 md:h-auto md:relative overflow-y-visible bg-white md:relative"}
140-
style={ReactDOMStyle.make(~minWidth="12.9375rem", ())}>
142+
) ++ " md:block md:w-48 md:-ml-4 lg:w-1/5 md:h-auto md:relative overflow-y-visible bg-white md:relative"}>
141143
<aside
142144
id="sidebar-content"
143145
className="relative top-0 px-4 w-full block md:top-18 md:pt-24 md:sticky border-r border-gray-5 overflow-y-auto scrolling-touch pb-24"
@@ -179,14 +181,18 @@ module BreadCrumbs = {
179181
let item = if i === Belt.List.length(crumbs) - 1 {
180182
<span key={Belt.Int.toString(i)}> {React.string(crumb.name)} </span>
181183
} else {
182-
<Link key={Belt.Int.toString(i)} href=crumb.href> <a> {React.string(crumb.name)} </a> </Link>
184+
<Link key={Belt.Int.toString(i)} href=crumb.href>
185+
<a> {React.string(crumb.name)} </a>
186+
</Link>
183187
}
184188
if i > 0 {
185189
<span key={Belt.Int.toString(i)}> {React.string(" / ")} item </span>
186190
} else {
187191
item
188192
}
189-
})->Belt.List.toArray->React.array}
193+
})
194+
->Belt.List.toArray
195+
->React.array}
190196
</div>
191197
}
192198

@@ -244,7 +250,14 @@ let make = (
244250
}, [])
245251

246252
let editLinkEl = switch editHref {
247-
| Some(href) => <a href className="inline text-14 hover:underline text-fire" target="_blank" rel="noopener noreferrer"> {React.string("Edit")} </a>
253+
| Some(href) =>
254+
<a
255+
href
256+
className="inline text-14 hover:underline text-fire"
257+
target="_blank"
258+
rel="noopener noreferrer">
259+
{React.string("Edit")}
260+
</a>
248261
| None => React.null
249262
}
250263

@@ -253,30 +266,30 @@ let make = (
253266
<div className={"mt-16 min-w-320 " ++ theme}>
254267
<div className="w-full">
255268
<Navigation overlayState=(isNavOpen, setNavOpen) />
256-
<div className="flex justify-center">
257-
<div className="w-full max-w-1280 md:mx-8">
258-
<div className="flex">
259-
sidebar
260-
<main
261-
className="px-4 w-full pt-16 md:ml-12 md:mx-8 md:mt-2 md:pt-24 mb-32 max-w-740"> //width of the right content part
269+
<div className="flex lg:justify-center">
270+
<div className="flex w-full max-w-1280 md:mx-8">
271+
sidebar
272+
<main
273+
className="px-4 w-full pt-16 md:ml-12 lg:mr-8 md:mt-2 md:pt-24 mb-32 md:max-w-576 lg:max-w-740">
274+
//width of the right content part
275+
<div
276+
className="z-10 fixed border-b shadow top-18 left-0 pl-4 bg-white w-full py-4 md:relative md:border-none md:shadow-none md:p-0 md:top-auto flex items-center">
277+
<MobileDrawerButton
278+
hidden=isNavOpen
279+
onClick={evt => {
280+
ReactEvent.Mouse.preventDefault(evt)
281+
toggleSidebar()
282+
}}
283+
/>
262284
<div
263-
className="z-10 fixed border-b shadow top-18 left-0 pl-4 bg-white w-full py-4 md:relative md:border-none md:shadow-none md:p-0 md:top-auto flex items-center">
264-
<MobileDrawerButton
265-
hidden=isNavOpen
266-
onClick={evt => {
267-
ReactEvent.Mouse.preventDefault(evt)
268-
toggleSidebar()
269-
}}
270-
/>
271-
<div className="truncate overflow-x-auto touch-scroll flex items-center space-x-4 md:justify-between mr-4 w-full">
272-
breadcrumbs editLinkEl
273-
</div>
274-
</div>
275-
<div className={hasBreadcrumbs ? "mt-10" : "-mt-4"}>
276-
<Mdx.Provider components> children </Mdx.Provider>
285+
className="truncate overflow-x-auto touch-scroll flex items-center space-x-4 md:justify-between mr-4 w-full">
286+
breadcrumbs editLinkEl
277287
</div>
278-
</main>
279-
</div>
288+
</div>
289+
<div className={hasBreadcrumbs ? "mt-10" : "-mt-4"}>
290+
<Mdx.Provider components> children </Mdx.Provider>
291+
</div>
292+
</main>
280293
</div>
281294
</div>
282295
</div>

tailwind.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ module.exports = {
190190
maxWidth: {
191191
"320": "20rem",
192192
"400": "25rem",
193+
"576": "36rem",
193194
"1280": "80rem",
194195
"740": "46.25rem",
195196
xs: "20rem", // 320px

0 commit comments

Comments
 (0)