diff --git a/src/App.re b/src/App.re index 46e3e482..16830a13 100644 --- a/src/App.re +++ b/src/App.re @@ -1,7 +1,92 @@ +type route = + | EAFunds + | GlobalCatastrophe + | Home + | NotFound; + +let routeToPath = route => + switch (route) { + | EAFunds => "/ea-funds" + | GlobalCatastrophe => "/global-catastrophe" + | Home => "/" + | _ => "/" + }; + +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" |> E.ste} + + {"EA Funds" |> E.ste} + + + {"Global Catastrophe" |> E.ste} + +
; + }; +}; + [@react.component] let make = () => { + let url = ReasonReactRouter.useUrl(); + + let routing = + switch (url.path) { + | ["ea-funds"] => EAFunds + | ["global-catastrophe"] => GlobalCatastrophe + | [] => Home + | _ => NotFound + }; +
- - + + {switch (routing) { + | EAFunds => + | GlobalCatastrophe => + + | Home =>
{"Welcome" |> E.ste}
+ | _ =>
{"Page is not found" |> E.ste}
+ }}
; -}; \ No newline at end of file +}; diff --git a/src/utility/E.re b/src/utility/E.re index 8ce61851..9be83a65 100644 --- a/src/utility/E.re +++ b/src/utility/E.re @@ -296,4 +296,6 @@ module JsArray = { Rationale.Option.toExn("Warning: This should not have happened"), ); let filter = Js.Array.filter; -}; \ No newline at end of file +}; + +let ste = React.string;