From 82d85b834b3b4668ae9e196328dad635ece067db Mon Sep 17 00:00:00 2001 From: towards-a-new-leftypol Date: Tue, 26 Dec 2023 02:53:17 -0500 Subject: [PATCH] Compose two components (fake actions, since grid doesn't do anything yet) --- src/Component/CatalogGrid.hs | 12 +++++++++++- src/Main.hs | 9 ++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/Component/CatalogGrid.hs b/src/Component/CatalogGrid.hs index 3fc6b1d..768c117 100644 --- a/src/Component/CatalogGrid.hs +++ b/src/Component/CatalogGrid.hs @@ -6,6 +6,7 @@ module Component.CatalogGrid , Action , Interface (..) , view +, update ) where import Miso @@ -23,6 +24,8 @@ import Miso , p_ , br_ , id_ + , Effect + , noEff ) type Model = () @@ -37,13 +40,20 @@ data Interface a = Interface , selectThread :: () } +update + :: Interface a + -> Action + -> Model + -> Effect a Model +update = const $ const noEff + view :: Interface a -> Model -> View a view iface model = div_ [ class_ "threads" ] [ div_ [ id_ "Grid" ] - [ gridItem | _ <- [0..10] ] + [ gridItem | _ <- [0..10] :: [ Int ] ] ] gridItem :: View a diff --git a/src/Main.hs b/src/Main.hs index 1947c46..b229376 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -73,8 +73,15 @@ mainView model = , Grid.view iGrid (gridModel model) ] + mainUpdate :: Action -> Model -> Effect Action Model -mainUpdate = const noEff +mainUpdate NoAction m = noEff m +mainUpdate GetLatest m = noEff m +mainUpdate GetThread {..} m = noEff m +mainUpdate (GridAction ga) m = + Grid.update iGrid ga (gridModel m) + >>= \gm -> noEff (m { gridModel = gm }) + iGrid :: Grid.Interface Action iGrid = Grid.Interface