Tile.purs 1.24 KB
Newer Older
1 2 3 4 5 6 7 8 9
module Gargantext.Components.Tile
  ( tileBlock
  , tileContext
  ) where

import Gargantext.Prelude

import Data.Maybe (Maybe(..))
import Effect (Effect)
arturo's avatar
arturo committed
10
import Gargantext.Components.App.Store (Boxes)
11
import Gargantext.Routes (Tile)
12
import Gargantext.Utils.Reactix as R2
13 14 15
import Reactix as R
import Reactix.DOM.HTML as H

16 17 18
here :: R2.Here
here = R2.here "Gargantext.Components.Tile"

19 20 21 22 23 24 25
type Props =
  ( boxes         :: Boxes
  , tile          :: Record Tile
  , key           :: String
  , closeCallback :: Unit -> Effect Unit
  )

26
tileBlock :: R2.Component Props
27 28
tileBlock = R.createElement tileBlockCpt
tileBlockCpt :: R.Component Props
29
tileBlockCpt = here.component "tileBlock" cpt where
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
  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