Commit f9df8e9f authored by James Laver's avatar James Laver

R2.StateSetter is now R2.Setter

parent ffe37f84
...@@ -87,7 +87,7 @@ maybeShowMenu setMenu setTermList ngrams event = do ...@@ -87,7 +87,7 @@ maybeShowMenu setMenu setTermList ngrams event = do
Nothing -> pure unit Nothing -> pure unit
maybeAddMenu maybeAddMenu
:: R2.StateSetter (Maybe AnnotationMenu) :: R2.Setter (Maybe AnnotationMenu)
-> R.Element -> R.Element
-> Maybe AnnotationMenu -> Maybe AnnotationMenu
-> R.Element -> R.Element
......
...@@ -28,7 +28,7 @@ type AnnotationMenu = { x :: Number, y :: Number | Props } ...@@ -28,7 +28,7 @@ type AnnotationMenu = { x :: Number, y :: Number | Props }
-- | 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 :: R2.StateSetter (Maybe AnnotationMenu) -> AnnotationMenu -> R.Element annotationMenu :: R2.Setter (Maybe AnnotationMenu) -> AnnotationMenu -> R.Element
annotationMenu setMenu { x,y,list,menuType,setList } = annotationMenu setMenu { x,y,list,menuType,setList } =
CM.contextMenu { x,y,setMenu } [ CM.contextMenu { x,y,setMenu } [
R.createElement annotationMenuCpt {list,menuType,setList} [] R.createElement annotationMenuCpt {list,menuType,setList} []
......
...@@ -21,7 +21,7 @@ import Reactix.DOM.HTML as HTML ...@@ -21,7 +21,7 @@ import Reactix.DOM.HTML as HTML
import Gargantext.Utils.Reactix as R2 import Gargantext.Utils.Reactix as R2
type Props t = ( x :: Number, y :: Number, setMenu :: R2.StateSetter (Maybe t) ) type Props t = ( x :: Number, y :: Number, setMenu :: R2.Setter (Maybe t) )
contextMenu :: forall t. Record (Props t) -> Array R.Element -> R.Element contextMenu :: forall t. Record (Props t) -> Array R.Element -> R.Element
contextMenu = R.createElement contextMenuCpt contextMenu = R.createElement contextMenuCpt
...@@ -62,7 +62,7 @@ contextMenuCpt = R.hooksComponent "ContextMenu" cpt ...@@ -62,7 +62,7 @@ contextMenuCpt = R.hooksComponent "ContextMenu" cpt
contextMenuEffect contextMenuEffect
:: forall t :: forall t
. R2.StateSetter (Maybe t) . R2.Setter (Maybe t)
-> R.Ref (Nullable DOM.Element) -> R.Ref (Nullable DOM.Element)
-> Effect (Effect Unit) -> Effect (Effect Unit)
contextMenuEffect setMenu rootRef = contextMenuEffect setMenu rootRef =
...@@ -77,14 +77,14 @@ contextMenuEffect setMenu rootRef = ...@@ -77,14 +77,14 @@ contextMenuEffect setMenu rootRef =
DOM.removeEventListener document "scroll" onScroll DOM.removeEventListener document "scroll" onScroll
Nothing -> pure R.nothing Nothing -> pure R.nothing
documentClickHandler :: forall t. R2.StateSetter (Maybe t) -> DOM.Element -> Callback DE.MouseEvent documentClickHandler :: forall t. R2.Setter (Maybe t) -> DOM.Element -> Callback DE.MouseEvent
documentClickHandler hide menu = documentClickHandler hide menu =
R2.named "hideMenuOnClickOutside" $ callback $ \e -> R2.named "hideMenuOnClickOutside" $ callback $ \e ->
if Element.contains menu (DE.target e) if Element.contains menu (DE.target e)
then pure unit then pure unit
else hide (const Nothing) else hide (const Nothing)
documentScrollHandler :: forall t. R2.StateSetter (Maybe t) -> Callback DE.MouseEvent documentScrollHandler :: forall t. R2.Setter (Maybe t) -> Callback DE.MouseEvent
documentScrollHandler hide = documentScrollHandler hide =
R2.named "hideMenuOnScroll" $ callback $ \e -> hide (const Nothing) R2.named "hideMenuOnScroll" $ callback $ \e -> hide (const Nothing)
......
...@@ -34,18 +34,18 @@ import Gargantext.Utils.Range as Range ...@@ -34,18 +34,18 @@ import Gargantext.Utils.Range as Range
import Gargantext.Utils.Reactix as R2 import Gargantext.Utils.Reactix as R2
-- data Axis = X | Y -- data Axis = X | Y
type Epsilon = Number
type Bounds = Range.NumberRange type Bounds = Range.NumberRange
type Epsilon = Number
-- To avoid overloading the terms 'min' and 'max' here, we treat 'min' -- To avoid overloading the terms 'min' and 'max' here, we treat 'min'
-- and 'max' as being the bounds of the scale and 'low' and 'high' as -- and 'max' as being the bounds of the scale and 'low' and 'high' as
-- being the selected values -- being the selected values
type Props = type Props =
( bounds :: Bounds -- The minimum and maximum values it is possible to select ( bounds :: Bounds -- The minimum and maximum values it is possible to select
, initialValue :: Range.NumberRange -- The user's selection of minimum and maximum values , initialValue :: Range.NumberRange -- The user's selection of minimum and maximum values
, epsilon :: Epsilon -- The smallest possible change (for mouse) , epsilon :: Number -- The smallest possible change (for mouse)
, step :: Number -- The 'standard' change (for keyboard) , step :: Number -- The 'standard' change (for keyboard)
-- , axis :: Axis -- Which direction to move in -- , axis :: Axis -- Which direction to move in
, width :: Number , width :: Number
, height :: Number , height :: Number
, onChange :: Range.NumberRange -> Effect Unit ) , onChange :: Range.NumberRange -> Effect Unit )
...@@ -130,7 +130,7 @@ destroyEventHandler name ref = traverse_ destroy $ R.readRef ref ...@@ -130,7 +130,7 @@ destroyEventHandler name ref = traverse_ destroy $ R.readRef ref
EL.removeEventListener document name handler EL.removeEventListener document name handler
R.setRef ref Nothing R.setRef ref Nothing
setKnob :: Knob -> R2.StateSetter Range.NumberRange -> Range.NumberRange -> Number -> Effect Unit setKnob :: Knob -> R2.Setter Range.NumberRange -> Range.NumberRange -> Number -> Effect Unit
setKnob knob setValue r val = setValue $ const $ knobSetter knob r val setKnob knob setValue r val = setValue $ const $ knobSetter knob r val
knobSetter :: Knob -> Range.NumberRange -> Number -> Range.NumberRange knobSetter :: Knob -> Range.NumberRange -> Number -> Range.NumberRange
...@@ -168,7 +168,7 @@ renderScaleSel ref props (Range.Closed {min, max}) = ...@@ -168,7 +168,7 @@ renderScaleSel ref props (Range.Closed {min, max}) =
computeWidth = (show $ 100.0 * (percOffsetMax - percOffsetMin)) <> "%" computeWidth = (show $ 100.0 * (percOffsetMax - percOffsetMin)) <> "%"
renderKnob :: Knob -> R.Ref (Nullable DOM.Element) -> Range.NumberRange -> Bounds -> R2.StateSetter (Maybe Knob) -> Int -> R.Element renderKnob :: Knob -> R.Ref (Nullable DOM.Element) -> Range.NumberRange -> Bounds -> R2.Setter (Maybe Knob) -> Int -> R.Element
renderKnob knob ref (Range.Closed value) bounds set precision = renderKnob knob ref (Range.Closed value) bounds set precision =
H.div { ref, tabIndex, className, aria, onMouseDown, style } [ H.div { ref, tabIndex, className, aria, onMouseDown, style } [
H.div { className: "button" } H.div { className: "button" }
......
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