diff options
author | Joris | 2017-04-05 21:26:31 +0200 |
---|---|---|
committer | Joris | 2017-04-05 21:26:35 +0200 |
commit | 28d595fef6d96557c3d318bc63e716dcebba282d (patch) | |
tree | 6ece538d3c6094f72cc7f63f1cef3288adb5ad35 /src/Page.purs | |
parent | 82f5793b57e923be50e53b6845802fdd30ef947b (diff) |
Add glycemic index indicator
Diffstat (limited to 'src/Page.purs')
-rw-r--r-- | src/Page.purs | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/Page.purs b/src/Page.purs index 76cdf8d..07372d2 100644 --- a/src/Page.purs +++ b/src/Page.purs @@ -1,5 +1,6 @@ module Page where +import Data.Array ((:), sortBy) import Data.Maybe (Maybe(..)) import Halogen as H import Halogen.HTML as HH @@ -9,12 +10,11 @@ import Prelude import Food (Aliment) import Food as Food import Format as Format - -type State = Unit +import Indicator as Indicator data Query a = NoOp a - -data Message = Toggled Boolean +type State = Unit +type Message = Unit component :: forall m . H.Component HH.HTML Query State Message m component = @@ -32,7 +32,7 @@ component = [ HH.h1 [] [ HH.text "Glycémie" ] , HH.ul [ HP.class_ $ HH.ClassName "aliments" ] - ([renderTitle] <> (map renderAliment Food.all)) + (renderTitle : (map renderAliment <<< sortBy (\a b -> compare a.name b.name) $ Food.all)) ] eval :: Query ~> H.ComponentDSL State Query Message m @@ -65,7 +65,7 @@ renderAliment aliment = [] [ HH.text aliment.name ] , HH.div - [ HP.class_ $ HH.ClassName "number" ] + [ HP.class_ $ HH.ClassName ("number " <> (show $ Indicator.fromGlycemicIndex aliment.glycemicIndex)) ] [ HH.text (show aliment.glycemicIndex) ] , HH.div [ HP.class_ $ HH.ClassName "number" ] |