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
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
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
Grégoire Locqueville
purescript-gargantext
Commits
af918879
Commit
af918879
authored
Apr 25, 2019
by
James Laver
Committed by
Alexandre Delanoë
Apr 28, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
upgrade to use reactix 0.1.0
parent
22a391de
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
25 additions
and
36 deletions
+25
-36
AnnotatedField.purs
src/Gargantext/Components/Annotation/AnnotatedField.purs
+10
-9
Menu.purs
src/Gargantext/Components/Annotation/Menu.purs
+4
-5
ContextMenu.purs
src/Gargantext/Components/ContextMenu/ContextMenu.purs
+6
-8
Reactix.purs
src/Gargantext/Utils/Reactix.purs
+5
-14
No files found.
src/Gargantext/Components/Annotation/AnnotatedField.purs
View file @
af918879
...
@@ -20,6 +20,7 @@ import Data.Tuple ( Tuple(..) )
...
@@ -20,6 +20,7 @@ import Data.Tuple ( Tuple(..) )
import Effect ( Effect )
import Effect ( Effect )
import Reactix as R
import Reactix as R
import Reactix.DOM.Raw as RDOM
import Reactix.DOM.Raw as RDOM
import Reactix.SyntheticEvent as E
import Gargantext.Types ( TermList(..) )
import Gargantext.Types ( TermList(..) )
import Gargantext.Components.Annotation.Utils ( termClass )
import Gargantext.Components.Annotation.Utils ( termClass )
...
@@ -37,13 +38,13 @@ defaultProps :: Record Props
...
@@ -37,13 +38,13 @@ defaultProps :: Record Props
defaultProps = { ngrams: NgramsTable Map.empty, text: Nothing }
defaultProps = { ngrams: NgramsTable Map.empty, text: Nothing }
annotatedField :: Record Props -> R.Element
annotatedField :: Record Props -> R.Element
annotatedField
= R.createLeaf annotatedFieldComponent
annotatedField
p = R.createElement annotatedFieldComponent p []
annotatedFieldComponent :: R.Component Props
annotatedFieldComponent :: R.Component Props
annotatedFieldComponent = R.
pureLeaf
"AnnotatedField" cpt
annotatedFieldComponent = R.
staticComponent
"AnnotatedField" cpt
where
where
runs props = annotateRun <$> compile props
runs props = annotateRun <$> compile props
cpt props =
cpt props
_
=
RDOM.div { className: "annotated-field-wrapper" }
RDOM.div { className: "annotated-field-wrapper" }
[ annotationMenu { termList: Nothing }
[ annotationMenu { termList: Nothing }
, RDOM.div { className: "annotated-field-runs" } (annotateRun <$> compile props) ]
, RDOM.div { className: "annotated-field-runs" } (annotateRun <$> compile props) ]
...
@@ -51,11 +52,11 @@ annotatedFieldComponent = R.pureLeaf "AnnotatedField" cpt
...
@@ -51,11 +52,11 @@ annotatedFieldComponent = R.pureLeaf "AnnotatedField" cpt
type RunProps = ( list :: Maybe TermList, text :: String )
type RunProps = ( list :: Maybe TermList, text :: String )
annotateRun :: Run -> R.Element
annotateRun :: Run -> R.Element
annotateRun (Tuple text list) = R.create
Leaf annotatedRunComponent { text, list }
annotateRun (Tuple text list) = R.create
Element annotatedRunComponent { text, list } []
annotatedRunComponent :: R.Component RunProps
annotatedRunComponent :: R.Component RunProps
annotatedRunComponent = R.
pureLeaf
"AnnotatedRun" cpt
annotatedRunComponent = R.
staticComponent
"AnnotatedRun" cpt
where cpt { text, list } = maybe (unstyled text) (styled text) list
where cpt { text, list }
_
= maybe (unstyled text) (styled text) list
styled text list = RDOM.span { className: className list } [ RDOM.text text ]
styled text list = RDOM.span { className: className list } [ RDOM.text text ]
unstyled text = RDOM.span {} [ RDOM.text text ]
unstyled text = RDOM.span {} [ RDOM.text text ]
className list = "annotation-run " <> termClass list
className list = "annotation-run " <> termClass list
...
@@ -65,16 +66,16 @@ compile props = runs props.text
...
@@ -65,16 +66,16 @@ compile props = runs props.text
where runs (Just text) = highlightNgrams props.ngrams text
where runs (Just text) = highlightNgrams props.ngrams text
runs _ = []
runs _ = []
maybeShowMenu ::
Synthetic
Event -> NgramsTable -> (Maybe TermList -> Effect Unit) -> Effect Unit
maybeShowMenu ::
E.Mouse
Event -> NgramsTable -> (Maybe TermList -> Effect Unit) -> Effect Unit
maybeShowMenu e n a = Sel.getSelection >>= traverse_ (a <<< findNgram n <<< Sel.toString)
maybeShowMenu e n a = Sel.getSelection >>= traverse_ (a <<< findNgram n <<< Sel.toString)
showMenu
--
showMenu
findNgram :: NgramsTable -> String -> Maybe TermList
findNgram :: NgramsTable -> String -> Maybe TermList
findNgram _ _ = Nothing
findNgram _ _ = Nothing
-- contextMenuHandler :: (Action -> Effect Unit) ->
Synthetic
MouseEvent -> Effect Unit
-- contextMenuHandler :: (Action -> Effect Unit) -> MouseEvent -> Effect Unit
-- contextMenuHandler d e =
-- contextMenuHandler d e =
-- do sel <- getSelection
-- do sel <- getSelection
-- case toString <$> sel of
-- case toString <$> sel of
...
...
src/Gargantext/Components/Annotation/Menu.purs
View file @
af918879
...
@@ -22,14 +22,13 @@ type Props = ( termList :: Maybe TermList )
...
@@ -22,14 +22,13 @@ type Props = ( termList :: Maybe TermList )
-- | An Annotation Menu is parameterised by a Maybe Termlist of the
-- | An Annotation Menu is parameterised by a Maybe Termlist of the
-- | TermList the currently selected text belongs to
-- | TermList the currently selected text belongs to
annotationMenu :: Record Props -> R.Element
annotationMenu :: Record Props -> R.Element
annotationMenu
= R.createLeaf annotationMenuCpt
annotationMenu
p = R.createElement annotationMenuCpt p []
annotationMenuCpt :: R.Component Props
annotationMenuCpt :: R.Component Props
annotationMenuCpt = R.hooks
Leaf
"Annotation.Menu" cpt
annotationMenuCpt = R.hooks
Component
"Annotation.Menu" cpt
where
where
cpt :: forall m. R'.HooksLeaf m Props
cpt { termList } _ = pure $
cpt { termList } = pure $
RDOM.div { className: "annotation-menu" } [ CM.contextMenu $ children termList ]
R'.div { className: "annotation-menu" } [ CM.contextMenu $ children termList ]
children l = A.mapMaybe (\l' -> addToList l' l) [ GraphTerm, CandidateTerm, StopTerm ]
children l = A.mapMaybe (\l' -> addToList l' l) [ GraphTerm, CandidateTerm, StopTerm ]
-- | Given the TermList to render the item for and the Maybe TermList the item may belong to, possibly render the menuItem
-- | Given the TermList to render the item for and the Maybe TermList the item may belong to, possibly render the menuItem
...
...
src/Gargantext/Components/ContextMenu/ContextMenu.purs
View file @
af918879
...
@@ -10,23 +10,21 @@ import Reactix.DOM.Raw as RDOM
...
@@ -10,23 +10,21 @@ import Reactix.DOM.Raw as RDOM
import Gargantext.Utils.Reactix as R'
import Gargantext.Utils.Reactix as R'
contextMenu :: Array R.Element -> R.Element
contextMenu :: Array R.Element -> R.Element
contextMenu = R.create
Tree
contextMenuCpt {}
contextMenu = R.create
Element
contextMenuCpt {}
contextMenuCpt :: R.Component (
R'.WithChildren ()
)
contextMenuCpt :: R.Component ()
contextMenuCpt = R.hooks
Tree
"ContextMenu" cpt
contextMenuCpt = R.hooks
Component
"ContextMenu" cpt
where
where
cpt :: forall m. R'.HooksTree m ()
cpt _props children = pure $
cpt _props children = pure $
R'.nav { className: "context-menu" }
R'.nav { className: "context-menu" }
[ R'.ul { className: "context-menu-items" } children ]
[ R'.ul { className: "context-menu-items" } children ]
contextMenuItem :: Array R.Element -> R.Element
contextMenuItem :: Array R.Element -> R.Element
contextMenuItem = R.create
Tree
contextMenuItemCpt {}
contextMenuItem = R.create
Element
contextMenuItemCpt {}
contextMenuItemCpt :: R.Component (
R'.WithChildren ()
)
contextMenuItemCpt :: R.Component ()
contextMenuItemCpt = R.hooks
Tree
"ContextMenuItem" cpt
contextMenuItemCpt = R.hooks
Component
"ContextMenuItem" cpt
where
where
cpt :: forall m. R'.HooksTree m ()
cpt _props children = pure $ R'.li { className: "context-menu-item" } children
cpt _props children = pure $ R'.li { className: "context-menu-item" } children
...
...
src/Gargantext/Utils/Reactix.purs
View file @
af918879
module Gargantext.Utils.Reactix
module Gargantext.Utils.Reactix
(
WithChildren, HooksTree, HooksLeaf,
buff, scuff, nav, ul, li, a, div )
( buff, scuff, nav, ul, li, a, div )
where
where
import React ( ReactElement )
import React ( ReactElement )
import Reactix as R
import Reactix as R
import Unsafe.Coerce ( unsafeCoerce )
import Unsafe.Coerce ( unsafeCoerce )
-- | A convenience for adding `children` to a list of props
type WithChildren p = ( children :: R.Children | p )
type HooksTree m p = R.MonadHooks m => Record p -> Array R.Element -> m R.Element
type HooksLeaf m p = R.MonadHooks m => Record p -> m R.Element
-- | Turns a ReactElement into a Reactix Element
-- | Turns a ReactElement into a Reactix Element
-- | buff (v.) to polish
-- | buff (v.) to polish
buff :: ReactElement -> R.Element
buff :: ReactElement -> R.Element
...
@@ -22,18 +16,15 @@ buff = unsafeCoerce
...
@@ -22,18 +16,15 @@ buff = unsafeCoerce
scuff :: R.Element -> ReactElement
scuff :: R.Element -> ReactElement
scuff = unsafeCoerce
scuff = unsafeCoerce
div :: forall r. Record r -> Array R.Element -> R.Element
div = R.createDOMElement "div"
nav :: forall r. Record r -> Array R.Element -> R.Element
nav :: forall r. Record r -> Array R.Element -> R.Element
nav = R.create
DOM
Element "nav"
nav = R.createElement "nav"
ul :: forall r. Record r -> Array R.Element -> R.Element
ul :: forall r. Record r -> Array R.Element -> R.Element
ul = R.create
DOM
Element "ul"
ul = R.createElement "ul"
li :: forall r. Record r -> Array R.Element -> R.Element
li :: forall r. Record r -> Array R.Element -> R.Element
li = R.create
DOM
Element "li"
li = R.createElement "li"
a :: forall r. Record r -> Array R.Element -> R.Element
a :: forall r. Record r -> Array R.Element -> R.Element
a = R.create
DOM
Element "a"
a = R.createElement "a"
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