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
1abaea10
Commit
1abaea10
authored
Feb 19, 2021
by
James Laver
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
R2: add 'here' and 'Leaf'
parent
6155a35e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
5 deletions
+20
-5
Reactix.purs
src/Gargantext/Utils/Reactix.purs
+20
-5
No files found.
src/Gargantext/Utils/Reactix.purs
View file @
1abaea10
...
@@ -43,8 +43,21 @@ import Web.HTML (window)
...
@@ -43,8 +43,21 @@ import Web.HTML (window)
import Web.HTML.Window (localStorage)
import Web.HTML.Window (localStorage)
import Web.Storage.Storage (Storage, getItem, setItem)
import Web.Storage.Storage (Storage, getItem, setItem)
type Module = String
type Component p = Record p -> Array R.Element -> R.Element
type Component p = Record p -> Array R.Element -> R.Element
type Leaf p = Record p -> R.Element
type Here =
{ component :: forall p. String -> R.HooksComponent p -> R.Component p
, log :: forall l. l -> Effect Unit }
here :: Module -> Here
here mod =
{ component: R.hooksComponentWithModule mod
, log: log2 ("[" <> mod <> "]") }
-- newtypes
-- newtypes
type NTHooksComponent props = props -> Array R.Element -> R.Hooks R.Element
type NTHooksComponent props = props -> Array R.Element -> R.Hooks R.Element
newtype NTComponent p = NTComponent (EffectFn1 p R.Element)
newtype NTComponent p = NTComponent (EffectFn1 p R.Element)
...
@@ -53,8 +66,9 @@ class NTIsComponent component (props :: Type) children
...
@@ -53,8 +66,9 @@ class NTIsComponent component (props :: Type) children
| component -> props, component -> children where
| component -> props, component -> children where
ntCreateElement :: component -> props -> children -> R.Element
ntCreateElement :: component -> props -> children -> R.Element
instance componentIsNTComponent :: NTIsComponent (NTComponent props) props (Array R.Element) where
instance componentIsNTComponent
ntCreateElement = R.rawCreateElement
:: NTIsComponent (NTComponent props) props (Array R.Element) where
ntCreateElement = R.rawCreateElement
-- | Turns a `HooksComponent` function into a Component
-- | Turns a `HooksComponent` function into a Component
ntHooksComponent :: forall props. String -> NTHooksComponent props -> NTComponent props
ntHooksComponent :: forall props. String -> NTHooksComponent props -> NTComponent props
...
@@ -63,15 +77,16 @@ ntHooksComponent name c = NTComponent $ named name $ mkEffectFn1 c'
...
@@ -63,15 +77,16 @@ ntHooksComponent name c = NTComponent $ named name $ mkEffectFn1 c'
c' :: props -> Effect R.Element
c' :: props -> Effect R.Element
c' props = R.runHooks $ c props (children props)
c' props = R.runHooks $ c props (children props)
ntHooksComponentWithModule :: forall props. Module -> String -> NTHooksComponent props -> NTComponent props
ntHooksComponentWithModule
ntHooksComponentWithModule module' name c = ntHooksComponent (module' <> "." <> name) c
:: forall props. Module -> String -> NTHooksComponent props -> NTComponent props
ntHooksComponentWithModule module' name c =
ntHooksComponent (module' <> "." <> name) c
---------------------------
---------------------------
-- TODO Copied from reactix, export these:
-- TODO Copied from reactix, export these:
children :: forall a. a -> Array R.Element
children :: forall a. a -> Array R.Element
children a = react .. "Children" ... "toArray" $ [ (a .. "children") ]
children a = react .. "Children" ... "toArray" $ [ (a .. "children") ]
type Module = String
---------------------------
---------------------------
newtype Point = Point { x :: Number, y :: Number }
newtype Point = Point { x :: Number, y :: Number }
...
...
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