blob: a77a18dbf2bcaa9e6a744adf4e3b96bf5b5fc166 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
module Component.Table
( table
, TableIn(..)
, TableOut(..)
) where
import Data.Text (Text)
import Reflex.Dom (Dynamic, MonadWidget)
import qualified Reflex.Dom as R
data TableIn h r t = TableIn
{ _tableIn_headerLabel :: h -> Text
, _tableIn_rows :: Dynamic t [r]
, _tableIn_cell :: h -> r -> Text
}
data TableOut = TableOut
{}
table :: forall t m h r. (MonadWidget t m, Bounded h, Enum h) => TableIn h r t -> m (TableOut)
table tableIn = do
R.divClass "table" $ do
R.divClass "lines" $ do
R.divClass "header" $ do
flip mapM_ [minBound..] $ \header ->
R.divClass "cell" . R.text $
_tableIn_headerLabel tableIn header
R.simpleList (_tableIn_rows tableIn) $ \r ->
R.divClass "row" $
flip mapM_ [minBound..] $ \h ->
R.divClass "cell name" $
R.dynText $
R.ffor r (_tableIn_cell tableIn h)
return $ TableOut
{}
|