Skip to content

Commit 1681a02

Browse files
committed
functionality is done
1 parent bff50b5 commit 1681a02

File tree

3 files changed

+50
-28
lines changed

3 files changed

+50
-28
lines changed

src/SyntaxLookup.res

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ let default = (props: props) => {
374374
<div className="text-gray-80">
375375
<Navigation isOverlayOpen setOverlayOpen />
376376
<div className="flex xs:justify-center overflow-hidden pb-48">
377-
<main className="mt-16 min-w-320 lg:align-center w-full px-4 md:px-8 max-w-1280">
377+
<main className="mt-24 min-w-320 lg:align-center w-full px-4 md:px-8 max-w-1280">
378378
<MdxProvider components=MarkdownComponents.default>
379379
<div className="flex justify-center">
380380
<div className="max-w-740 w-full"> content </div>

src/components/Navigation.res

Lines changed: 46 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,29 @@
11
module Link = Next.Link
22

3-
let link = "no-underline block hover:cursor-pointer hover:text-fire-30 text-gray-40 mb-px"
3+
let link = "no-underline block hover:cursor-pointer hover:text-fire-30 mb-px"
44
let activeLink = "font-medium text-fire-30 border-b border-fire"
55

66
let linkOrActiveLink = (~target, ~route) => target === route ? activeLink : link
77

88
let linkOrActiveLinkSubroute = (~target, ~route) =>
99
String.startsWith(route, target) ? activeLink : link
1010

11-
let isActiveLink = (~route: string, ~href: string) => {
12-
route == href ? activeLink : link
11+
let isActiveLink = (~includes: string, ~excludes: option<string>=?, ~route: string) => {
12+
// includes means we want the lnk to be active if it contains the expected text
13+
let includes = route->String.includes(includes)
14+
// excludes allows us to not have links be active even if they do have the includes text
15+
let excludes = switch excludes {
16+
| Some(excludes) => route->String.includes(excludes)
17+
| None => false
18+
}
19+
includes && !excludes ? activeLink : link
1320
}
1421

22+
let isDocRoute = (~route) =>
23+
route->String.includes("/docs/") || route->String.includes("/syntax-lookup")
24+
25+
let isDocRouteActive = (~route) => isDocRoute(~route) ? activeLink : link
26+
1527
module MobileNav = {
1628
@react.component
1729
let make = (~route: string) => {
@@ -91,11 +103,10 @@ let make = (~fixed=true, ~isOverlayOpen: bool, ~setOverlayOpen: (bool => bool) =
91103
<div
92104
className="flex items-center xs:justify-between w-full bg-gray-90 sm:h-auto sm:relative">
93105
<div
94-
className="flex ml-10 space-x-5 w-full max-w-320"
106+
className="flex ml-10 space-x-5 w-full max-w-320 text-gray-40"
95107
style={ReactDOMStyle.make(~maxWidth="26rem", ())}>
96108
<Link
97-
href={`/docs/manual/${version}/introduction`}
98-
className={isActiveLink(~route, ~href=`/docs/manual/${version}/introduction`)}>
109+
href={`/docs/manual/${version}/introduction`} className={isDocRouteActive(~route)}>
99110
{React.string("Docs")}
100111
</Link>
101112

@@ -154,24 +165,35 @@ let make = (~fixed=true, ~isOverlayOpen: bool, ~setOverlayOpen: (bool => bool) =
154165
<MobileNav route />
155166
</div>
156167
</nav>
157-
<nav
158-
className="z-50 px-4 w-full h-14 bg-gray-100 shadow text-white-80 text-12 transition duration-300 ease-out group-[.nav-disappear]:-translate-y-16 md:group-[.nav-disappear]:transform-none">
159-
<div className="pl-30 flex gap-16 items-center h-full w-full max-w-md">
160-
<Link
161-
href={`/docs/manual/${version}/api`}
162-
className={isActiveLink(~route, ~href=`/docs/manual/${version}/api`)}>
163-
{React.string("API")}
164-
</Link>
165-
<Link href={`/syntax-lookup`} className={isActiveLink(~route, ~href=`/syntax-lookup`)}>
166-
{React.string("Syntax")}
167-
</Link>
168-
<Link
169-
href={`/docs/react/latest/introduction`}
170-
className={isActiveLink(~route, ~href=`/docs/react/latest/introduction`)}>
171-
{React.string("React")}
172-
</Link>
173-
</div>
174-
</nav>
168+
// This is a subnav for documentation pages
169+
{isDocRoute(~route)
170+
? <nav
171+
id="docs-subnav"
172+
className="z-50 px-4 w-full h-12 bg-gray-70 shadow text-white text-14 transition duration-300 ease-out group-[.nav-disappear]:-translate-y-16 md:group-[.nav-disappear]:transform-none">
173+
<div className="pl-30 flex gap-10 items-center h-full w-full max-w-md">
174+
<Link
175+
href={`/docs/manual/${version}/introduction`}
176+
className={isActiveLink(~includes="/docs/manual/", ~excludes="/api", ~route)}>
177+
{React.string("Language Manual")}
178+
</Link>
179+
<Link
180+
href={`/docs/manual/${version}/api`}
181+
className={isActiveLink(~includes="/api", ~route)}>
182+
{React.string("API")}
183+
</Link>
184+
<Link
185+
href={`/syntax-lookup`}
186+
className={isActiveLink(~includes="/syntax-lookup", ~route)}>
187+
{React.string("Syntax Lookup")}
188+
</Link>
189+
<Link
190+
href={`/docs/react/latest/introduction`}
191+
className={isActiveLink(~includes="/docs/react/", ~route)}>
192+
{React.string("React")}
193+
</Link>
194+
</div>
195+
</nav>
196+
: React.null}
175197
</header>
176198
</>
177199
}

src/layouts/SidebarLayout.res

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,10 +138,10 @@ module Sidebar = {
138138
id="sidebar"
139139
className={(
140140
isOpen ? "fixed w-full left-0 h-full z-20 min-w-320" : "hidden "
141-
) ++ " md:block md:w-48 md:-ml-4 lg:w-1/5 md:h-auto md:relative overflow-y-visible bg-white"}>
141+
) ++ " overflow-x-hidden md:block md:w-48 md:-ml-4 lg:w-1/5 md:h-auto md:relative overflow-y-visible bg-white"}>
142142
<aside
143143
id="sidebar-content"
144-
className="relative top-0 px-4 w-full block md:top-16 md:pt-16 md:sticky border-r border-gray-20 overflow-y-auto pb-24"
144+
className="relative top-0 px-4 w-full block md:top-16 md:pt-4 md:sticky border-r border-gray-20 overflow-y-auto pb-24"
145145
style={ReactDOMStyle.make(~height="calc(100vh - 4.5rem", ())}>
146146
<div className="flex justify-between">
147147
<div className="w-3/4 md:w-full"> toplevelNav </div>
@@ -309,7 +309,7 @@ let make = (
309309
<div className="flex lg:justify-center">
310310
<div className="flex w-full max-w-1280 md:mx-8">
311311
sidebar
312-
<main className="px-4 w-full pt-16 md:ml-12 lg:mr-8 mb-32 md:max-w-576 lg:max-w-740">
312+
<main className="px-4 w-full pt-20 md:ml-12 lg:mr-8 mb-32 md:max-w-576 lg:max-w-740">
313313
//width of the right content part
314314
<div
315315
className={"z-10 fixed border-b shadow top-16 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 transition duration-300 ease-out group-[.nav-disappear]:-translate-y-32 md:group-[.nav-disappear]:transform-none"}>

0 commit comments

Comments
 (0)