Wad.purs 1.22 KB
Newer Older
arturo's avatar
arturo committed
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
module Gargantext.Components.Bootstrap.Wad
  ( wad
  , wad'
  , wad_
  ) where

import Gargantext.Prelude

import Data.Foldable (intercalate)
import Reactix as R
import Reactix.DOM.HTML as H

componentName :: String
componentName = "b-wad"

-- | Structural Component for a simple Element only serving the purpose to add
-- | some classes in it
-- |
-- | Hence the name: Wad (noun): a small mass, lump, or ball of anything ;
-- | a roll of something
wad :: Array String -> Array R.Element -> R.Element
wad classes children = R.createDOMElement "div" cls children
  where
    cls = { className: intercalate " " $
              [ componentName
              ] <> classes
          }

-- | Shorthand for using <wad> Component without writing its text node
wad' :: Array String -> String -> R.Element
wad' classes text = R.createDOMElement "div" cls chd
  where
    cls = { className: intercalate " " $
              [ componentName
              ] <> classes
          }

    chd = [ H.text text ]

-- | Shorthand for using <wad> Component without any child
wad_ :: Array String -> R.Element
wad_ classes = R.createDOMElement "div" cls []
  where
    cls = { className: intercalate " " $
              [ componentName
              ] <> classes
          }