ControlsToggleButton.purs 916 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
import Reactix as R
import Reactix.DOM.HTML as H

10 11 12 13
import Gargantext.Utils.Reactix as R2

thisModule = "Gargantext.Components.GraphExplorer.ControlsToggleButton"

James Laver's avatar
James Laver committed
14 15 16 17
type Props = ( state :: R.State Boolean )

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

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