Skip to content

Commit 5062cd8

Browse files
committed
remove redundant length check
1 parent 14aef79 commit 5062cd8

File tree

1 file changed

+39
-42
lines changed

1 file changed

+39
-42
lines changed

src/ApiDocs.res

Lines changed: 39 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -44,49 +44,46 @@ type item =
4444
module RightSidebar = {
4545
@react.component
4646
let make = (~items: array<item>) => {
47-
switch items->Js.Array2.length === 0 {
48-
| true => React.null
49-
| false =>
50-
let valuesAndTypes = items->Js.Array2.map(item => {
51-
switch item {
52-
| Value({name, deprecated}) as kind | Type({name, deprecated}) as kind =>
53-
let (icon, textColor, bgColor, href) = switch kind {
54-
| Type(_) => ("t", "text-fire-30", "bg-fire-5", `#type-${name}`)
55-
| Value(_) => ("v", "text-sky-30", "bg-sky-5", `#value-${name}`)
56-
}
57-
let deprecatedIcon = switch deprecated->Js.Null.toOption {
58-
| Some(_) =>
59-
<div
60-
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`}>
61-
<span className={"text-[10px] text-orange-400"}> {"D"->React.string} </span>
62-
</div>->Some
63-
| None => None
64-
}
65-
let title = `${Belt.Option.isSome(deprecatedIcon) ? "Deprecated " : ""}` ++ name
66-
let result =
67-
<li className="my-3">
68-
<a
69-
title
70-
className="flex items-center w-full font-normal text-14 text-gray-40 leading-tight hover:text-gray-80"
71-
href>
72-
<div
73-
className={`${bgColor} min-w-[20px] min-h-[20px] w-5 h-5 mr-3 flex justify-center items-center rounded-xl`}>
74-
<span className={"text-[10px] font-normal " ++ textColor}>
75-
{icon->React.string}
76-
</span>
77-
</div>
78-
<span className={"truncate"}> {React.string(name)} </span>
79-
{switch deprecatedIcon {
80-
| Some(icon) => icon
81-
| None => React.null
82-
}}
83-
</a>
84-
</li>
85-
result
47+
items
48+
->Js.Array2.map(item => {
49+
switch item {
50+
| Value({name, deprecated}) as kind | Type({name, deprecated}) as kind =>
51+
let (icon, textColor, bgColor, href) = switch kind {
52+
| Type(_) => ("t", "text-fire-30", "bg-fire-5", `#type-${name}`)
53+
| Value(_) => ("v", "text-sky-30", "bg-sky-5", `#value-${name}`)
8654
}
87-
})
88-
valuesAndTypes->React.array
89-
}
55+
let deprecatedIcon = switch deprecated->Js.Null.toOption {
56+
| Some(_) =>
57+
<div
58+
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`}>
59+
<span className={"text-[10px] text-orange-400"}> {"D"->React.string} </span>
60+
</div>->Some
61+
| None => None
62+
}
63+
let title = `${Belt.Option.isSome(deprecatedIcon) ? "Deprecated " : ""}` ++ name
64+
let result =
65+
<li className="my-3">
66+
<a
67+
title
68+
className="flex items-center w-full font-normal text-14 text-gray-40 leading-tight hover:text-gray-80"
69+
href>
70+
<div
71+
className={`${bgColor} min-w-[20px] min-h-[20px] w-5 h-5 mr-3 flex justify-center items-center rounded-xl`}>
72+
<span className={"text-[10px] font-normal " ++ textColor}>
73+
{icon->React.string}
74+
</span>
75+
</div>
76+
<span className={"truncate"}> {React.string(name)} </span>
77+
{switch deprecatedIcon {
78+
| Some(icon) => icon
79+
| None => React.null
80+
}}
81+
</a>
82+
</li>
83+
result
84+
}
85+
})
86+
->React.array
9087
}
9188
}
9289

0 commit comments

Comments
 (0)