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

import Reactix as R
import Reactix.DOM.HTML as H
7 8 9
import Toestand as T

import Gargantext.Prelude
James Laver's avatar
James Laver committed
10

11 12
import Gargantext.Utils.Reactix as R2

13
here :: R2.Here
14
here = R2.here "Gargantext.Components.GraphExplorer.ControlsToggleButton"
15

16
type Props = ( state :: T.Box Boolean )
James Laver's avatar
James Laver committed
17

18
controlsToggleButton :: R2.Leaf Props
James Laver's avatar
James Laver committed
19
controlsToggleButton props = R.createElement controlsToggleButtonCpt props []
20

James Laver's avatar
James Laver committed
21
controlsToggleButtonCpt :: R.Component Props
22
controlsToggleButtonCpt = here.component "controlsToggleButton" cpt
James Laver's avatar
James Laver committed
23
  where
24 25
    cpt { state } _ = do
      open' <- T.useLive T.unequal state
James Laver's avatar
James Laver committed
26
      pure $
27
        H.button
28 29
          { className: "btn btn-primary", on: {click: \_ -> T.modify_ not state } }
          [ H.text (text open') ]
James Laver's avatar
James Laver committed
30 31
    text true = "Hide Controls"
    text false = "Show Controls"