ControlsToggleButton.purs 792 Bytes
Newer Older
James Laver's avatar
James Laver committed
1 2 3 4
module Gargantext.Components.GraphExplorer.ControlsToggleButton
  ( Props, controlsToggleButton, controlsToggleButtonCpt
  ) where

5 6
import Data.Tuple.Nested ((/\))
import Prelude
James Laver's avatar
James Laver committed
7 8 9 10 11 12 13
import Reactix as R
import Reactix.DOM.HTML as H

type Props = ( state :: R.State Boolean )

controlsToggleButton :: Record Props -> R.Element
controlsToggleButton props = R.createElement controlsToggleButtonCpt props []
14

James Laver's avatar
James Laver committed
15 16 17 18 19 20
controlsToggleButtonCpt :: R.Component Props
controlsToggleButtonCpt = R.hooksComponent "GraphControlsToggleButton" cpt
  where
    cpt {state} _ = do
      let (open /\ setOpen) = state
      pure $
21
        H.button
James Laver's avatar
James Laver committed
22
          { className: "btn btn-primary", on: {click: \_ -> setOpen not } }
23
          [ H.text (text open) ]
James Laver's avatar
James Laver committed
24 25
    text true = "Hide Controls"
    text false = "Show Controls"