@@ -238,7 +238,7 @@ let default = (props: props) => {
238
238
| _ => "API"
239
239
}
240
240
241
- let item = {
241
+ let children = {
242
242
open Markdown
243
243
switch props {
244
244
| Ok ({module_ : {id , name , docstrings , items }}) =>
@@ -274,39 +274,58 @@ let default = (props: props) => {
274
274
}
275
275
}
276
276
277
- // let valuesAndTypes = switch props {
278
- // | Ok({module_: {items}}) if Js.Array2.length(items) > 0 =>
279
- // let valuesAndTypes = items->Belt.Array.keepMap(item => {
280
- // switch item {
281
- // | Value({name}) as kind | Type({name}) as kind =>
282
- // let icon = switch kind {
283
- // | Type(_) => "T"
284
- // | Value(_) => "V"
285
- // }
286
- // let (textColor, bgColor) = switch kind {
287
- // | Type(_) => ("text-fire-30", "bg-fire-5")
288
- // | Value(_) => ("text-sky-30", "bg-sky-5")
289
- // }
290
- // let result =
291
- // <li className="my-3 flex">
292
- // <a
293
- // className="flex font-normal text-14 text-gray-40 leading-tight hover:text-gray-80"
294
- // href={`#${name}`}>
295
- // <div
296
- // className={`${bgColor} w-5 h-5 mr-3 flex justify-center items-center rounded-xl`}>
297
- // <span style={ReactDOM.Style.make(~fontSize="10px", ())} className=textColor>
298
- // {icon->React.string}
299
- // </span>
300
- // </div>
301
- // {React.string(name)}
302
- // </a>
303
- // </li>
304
- // Some(result)
305
- // }
306
- // })
307
- // valuesAndTypes->Some
308
- // | _ => None
309
- // }
277
+ let rightSidebar = switch props {
278
+ | Ok ({module_ : {items }}) if Js .Array2 .length (items ) > 0 =>
279
+ let valuesAndTypes = items -> Belt .Array .keepMap (item => {
280
+ switch item {
281
+ | Value ({name , deprecated }) as kind | Type ({name , deprecated }) as kind =>
282
+ let (icon , textColor , bgColor , href ) = switch kind {
283
+ | Type (_ ) => ("t" , "text-fire-30" , "bg-fire-5" , ` #type-${name}` )
284
+ | Value (_ ) => ("v" , "text-sky-30" , "bg-sky-5" , ` #value-${name}` )
285
+ }
286
+ let deprecatedIcon = switch deprecated -> Js .Null .toOption {
287
+ | Some (_ ) =>
288
+ <div
289
+ className = {` bg-orange-100 min-w-[20px] min-h-[20px] w-5 h-5 mr-3 flex justify-center items-center rounded-xl ml-auto` }>
290
+ <span className = {"text-[10px] text-orange-400" }> {"D" -> React .string } </span >
291
+ </div >-> Some
292
+ | None => None
293
+ }
294
+ let title = ` ${Belt.Option.isSome(deprecatedIcon) ? "Deprecated " : "" }` ++ name
295
+ let result =
296
+ <li className = "my-3" >
297
+ <a
298
+ title
299
+ className = "flex items-center w-full font-normal text-14 text-gray-40 leading-tight hover:text-gray-80"
300
+ href >
301
+ <div
302
+ className = {` ${bgColor} min-w-[20px] min-h-[20px] w-5 h-5 mr-3 flex justify-center items-center rounded-xl` }>
303
+ <span className = {"text-[10px] font-normal " ++ textColor }>
304
+ {icon -> React .string }
305
+ </span >
306
+ </div >
307
+ <span className = {"truncate" }> {React .string (name )} </span >
308
+ {switch deprecatedIcon {
309
+ | Some (icon ) => icon
310
+ | None => React .null
311
+ }}
312
+ </a >
313
+ </li >
314
+ Some (result )
315
+ }
316
+ })
317
+ <div className = "hidden xl:block lg:w-1/5 md:h-auto md:relative overflow-y-visible bg-white" >
318
+ <aside
319
+ className = "relative top-0 pl-4 w-full block md:top-16 md:pt-16 md:sticky border-l border-gray-20 overflow-y-auto pb-24 h-[calc(100vh-4.5rem)]" >
320
+ <div className = "hl-overline block text-gray-80 mt-16 mb-2" >
321
+ {"Types and values" -> React .string }
322
+ </div >
323
+ <ul > {valuesAndTypes -> React .array } </ul >
324
+ </aside >
325
+ </div >
326
+
327
+ | _ => React .null
328
+ }
310
329
311
330
let version = switch Url .parse (router .asPath ).version {
312
331
| Latest | NoVersion => "latest"
@@ -324,32 +343,14 @@ let default = (props: props) => {
324
343
325
344
let breadcrumbs = ApiLayout .makeBreadcrumbs (~prefix , router .asPath )
326
345
327
- let children =
328
- <>
329
- item
330
- // {switch valuesAndTypes {
331
- // | Some(elemets) =>
332
- // <div className="pt-16 relative">
333
- // <aside
334
- // className="sticky top-18 overflow-auto px-8"
335
- // style={ReactDOM.Style.make(~height="calc(100vh - 6rem)", ())}>
336
- // <span className="font-normal block text-14 text-gray-40">
337
- // {React.string("Types and Values")}
338
- // </span>
339
- // <ul> {elemets->React.array} </ul>
340
- // </aside>
341
- // </div>
342
- // | None => React.null
343
- // }}
344
- </>
345
-
346
346
<SidebarLayout
347
347
breadcrumbs
348
348
metaTitle = {title ++ " | ReScript API" }
349
349
theme = #Reason
350
350
components = ApiMarkdown .default
351
351
sidebarState = (isSidebarOpen , setSidebarOpen )
352
- sidebar >
352
+ sidebar
353
+ rightSidebar >
353
354
children
354
355
</SidebarLayout >
355
356
}
0 commit comments