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
131
Issues
131
List
Board
Labels
Milestones
Merge Requests
3
Merge Requests
3
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
514d1318
Commit
514d1318
authored
Dec 12, 2024
by
Yoelis Acourt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add hoc component + some utils
tosquash
parent
f12ce1f0
Pipeline
#7130
passed with stages
in 17 minutes and 28 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
4 deletions
+20
-4
UseFeatureFlag.purs
src/Gargantext/Hooks/UseFeatureFlag.purs
+12
-4
Reactix.purs
src/Gargantext/Utils/Reactix.purs
+8
-0
No files found.
src/Gargantext/Hooks/UseFeatureFlag.purs
View file @
514d1318
...
@@ -3,8 +3,11 @@ module Gargantext.Hooks.UseFeatureFlag where
...
@@ -3,8 +3,11 @@ module Gargantext.Hooks.UseFeatureFlag where
import Prelude
import Prelude
import Effect.Uncurried (runEffectFn1, EffectFn1)
import Effect.Uncurried (runEffectFn1, EffectFn1)
import Gargantext.Components.CodeEditor (previewPostProcess)
import Gargantext.Utils.Reactix as R2
import Gargantext.Utils.Reactix as R2
import Reactix (hooksComponent)
import Reactix as R
import Reactix as R
import Reactix.DOM.HTML as H
foreign import _useFeatureFlag :: EffectFn1 (Array String) Boolean
foreign import _useFeatureFlag :: EffectFn1 (Array String) Boolean
...
@@ -42,13 +45,18 @@ type FeatureProps =
...
@@ -42,13 +45,18 @@ type FeatureProps =
Usage:
Usage:
feature { keys: [ "keyOne" ], render: \shouldRender -> if shouldRender then H.text "hello" else H.text "you cant see me" }
feature { keys: [ "keyOne" ], render: \shouldRender -> if shouldRender then H.text "hello" else H.text "you cant see me" }
-}
-}
feature :: R2.Leaf
(FeatureProps)
feature :: R2.Leaf
FeatureProps
feature =
feature =
R2.renderLeaf "" $
( \{ keys, render } _ -> do
( \{ keys, render } _ -> do
shouldRender <- useFeatureFlag keys
shouldRender <- useFeatureFlag keys
pure $
pure $
render shouldRender
render shouldRender
)
)
# R.hooksComponent "flagged"
# R2.leaf
hideBehind :: forall a. Array String -> R2.Component a -> R2.Component a
hideBehind keys cpt = R2.renderComponent "" \props children -> do
shouldRender <- useFeatureFlag keys
pure $
if shouldRender then cpt props children
else H.text ""
src/Gargantext/Utils/Reactix.purs
View file @
514d1318
...
@@ -72,6 +72,14 @@ component
...
@@ -72,6 +72,14 @@ component
-> R.Element
-> R.Element
component cpt props children = R.createElement cpt props children
component cpt props children = R.createElement cpt props children
renderComponent :: forall a. String -> R.HooksComponent a -> (Record a -> Array R.Element -> R.Element)
renderComponent name cpt props children =
R.createElement (R.hooksComponent name cpt) props children
renderLeaf :: forall a. String -> R.HooksComponent a -> Leaf a
renderLeaf name cpt props =
renderComponent name cpt props []
leaf
leaf
:: forall cpt p
:: forall cpt p
. R.IsComponent cpt p (Array R.Element)
. R.IsComponent cpt p (Array R.Element)
...
...
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