ToolBar.purs 4.24 KB
Newer Older
1 2 3 4 5 6 7 8 9
module Gargantext.Components.PhyloExplorer.ToolBar
  ( toolBar
  ) where

import Gargantext.Prelude

import Effect (Effect)
import Gargantext.Components.Bootstrap as B
import Gargantext.Components.Bootstrap.Types (ButtonVariant(..), Variant(..))
arturo's avatar
arturo committed
10
import Gargantext.Components.PhyloExplorer.Store as PhyloStore
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
import Gargantext.Components.PhyloExplorer.Types (DisplayView(..))
import Gargantext.Utils ((?))
import Gargantext.Utils.Reactix as R2
import Reactix as R
import Reactix.DOM.HTML as H
import Toestand as T

type Props =
  ( resetViewCallback   :: Unit -> Effect Unit
  , changeViewCallback  :: DisplayView -> Effect Unit
  , exportCallback      :: Unit -> Effect Unit
  , unselectCallback    :: Unit -> Effect Unit
  )

here :: R2.Here
here = R2.here "Gargantext.Components.PhyloExplorer.ToolBar"

toolBar :: R2.Leaf Props
toolBar = R2.leaf component

component :: R.Component Props
component = here.component "main" cpt where
  cpt { resetViewCallback
      , changeViewCallback
      , exportCallback
      , unselectCallback
      } _ = do
arturo's avatar
arturo committed
38 39 40 41
    -- | States
    { isIsolineDisplayed
    , displayView
    } <- PhyloStore.use
42

arturo's avatar
arturo committed
43 44 45 46
    displayView'        <- R2.useLive' displayView
    isIsolineDisplayed' <- R2.useLive' isIsolineDisplayed

    -- | Render
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
    pure $

      H.div
      { className: "phylo-toolbar" }
      [
        -- View settings
        B.fieldset
        { className: "phylo-toolbar__section"
        , titleSlot: H.text "View settings"
        }
        [
          -- Reset view button
          B.button
          { callback: resetViewCallback
          , variant: OutlinedButtonVariant Secondary
          }
          [
            H.text "Reset view"
          ]
        ,
          H.span
          { className: "phylo-toolbar__gap" }
          [ H.text "" ]
        ,
          -- Display view mode
          H.div
          { className: "btn-group"
          , role: "group"
          }
          [
            B.button
            { title: "Show emergence label only"
            , callback: \_ -> changeViewCallback HeadingMode
            , variant: OutlinedButtonVariant Secondary
arturo's avatar
arturo committed
81
            , className: displayView' == HeadingMode ?
82 83 84 85 86 87 88 89 90 91 92 93
                "active" $
                ""
            }
            [
              B.icon
              { name: "header" }
            ]
          ,
            B.button
            { title: "Show node inner labels"
            , callback: \_ -> changeViewCallback LabelMode
            , variant: OutlinedButtonVariant Secondary
arturo's avatar
arturo committed
94
            , className: displayView' == LabelMode ?
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126
                "active" $
                ""
            }
            [
              B.icon
              { name: "dot-circle-o" }
            ]
          -- @NOTE #219: disable "landing view" (deprecated feature)
          -- ,
          --   B.button
          --   { title: "Show default landing view"
          --   , callback: \_ -> changeViewCallback LandingMode
          --   , variant: OutlinedButtonVariant Secondary
          --   , className: displayView == LandingMode ?
          --       "active" $
          --       ""
          --   }
          --   [
          --     B.icon
          --     { name: "circle" }
          --   ]
          ]
        ]
      ,
        -- Actions
        B.fieldset
        { className: "phylo-toolbar__section"
        , titleSlot: H.text "Actions"
        }
        [
          -- Isoline button
          B.button
arturo's avatar
arturo committed
127 128
          { callback: \_ -> T.modify_ not isIsolineDisplayed
          , variant: isIsolineDisplayed' ?
129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162
              ButtonVariant Secondary $
              OutlinedButtonVariant Secondary
          }
          [
            H.text "Iso Line data"
          ]
        ,
          H.span
          { className: "phylo-toolbar__gap" }
          [ H.text "" ]
        ,
          -- Unselect button
          B.button
          { callback: unselectCallback
          , variant: OutlinedButtonVariant Secondary
          }
          [
            H.text "Unselect"
          ]
        ,
          H.span
          { className: "phylo-toolbar__gap" }
          [ H.text "" ]
        ,
          -- Screenshot button
          B.button
          { callback: exportCallback
          , variant: OutlinedButtonVariant Secondary
          }
          [
            H.text "Take screenshot"
          ]
        ]
      ]