type route = | Model(string) | DistBuilder | DistBuilder2 | DistBuilder3 | Home | NotFound; let routeToPath = route => switch (route) { | Model(modelId) => "/m/" ++ modelId | DistBuilder => "/dist-builder" | DistBuilder2 => "/dist-builder2" | DistBuilder3 => "/dist-builder3" | Home => "/" | _ => "/" }; module Models = { let all = [| EAFunds.Interface.model, GlobalCatastrophe.Interface.model, Human.Interface.model, |]; let getById = id => E.A.getBy(all, r => r.id == id); }; module Menu = { module Styles = { open Css; let menu = style([ position(`relative), marginTop(em(0.25)), marginBottom(em(0.25)), selector( "a", [ borderRadius(em(0.25)), display(`inlineBlock), backgroundColor(`hex("eee")), padding(em(1.)), cursor(`pointer), ], ), selector("a:hover", [backgroundColor(`hex("bfcad4"))]), selector("a:hover", [backgroundColor(`hex("bfcad4"))]), selector( "a:not(:first-child):not(:last-child)", [marginRight(em(0.25)), marginLeft(em(0.25))], ), ]); }; module Item = { [@react.component] let make = (~href, ~children) => { { e->ReactEvent.Synthetic.preventDefault; ReasonReactRouter.push(href); }}> children ; }; }; [@react.component] let make = () => {
{"Home" |> R.ste} {"Dist Builder" |> R.ste} {"Dist Builder 2" |> R.ste} {"Dist Builder 3" |> R.ste}
; }; }; [@react.component] let make = () => { let url = ReasonReactRouter.useUrl(); let routing = switch (url.path) { | ["m", modelId] => Model(modelId) | ["dist-builder"] => DistBuilder | ["dist-builder2"] => DistBuilder2 | ["dist-builder3"] => DistBuilder3 | [] => Home | _ => NotFound };
{switch (routing) { | Model(id) => switch (Models.getById(id)) { | Some(model) => | None =>
{"Page is not found" |> R.ste}
} | DistBuilder => | DistBuilder2 => | DistBuilder3 => | Home => | _ =>
{"Page is not found" |> R.ste}
}}
; };