Compose two components (fake actions, since grid doesn't do anything yet)

This commit is contained in:
towards-a-new-leftypol 2023-12-26 02:53:17 -05:00
parent fcea3f87fe
commit 82d85b834b
2 changed files with 19 additions and 2 deletions

View File

@ -6,6 +6,7 @@ module Component.CatalogGrid
, Action , Action
, Interface (..) , Interface (..)
, view , view
, update
) where ) where
import Miso import Miso
@ -23,6 +24,8 @@ import Miso
, p_ , p_
, br_ , br_
, id_ , id_
, Effect
, noEff
) )
type Model = () type Model = ()
@ -37,13 +40,20 @@ data Interface a = Interface
, selectThread :: () , selectThread :: ()
} }
update
:: Interface a
-> Action
-> Model
-> Effect a Model
update = const $ const noEff
view :: Interface a -> Model -> View a view :: Interface a -> Model -> View a
view iface model = view iface model =
div_ div_
[ class_ "threads" ] [ class_ "threads" ]
[ div_ [ div_
[ id_ "Grid" ] [ id_ "Grid" ]
[ gridItem | _ <- [0..10] ] [ gridItem | _ <- [0..10] :: [ Int ] ]
] ]
gridItem :: View a gridItem :: View a

View File

@ -73,8 +73,15 @@ mainView model =
, Grid.view iGrid (gridModel model) , Grid.view iGrid (gridModel model)
] ]
mainUpdate :: Action -> Model -> Effect Action 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 Action
iGrid = Grid.Interface iGrid = Grid.Interface