diff --git a/src/common/App.res b/src/common/App.res
index e08426c11..78dfde1f5 100644
--- a/src/common/App.res
+++ b/src/common/App.res
@@ -56,106 +56,98 @@ let make = (props: props): React.element => {
// docs routes
| {base: ["docs", "manual"], pagepath} =>
// check if it's an api route
-
- {switch pagepath[0] {
- | Some("api") =>
- switch url->Url.getVersionString {
- | ("v11.0.0" | "v12.0.0") as version =>
- switch (Array.length(pagepath), pagepath[1]) {
- | (1, _) => content
- | _ => content
- }
- | "v8.0.0" =>
- switch (Array.length(pagepath), pagepath[1]) {
- | (1, _) => content
- | (2, Some("js")) => content
- | (2, Some("belt")) => content
- | (_, Some("js")) => content
- | (_, Some("belt")) => content
- | (_, Some("dom")) => content
- | _ => React.null
- }
- | "v9.0.0" =>
- switch (Array.length(pagepath), pagepath[1]) {
- | (1, _) => content
- | (2, Some("js")) => content
- | (2, Some("belt")) => content
- | (_, Some("js")) => content
- | (_, Some("belt")) => content
- | (_, Some("dom")) => content
- | _ => React.null
- }
- | "v10.0.0" =>
- switch (Array.length(pagepath), pagepath[1]) {
- | (1, _) => content
- | (2, Some("js")) => content
- | (2, Some("belt")) => content
- | (_, Some("js")) => content
- | (_, Some("belt")) => content
- | (_, Some("dom")) => content
- | _ => React.null
- }
+ switch pagepath[0] {
+ | Some("api") =>
+ switch url->Url.getVersionString {
+ | ("v11.0.0" | "v12.0.0") as version =>
+ switch (Array.length(pagepath), pagepath[1]) {
+ | (1, _) => content
| _ => content
}
- | _ =>
- switch url->Url.getVersionString {
- | "v8.0.0" =>
- frontmatter}>
- content
-
- | "v9.0.0" =>
- frontmatter}>
- content
-
- | "v10.0.0" =>
- frontmatter}>
- content
-
- | "v11.0.0" =>
- frontmatter}>
- content
-
- | "v12.0.0" =>
- frontmatter}>
- content
-
+ | "v8.0.0" =>
+ switch (Array.length(pagepath), pagepath[1]) {
+ | (1, _) => content
+ | (2, Some("js")) => content
+ | (2, Some("belt")) => content
+ | (_, Some("js")) => content
+ | (_, Some("belt")) => content
+ | (_, Some("dom")) => content
| _ => React.null
}
- }}
-
- | {base: ["docs", "react"], version} =>
-
- {switch version {
- | Latest =>
- frontmatter}>
+ | "v9.0.0" =>
+ switch (Array.length(pagepath), pagepath[1]) {
+ | (1, _) => content
+ | (2, Some("js")) => content
+ | (2, Some("belt")) => content
+ | (_, Some("js")) => content
+ | (_, Some("belt")) => content
+ | (_, Some("dom")) => content
+ | _ => React.null
+ }
+ | "v10.0.0" =>
+ switch (Array.length(pagepath), pagepath[1]) {
+ | (1, _) => content
+ | (2, Some("js")) => content
+ | (2, Some("belt")) => content
+ | (_, Some("js")) => content
+ | (_, Some("belt")) => content
+ | (_, Some("dom")) => content
+ | _ => React.null
+ }
+ | _ => content
+ }
+ | _ =>
+ switch url->Url.getVersionString {
+ | "v8.0.0" =>
+ frontmatter}>
+ content
+
+ | "v9.0.0" =>
+ frontmatter}>
content
-
- | Version("v0.10.0") =>
- frontmatter}>
+
+ | "v10.0.0" =>
+ frontmatter}>
content
-
- | Version("v0.11.0") =>
- frontmatter}>
+
+ | "v11.0.0" =>
+ frontmatter}>
content
-
+
+ | "v12.0.0" =>
+ frontmatter}>
+ content
+
| _ => React.null
- }}
-
+ }
+ }
+
+ | {base: ["docs", "react"], version} =>
+ switch version {
+ | Latest =>
+ frontmatter}>
+ content
+
+ | Version("v0.10.0") =>
+ frontmatter}> content
+ | Version("v0.11.0") =>
+ frontmatter}> content
+ | _ => React.null
+ }
+
// common routes
| {base} =>
switch List.fromArray(base) {
| list{"community", ..._rest} =>
-
- frontmatter}> content
-
+ frontmatter}> content
+
| list{"try"} => content
| list{"blog"} => content // Blog implements its own layout as well
- | list{"syntax-lookup"} => content
- | list{"packages"} => content
- | list{"blog", ..._rest} =>
- // Here, the layout will be handled by the Blog_Article component
+ | list{"syntax-lookup"} => content
+ | list{"packages"} => content
+ | list{"blog", ..._rest} => // Here, the layout will be handled by the Blog_Article component
// to keep the frontmatter parsing etc in one place
- content
+ content
| _ =>
let fm = component->frontmatter->DocFrontmatter.decode
let title = switch url {
diff --git a/src/common/EnableCollapsibleNavbar.res b/src/common/EnableCollapsibleNavbar.res
deleted file mode 100644
index f8473822b..000000000
--- a/src/common/EnableCollapsibleNavbar.res
+++ /dev/null
@@ -1,12 +0,0 @@
-@react.component
-let make = (~children) => {
- let scrollDir = Hooks.useScrollDirection()
-
-
"group nav-appear"
- | Down(_) => "group nav-disappear"
- }}>
- children
-
-}
diff --git a/src/components/Navigation.res b/src/components/Navigation.res
index fcecc0b19..d75624361 100644
--- a/src/components/Navigation.res
+++ b/src/components/Navigation.res
@@ -8,344 +8,10 @@ let linkOrActiveLink = (~target, ~route) => target === route ? activeLink : link
let linkOrActiveLinkSubroute = (~target, ~route) =>
String.startsWith(route, target) ? activeLink : link
-let linkOrActiveApiSubroute = (~route) => {
- let url = Url.parse(route)
- switch url.pagepath[0] {
- | Some("api") => activeLink
- | _ => link
- }
-}
-
let isActiveLink = (~route: string, ~href: string) => {
route == href ? activeLink : link
}
-module CollapsibleLink = {
- // KeepOpen = Menu has been opened and should stay open
- type state =
- | KeepOpen
- | HoverOpen
- | Closed
-
- @react.component
- let make = (
- ~title: string,
- ~onStateChange: (~id: string, state) => unit,
- ~allowHover=true,
- /* ~allowInteraction=true, */
- ~id: string,
- ~state: state,
- ~active=false,
- ~children,
- ) => {
- let onClick = _evt => {
- /* ReactEvent.Mouse.preventDefault(evt) */
- /* ReactEvent.Mouse.stopPropagation(evt) */
-
- onStateChange(
- ~id,
- switch state {
- | Closed => KeepOpen
- | HoverOpen => Closed
- | KeepOpen => Closed
- },
- )
- }
-
- let onMouseEnter = evt => {
- ReactEvent.Mouse.preventDefault(evt)
- if allowHover {
- onStateChange(~id, HoverOpen)
- }
- }
-
- let isOpen = switch state {
- | Closed => false
- | KeepOpen
- | HoverOpen => true
- }
-
- <>
-
-
-
- {React.string(title)}
-
-
-
-
- >
- }
-}
-
-type collapsible = {
- title: string,
- children: React.element,
- isActiveRoute: string => bool,
- href: string,
- state: CollapsibleLink.state,
-}
-
-module DocsSection = {
- type item = {
- imgSrc: string,
- title: string,
- description: string,
- href: string,
- isActive: Url.t => bool,
- }
-
- module LinkCard = {
- @react.component
- let make = (
- ~icon: React.element,
- ~title: string,
- ~description: string,
- ~href: string,
- ~active=false,
- ) => {
- let isAbsolute = Util.Url.isAbsolute(href)
- let content =
-
- icon
-
-
- {React.string(title)}
- {if isAbsolute {
-
- } else {
- React.null
- }}
-
-
- {React.string(description)}
-
-
-
-
- if isAbsolute {
- content
- } else {
- content
- }
- }
- }
-
- @react.component
- let make = () => {
- let router = Next.Router.useRouter()
- let url = router.route->Url.parse
-
- let (version, setVersion) = React.useState(_ => url->Url.getVersionString)
-
- let languageManual = Constants.languageManual(version)
-
- let documentation = [
- {
- imgSrc: "/static/ic_manual@2x.png",
- title: "Language Manual",
- description: "Reference for all language features",
- href: `/docs/manual/${version}/introduction`,
- isActive: url => {
- switch url.fullpath {
- | ["docs", "manual", _, fragment] => fragment !== "typescript-integration"
- | _ => false
- }
- },
- },
- {
- imgSrc: "/static/ic_rescript_react@2x.png",
- title: "ReScript & React",
- description: "First class bindings for ReactJS",
- href: "/docs/react/latest/introduction",
- isActive: url => {
- switch url.base {
- | ["docs", "react"] => true
- | _ => false
- }
- },
- },
- ]
-
- let languageManualColumn =
-
-
-
- {React.string("Quick Links")}
-
-
-
- {languageManual
- ->Array.map(item => {
- let (text, href) = item
-
- let linkClass = if router.route === href {
- "text-fire-50"
- } else {
- "hover:text-fire-50"
- }
-
-
- {React.string(`-`)}
- {React.string(text)}
-
- })
- ->React.array}
-
-
-
-
-
- let ecosystemColumn = {
-
-
-
- {React.string("Documentation")}
-
-
-
- {Array.map(documentation, item => {
- let {imgSrc, title, href, description, isActive} = item
-
- let icon =
-
- })->React.array}
-
-
-
-
- }
-
- let quickReferenceColumn =
-
-
-
- {React.string("Exploration")}
-
-
- {
- let packageLink = {
- let icon =
-
-
-
- let active = switch url {
- | {base: ["packages"]} => true
- | _ => false
- }
-
-
- }
- let syntaxLookupLink = {
- let active = switch url {
- | {base: ["syntax-lookup"]} => true
- | _ => false
- }
- let icon =
-
-
-
-
-
- }
-
- <>
- packageLink
- syntaxLookupLink
- >
- }
-
-
-
-
- let onVersionChange = evt => {
- open Url
- ReactEvent.Form.preventDefault(evt)
- let version = (evt->ReactEvent.Form.target)["value"]
-
- switch url {
- | {base: ["docs", "manual"]} =>
- let targetUrl =
- "/" ++
- (Array.join(url.base, "/") ++
- ("/" ++ (version ++ ("/" ++ Array.join(url.pagepath, "/")))))
- router->Next.Router.push(targetUrl)
- | _ => ()
- }
-
- setVersion(_ => version)
- }
-
-
-
-
-
- {if version === Constants.versions.next {
-
- {React.string("This docs version is work in progress!")}
-
- } else if version === Constants.versions.latest {
-
- {React.string("This is the latest docs version")}
-
- } else {
- React.null
- }}
-
-
-
-
- languageManualColumn
- ecosystemColumn
- quickReferenceColumn
-
-
-
-
- }
-}
-
module MobileNav = {
@react.component
let make = (~route: string) => {
@@ -402,101 +68,12 @@ let make = (~fixed=true, ~isOverlayOpen: bool, ~setOverlayOpen: (bool => bool) =
let url = router.route->Url.parse
let version = url->Url.getVersionString
- let (collapsibles, setCollapsibles) = React.useState(_ => [
- {
- title: "Docs",
- href: `/docs/manual/${version}/api`,
- isActiveRoute: route => {
- let url = Url.parse(route)
- switch url {
- | {base: ["docs"]}
- | {base: ["docs", "react"]}
- | {base: ["docs", "gentype"]}
- | {base: ["docs", "manual"]} =>
- switch url.pagepath[0] {
- | Some("api") => false
- | _ => true
- }
- | _ => false
- }
- },
- state: Closed,
- children: ,
- },
- ])
-
- let isSubnavOpen = Array.find(collapsibles, c => c.state !== Closed) !== None
-
let toggleOverlay = () => setOverlayOpen(prev => !prev)
- let resetCollapsibles = () => setCollapsibles(prev => Array.map(prev, c => {...c, state: Closed}))
-
- let navRef = React.useRef(Nullable.null)
- Hooks.useOutsideClick(ReactDOM.Ref.domRef(navRef), resetCollapsibles)
-
- /* let windowWidth = useWindowWidth() */
-
- /*
- // Don't allow hover behavior for collapsibles if mobile navigation is on
- let _allowHover = switch windowWidth {
- | Some(width) => width > 576 // Value noted in tailwind config
- | None => true
- }
- */
-
- // Client side navigation requires us to reset the collapsibles
- // whenever a route change had occurred, otherwise the collapsible
- // will stay open, even though you clicked a link
- React.useEffect(() => {
- open Next.Router.Events
- let {Next.Router.events: events} = router
-
- let onChangeComplete = _url => {
- resetCollapsibles()
- setOverlayOpen(_ => false)
- }
-
- events->on(#routeChangeComplete(onChangeComplete))
- events->on(#hashChangeComplete(onChangeComplete))
-
- Some(
- () => {
- events->off(#routeChangeComplete(onChangeComplete))
- events->off(#hashChangeComplete(onChangeComplete))
- },
- )
- }, [])
-
let fixedNav = fixed ? "fixed top-0" : "relative"
- let onStateChange = (~id, state) => {
- setCollapsibles(prev => {
- Array.filterMap(prev, next => {
- if next.title === id {
- Some({...next, state})
- } else {
- None
- }
- })
- })
- }
-
- let collapsibleElements = Array.map(collapsibles, coll => {
-
- {coll.children}
-
- })
-
<>
- unsafeAddProp("backdropFilter", "blur(2px)")
- ->unsafeAddProp("WebkitBackdropFilter", "blur(2px)")
- }
- />
>
}