Spinner.purs 1.17 KB
Newer Older
arturo's avatar
arturo committed
1 2 3 4 5
module Gargantext.Components.Bootstrap.Spinner(spinner) where

import Gargantext.Prelude

import Data.Foldable (intercalate)
6
import Gargantext.Components.Bootstrap.Types (SpinnerTheme(..))
arturo's avatar
arturo committed
7 8 9 10 11 12
import Gargantext.Utils.Reactix as R2
import Reactix as R
import Reactix.DOM.HTML as H

type Props   = ( | Options)
type Options =
13
  ( theme     :: SpinnerTheme
arturo's avatar
arturo committed
14 15 16 17 18
  , className :: String
  )

options :: Record Options
options =
19 20
  { theme     : BorderTheme
  , className : ""
arturo's avatar
arturo committed
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
  }

-- | Structural Component for the Bootstrap spinner
-- |
-- | https://getbootstrap.com/docs/4.4/components/spinners/
spinner :: forall r. R2.OptLeaf Options Props r
spinner = R2.optLeaf component options

componentName :: String
componentName = "b-spinner"

bootstrapName :: String
bootstrapName = "spinner"

component :: R.Component Props
component = R.hooksComponent componentName cpt where
  cpt props _ = do
    -- Computed
    className <- pure $ intercalate " "
      -- provided custom className
      [ props.className
      -- BEM classNames
      , componentName
      -- Bootstrap specific classNames
45
      , bootstrapName <> "-" <> show props.theme
arturo's avatar
arturo committed
46 47 48 49 50 51 52
      ]
    -- Render
    pure $

      H.div
      { className }
      []