aboutsummaryrefslogtreecommitdiff
path: root/src/Page.purs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Page.purs')
-rw-r--r--src/Page.purs45
1 files changed, 38 insertions, 7 deletions
diff --git a/src/Page.purs b/src/Page.purs
index 83e4d73..76cdf8d 100644
--- a/src/Page.purs
+++ b/src/Page.purs
@@ -1,12 +1,14 @@
module Page where
-import Prelude
import Data.Maybe (Maybe(..))
import Halogen as H
import Halogen.HTML as HH
+import Halogen.HTML.Properties as HP
+import Prelude
-import Aliment as Aliment
-import Aliment (Aliment)
+import Food (Aliment)
+import Food as Food
+import Format as Format
type State = Unit
@@ -27,19 +29,48 @@ component =
render state =
HH.div
[]
- [ HH.h1 [] [ HH.text "Sucre" ]
+ [ HH.h1 [] [ HH.text "Glycémie" ]
, HH.ul
- []
- (map renderAliment Aliment.all)
+ [ HP.class_ $ HH.ClassName "aliments" ]
+ ([renderTitle] <> (map renderAliment Food.all))
]
eval :: Query ~> H.ComponentDSL State Query Message m
eval = case _ of
NoOp next -> pure next
+renderTitle :: H.ComponentHTML Query
+renderTitle =
+ HH.li
+ [ HP.class_ $ HH.ClassName "title" ]
+ [ HH.div
+ []
+ [ HH.text "Aliment" ]
+ , HH.div
+ []
+ [ HH.text "Index glycémique" ]
+ , HH.div
+ []
+ [ HH.text "Glucides pour 100 g" ]
+ , HH.div
+ []
+ [ HH.text "Charge glycémique" ]
+ ]
+
renderAliment :: Aliment -> H.ComponentHTML Query
renderAliment aliment =
HH.li
[]
- [ HH.text (aliment.name <> ", index glycémique: " <> (show aliment.gi))
+ [ HH.div
+ []
+ [ HH.text aliment.name ]
+ , HH.div
+ [ HP.class_ $ HH.ClassName "number" ]
+ [ HH.text (show aliment.glycemicIndex) ]
+ , HH.div
+ [ HP.class_ $ HH.ClassName "number" ]
+ [ HH.text (show aliment.carbohydrates) ]
+ , HH.div
+ [ HP.class_ $ HH.ClassName "number" ]
+ [ HH.text (Format.number 2 <<< Food.glycemicLoad $ aliment) ]
]