From 28d595fef6d96557c3d318bc63e716dcebba282d Mon Sep 17 00:00:00 2001 From: Joris Date: Wed, 5 Apr 2017 21:26:31 +0200 Subject: Add glycemic index indicator --- src/Page.purs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/Page.purs') 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" ] -- cgit v1.2.3