Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
purescript-gargantext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
142
Issues
142
List
Board
Labels
Milestones
Merge Requests
4
Merge Requests
4
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gargantext
purescript-gargantext
Commits
fa676aa7
Commit
fa676aa7
authored
Mar 25, 2021
by
Karen Konou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use toestand
parent
d760e50c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
15 deletions
+14
-15
Corpus.purs
src/Gargantext/Components/Nodes/Corpus.purs
+14
-15
No files found.
src/Gargantext/Components/Nodes/Corpus.purs
View file @
fa676aa7
module Gargantext.Components.Nodes.Corpus where
import Gargantext.Prelude
( Unit, bind,
const,
discard, pure, show, unit
( Unit, bind, discard, pure, show, unit
, ($), (+), (-), (<), (<$>), (<<<), (<>), (==), (>), class Show, class Eq)
import Data.Argonaut (class DecodeJson, decodeJson, encodeJson)
import Data.Argonaut.Parser (jsonParser)
...
...
@@ -12,8 +12,7 @@ import Data.Generic.Rep.Eq (genericEq)
import Data.Generic.Rep.Show (genericShow)
import Data.List as List
import Data.Maybe (Maybe(..), fromMaybe)
import Data.Tuple (Tuple(..), fst)
import Data.Tuple.Nested ((/\))
import Data.Tuple (Tuple(..))
import DOM.Simple.Console (log2)
import Effect (Effect)
import Effect.Aff (Aff, launchAff_, throwError)
...
...
@@ -68,11 +67,12 @@ corpusLayoutMainCpt :: R.Component KeyProps
corpusLayoutMainCpt = here.component "corpusLayoutMain" cpt
where
cpt { nodeId, key, session } _ = do
viewType <- R.useState' Folders
viewType <- T.useBox Folders
viewType' <- T.read viewType
pure $ H.div{} [
H.div{} [viewTypeSelector {state: viewType} ]
, H.div{} [renderContent
(fst viewType)
nodeId session key]
, H.div{} [renderContent
viewType'
nodeId session key]
]
renderContent Folders nodeId session key = folderViewLoad { nodeId, session }
...
...
@@ -575,7 +575,7 @@ instance showViewType :: Show ViewType where
type ViewTypeSelectorProps =
(
state ::
R.State
ViewType
state ::
T.Box
ViewType
)
viewTypeSelector :: Record ViewTypeSelectorProps -> R.Element
...
...
@@ -584,25 +584,24 @@ viewTypeSelector p = R.createElement viewTypeSelectorCpt p []
viewTypeSelectorCpt :: R.Component ViewTypeSelectorProps
viewTypeSelectorCpt = here.component "viewTypeSelector" cpt
where
cpt {state} _ =
cpt {state} _ = do
state' <- T.useLive T.unequal state
pure $ H.div { className: "btn-group"
, role: "group" } [
viewTypeButton Folders state
, viewTypeButton Code state
viewTypeButton Folders state
' state
, viewTypeButton Code state
' state
]
viewTypeButton viewType
(state /\ setState)
=
viewTypeButton viewType
state' state
=
H.button { className: "btn btn-primary" <> active
, on: { click:
onClick
}
, on: { click:
\_ -> T.write viewType state
}
, type: "button"
} [
H.i { className: "fa " <> (icon viewType) } []
]
where
active = if viewType == state then " active" else ""
onClick _ = do
setState $ const viewType
active = if viewType == state' then " active" else ""
icon Folders = "fa-folder"
icon Code = "fa-code"
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment