Commit c48c056e authored by Alexandre Delanoë's avatar Alexandre Delanoë

[Accessibility] Handed user (Left or Right), todo: Tree to right and...

[Accessibility] Handed user (Left or Right), todo: Tree to right and text-align right or left accordingly
parent fa92261e
...@@ -15,7 +15,7 @@ import Gargantext.Components.Forest.Tree (treeView) ...@@ -15,7 +15,7 @@ import Gargantext.Components.Forest.Tree (treeView)
import Gargantext.Ends (Frontends) import Gargantext.Ends (Frontends)
import Gargantext.Routes (AppRoute) import Gargantext.Routes (AppRoute)
import Gargantext.Sessions (Session(..), Sessions, OpenNodes, unSessions) import Gargantext.Sessions (Session(..), Sessions, OpenNodes, unSessions)
import Gargantext.Types (Reload) import Gargantext.Types (Reload, Handed(..))
import Gargantext.Utils.Reactix as R2 import Gargantext.Utils.Reactix as R2
type Props = type Props =
...@@ -58,6 +58,7 @@ forestCpt = R.hooksComponent "G.C.Forest.forest" cpt where ...@@ -58,6 +58,7 @@ forestCpt = R.hooksComponent "G.C.Forest.forest" cpt where
, openNodes , openNodes
, reload , reload
, session: s , session: s
, handed: RightHanded -- TODO enabling user to change it and save locally
} }
plus :: R2.Setter Boolean -> R.Element plus :: R2.Setter Boolean -> R.Element
......
...@@ -31,7 +31,7 @@ import Gargantext.Components.Forest.Tree.Node.Tools.FTree (FTree, LNode(..), NTr ...@@ -31,7 +31,7 @@ import Gargantext.Components.Forest.Tree.Node.Tools.FTree (FTree, LNode(..), NTr
import Gargantext.Components.Forest.Tree.Node.Tools.Task (Tasks, tasksStruct) import Gargantext.Components.Forest.Tree.Node.Tools.Task (Tasks, tasksStruct)
import Gargantext.Ends (Frontends) import Gargantext.Ends (Frontends)
import Gargantext.Hooks.Loader (useLoader) import Gargantext.Hooks.Loader (useLoader)
import Gargantext.Prelude (Unit, bind, discard, map, pure, void, ($), (+), (<>)) import Gargantext.Prelude (Unit, bind, discard, map, pure, void, ($), (+), (<>), (==))
import Gargantext.Routes (AppRoute) import Gargantext.Routes (AppRoute)
import Gargantext.Sessions (OpenNodes, Session, mkNodeId, get) import Gargantext.Sessions (OpenNodes, Session, mkNodeId, get)
import Gargantext.Types (ID, Reload, isPublic, publicize) import Gargantext.Types (ID, Reload, isPublic, publicize)
...@@ -45,6 +45,7 @@ type CommonProps = ...@@ -45,6 +45,7 @@ type CommonProps =
, openNodes :: R.State OpenNodes , openNodes :: R.State OpenNodes
, reload :: R.State Reload , reload :: R.State Reload
, session :: Session , session :: Session
, handed :: GT.Handed
) )
------------------------------------------------------------------------ ------------------------------------------------------------------------
...@@ -66,6 +67,7 @@ treeView props = R.createElement treeViewCpt props [] ...@@ -66,6 +67,7 @@ treeView props = R.createElement treeViewCpt props []
, openNodes , openNodes
, reload , reload
, session , session
, handed
} _children = pure } _children = pure
$ treeLoadView { root $ treeLoadView { root
, asyncTasks , asyncTasks
...@@ -74,6 +76,7 @@ treeView props = R.createElement treeViewCpt props [] ...@@ -74,6 +76,7 @@ treeView props = R.createElement treeViewCpt props []
, openNodes , openNodes
, reload , reload
, session , session
, handed
} }
treeLoadView :: Record Props -> R.Element treeLoadView :: Record Props -> R.Element
...@@ -89,6 +92,7 @@ treeLoadView p = R.createElement treeLoadViewCpt p [] ...@@ -89,6 +92,7 @@ treeLoadView p = R.createElement treeLoadViewCpt p []
, openNodes , openNodes
, reload , reload
, session , session
, handed
} _children = do } _children = do
let fetch _ = getNodeTree session root let fetch _ = getNodeTree session root
let paint loaded = loadedTreeView { asyncTasks let paint loaded = loadedTreeView { asyncTasks
...@@ -99,6 +103,7 @@ treeLoadView p = R.createElement treeLoadViewCpt p [] ...@@ -99,6 +103,7 @@ treeLoadView p = R.createElement treeLoadViewCpt p []
, session , session
, tasks: tasksStruct root asyncTasks reload , tasks: tasksStruct root asyncTasks reload
, tree: loaded , tree: loaded
, handed
} }
useLoader { root, counter: fst reload } fetch paint useLoader { root, counter: fst reload } fetch paint
...@@ -127,7 +132,11 @@ loadedTreeView p = R.createElement loadedTreeViewCpt p [] ...@@ -127,7 +132,11 @@ loadedTreeView p = R.createElement loadedTreeViewCpt p []
, session , session
, tasks , tasks
, tree , tree
} _ = pure $ H.ul { className: "tree"} , handed
} _ = pure $ H.ul { className: "tree " <> if handed == GT.RightHanded
then "flex-start"
else "flex-end"
}
[ toHtml { asyncTasks [ toHtml { asyncTasks
, frontends , frontends
, mCurrentRoute , mCurrentRoute
...@@ -136,10 +145,13 @@ loadedTreeView p = R.createElement loadedTreeViewCpt p [] ...@@ -136,10 +145,13 @@ loadedTreeView p = R.createElement loadedTreeViewCpt p []
, session , session
, tasks , tasks
, tree , tree
, handed: GT.RightHanded -- TODO enabling user to change it
} }
] ]
------------------------------------------------------------------------ ------------------------------------------------------------------------
type ToHtmlProps = type ToHtmlProps =
( asyncTasks :: R.State GAT.Storage ( asyncTasks :: R.State GAT.Storage
, tasks :: Record Tasks , tasks :: Record Tasks
...@@ -163,7 +175,8 @@ toHtml p@{ asyncTasks ...@@ -163,7 +175,8 @@ toHtml p@{ asyncTasks
, nodeType , nodeType
} }
) ary ) ary
) )
, handed
} = } =
R.createElement el {} [] R.createElement el {} []
where where
...@@ -190,6 +203,7 @@ toHtml p@{ asyncTasks ...@@ -190,6 +203,7 @@ toHtml p@{ asyncTasks
, nodeType , nodeType
, session , session
, tasks , tasks
, handed
} ] } ]
<> childNodes ( Record.merge commonProps <> childNodes ( Record.merge commonProps
{ asyncTasks { asyncTasks
...@@ -199,6 +213,7 @@ toHtml p@{ asyncTasks ...@@ -199,6 +213,7 @@ toHtml p@{ asyncTasks
) t) ary ) t) ary
else ary else ary
, folderOpen , folderOpen
, handed
} }
) )
...@@ -212,11 +227,12 @@ type ChildNodesProps = ...@@ -212,11 +227,12 @@ type ChildNodesProps =
childNodes :: Record ChildNodesProps -> Array R.Element childNodes :: Record ChildNodesProps -> Array R.Element
childNodes { children: [] } = [] childNodes { children: [] } = []
childNodes { folderOpen: (false /\ _) } = [] childNodes { folderOpen: (false /\ _) } = []
childNodes props@{ asyncTasks, children, reload } = childNodes props@{ asyncTasks, children, reload, handed } =
map (\ctree@(NTree (LNode {id}) _) -> H.ul {} [ map (\ctree@(NTree (LNode {id}) _) -> H.ul {} [
toHtml (Record.merge commonProps { asyncTasks toHtml (Record.merge commonProps { asyncTasks
, tasks: tasksStruct id asyncTasks reload , tasks: tasksStruct id asyncTasks reload
, tree: ctree , tree: ctree
, handed
} }
)] )]
) $ sorted children ) $ sorted children
......
module Gargantext.Components.Forest.Tree.Node where module Gargantext.Components.Forest.Tree.Node where
import Data.Array (reverse)
import Data.Maybe (Maybe(..)) import Data.Maybe (Maybe(..))
import Data.Nullable (null) import Data.Nullable (null)
import Data.Tuple.Nested ((/\)) import Data.Tuple.Nested ((/\))
...@@ -25,7 +26,7 @@ import Gargantext.Components.Lang (Lang(EN)) ...@@ -25,7 +26,7 @@ import Gargantext.Components.Lang (Lang(EN))
import Gargantext.Components.Nodes.Corpus (loadCorpusWithChild) import Gargantext.Components.Nodes.Corpus (loadCorpusWithChild)
import Gargantext.Ends (Frontends, url) import Gargantext.Ends (Frontends, url)
import Gargantext.Hooks.Loader (useLoader) import Gargantext.Hooks.Loader (useLoader)
import Gargantext.Prelude (Unit, bind, const, discard, map, pure, show, unit, void, ($), (<>), (==)) import Gargantext.Prelude (Unit, bind, const, discard, map, pure, show, unit, void, ($), (<>), (==), identity)
import Gargantext.Routes as Routes import Gargantext.Routes as Routes
import Gargantext.Version as GV import Gargantext.Version as GV
import Gargantext.Sessions (Session, sessionId) import Gargantext.Sessions (Session, sessionId)
...@@ -44,12 +45,13 @@ type NodeMainSpanProps = ...@@ -44,12 +45,13 @@ type NodeMainSpanProps =
, name :: Name , name :: Name
, nodeType :: GT.NodeType , nodeType :: GT.NodeType
, tasks :: Record Tasks , tasks :: Record Tasks
, handed :: GT.Handed
| CommonProps | CommonProps
) )
nodeMainSpan :: Record NodeMainSpanProps nodeMainSpan :: Record NodeMainSpanProps
-> R.Element -> R.Element
nodeMainSpan p@{ dispatch, folderOpen, frontends, session } = R.createElement el p [] nodeMainSpan p@{ dispatch, folderOpen, frontends, session, handed} = R.createElement el p []
where where
el = R.hooksComponent "G.C.F.T.N.NodeMainSpan" cpt el = R.hooksComponent "G.C.F.T.N.NodeMainSpan" cpt
cpt props@{id, mCurrentRoute, name, nodeType, tasks: { onTaskFinish, tasks }} _ = do cpt props@{id, mCurrentRoute, name, nodeType, tasks: { onTaskFinish, tasks }} _ = do
...@@ -59,7 +61,11 @@ nodeMainSpan p@{ dispatch, folderOpen, frontends, session } = R.createElement el ...@@ -59,7 +61,11 @@ nodeMainSpan p@{ dispatch, folderOpen, frontends, session } = R.createElement el
popoverRef <- R.useRef null popoverRef <- R.useRef null
pure $ H.span (dropProps droppedFile isDragOver) $ pure $ H.span (dropProps droppedFile isDragOver)
$ (if handed == GT.LeftHanded
then reverse
else identity)
$
[ chevronIcon nodeType folderOpen [ chevronIcon nodeType folderOpen
, folderIcon nodeType folderOpen , folderIcon nodeType folderOpen
, if showBox then , if showBox then
......
...@@ -15,6 +15,17 @@ import Prelude ...@@ -15,6 +15,17 @@ import Prelude
import Prim.Row (class Union) import Prim.Row (class Union)
import URI.Query (Query) import URI.Query (Query)
data Handed = LeftHanded | RightHanded
derive instance genericHanded :: Generic Handed _
instance eqHanded :: Eq Handed where
eq = genericEq
-------------------------------------------------------------------------
type ID = Int type ID = Int
type Name = String type Name = String
type Reload = Int type Reload = Int
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment