diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Aliment.purs | 13 | ||||
-rw-r--r-- | src/Main.purs | 13 | ||||
-rw-r--r-- | src/Page.purs | 45 |
3 files changed, 71 insertions, 0 deletions
diff --git a/src/Aliment.purs b/src/Aliment.purs new file mode 100644 index 0000000..e7c4fc8 --- /dev/null +++ b/src/Aliment.purs @@ -0,0 +1,13 @@ +module Aliment where + +all :: Array Aliment +all = + [ { name: "Oignon", gi: 15 } + , { name: "Olive", gi: 15 } + , { name: "Haricot rouge", gi: 35 } + ] + +type Aliment = + { name :: String + , gi :: Int + } diff --git a/src/Main.purs b/src/Main.purs new file mode 100644 index 0000000..3121aa5 --- /dev/null +++ b/src/Main.purs @@ -0,0 +1,13 @@ +module Main where + +import Prelude +import Control.Monad.Eff (Eff) +import Halogen.Aff as HA +import Halogen.VDom.Driver (runUI) + +import Page as Page + +main :: Eff (HA.HalogenEffects ()) Unit +main = HA.runHalogenAff do + body <- HA.awaitBody + runUI Page.component unit body diff --git a/src/Page.purs b/src/Page.purs new file mode 100644 index 0000000..83e4d73 --- /dev/null +++ b/src/Page.purs @@ -0,0 +1,45 @@ +module Page where + +import Prelude +import Data.Maybe (Maybe(..)) +import Halogen as H +import Halogen.HTML as HH + +import Aliment as Aliment +import Aliment (Aliment) + +type State = Unit + +data Query a = NoOp a + +data Message = Toggled Boolean + +component :: forall m . H.Component HH.HTML Query State Message m +component = + H.component + { initialState: const unit + , render + , eval + , receiver: const Nothing + } + where + render :: State -> H.ComponentHTML Query + render state = + HH.div + [] + [ HH.h1 [] [ HH.text "Sucre" ] + , HH.ul + [] + (map renderAliment Aliment.all) + ] + + eval :: Query ~> H.ComponentDSL State Query Message m + eval = case _ of + NoOp next -> pure next + +renderAliment :: Aliment -> H.ComponentHTML Query +renderAliment aliment = + HH.li + [] + [ HH.text (aliment.name <> ", index glycémique: " <> (show aliment.gi)) + ] |