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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
module Gargantext.Components.Tile
( tileBlock
, tileContext
) where
import Gargantext.Prelude
import Data.Maybe (Maybe(..))
import Effect (Effect)
import Gargantext.Components.App.Store (Boxes)
import Gargantext.Routes (Tile)
import Gargantext.Utils.Reactix as R2
import Reactix as R
import Reactix.DOM.HTML as H
here :: R2.Here
here = R2.here "Gargantext.Components.Tile"
type Props =
( boxes :: Boxes
, tile :: Record Tile
, key :: String
, closeCallback :: Unit -> Effect Unit
)
tileBlock :: R2.Component Props
tileBlock = R.createElement tileBlockCpt
tileBlockCpt :: R.Component Props
tileBlockCpt = here.component "tileBlock" cpt where
cpt props@{ closeCallback } children = do
-- Render
pure $
R.provideContext tileContext (Just props)
[
H.div
{ className: "tile-block" }
[
H.div { className: "tile-block__header"}
[
H.i
{ className: "btn fa fa-times"
, on: { click: closeCallback }
}
[]
]
,
H.div { className: "tile-block__body" }
children
]
]
tileContext :: R.Context (Maybe (Record Props))
tileContext = R.createContext Nothing