@@ -13,17 +13,20 @@ import Data.Nullable as Nullable
13import Data.Symbol (SProxy(..))
13import Data.Symbol (SProxy(..))
14import Data.Traversable (for, sequence)
14import Data.Traversable (for, sequence)
15import Data.Tuple.Nested ((/\), type (/\))
15import Data.Tuple.Nested ((/\), type (/\))
16+import Debug.Trace (spy)
16import Effect (Effect)
17import Effect (Effect)
17import Effect.Class.Console (log)
18import Effect.Class.Console (log)
18import Justifill (justifill)
19import Justifill (justifill)
19import Partial.Unsafe (unsafeCrashWith)
20import Partial.Unsafe (unsafeCrashWith)
20import React.Basic (ReactComponent)
21import React.Basic (ReactComponent)
21import React.Basic.DOM (css)
22import React.Basic.DOM (css)
23+import React.Basic.DOM as R
22import React.Basic.Helpers (jsx)
24import React.Basic.Helpers (jsx)
23import React.Basic.Hooks (Ref, component, element, readRef, useLayoutEffect, useRef, useState, writeRef)
25import React.Basic.Hooks (Ref, component, element, readRef, useLayoutEffect, useRef, useState, writeRef)
24import React.Basic.Hooks as React
26import React.Basic.Hooks as React
25import React.Basic.Hooks.Spring (animatedDiv, useSprings)
27import React.Basic.Hooks.Spring (animatedDiv, useSprings)
26import React.Basic.Hooks.UseGesture (useDrag, withDragProps)
28import React.Basic.Hooks.UseGesture (useDrag, withDragProps)
29+import Record (disjointUnion)
27import Record as Record
30import Record as Record
28import Record.Extra (pick)
31import Record.Extra (pick)
29import Unsafe.Coerce (unsafeCoerce)
32import Unsafe.Coerce (unsafeCoerce)
@@ -96,13 +99,13 @@ scaledCompletely = "scale3d(2.0, 2.0, 2.0)"
96defaultSprings =
99defaultSprings =
99− , shadow: 5
102+ , shadow: 1
100 , zIndex: 0
103 , zIndex: 0
101 , immediate: const true
104 , immediate: const true
102 , transform: "scale3d(1.0,1.0,1.0)"
105 , transform: "scale3d(1.0,1.0,1.0)"
105−springsteen init windowSize rectsRef positionsRef arg mx my down tap springs = do
108+springsteen springs init windowSize rectsRef positionsRef { arg, movement: mx /\ my, down, tap } = do
107 rects <- readRef rectsRef
110 rects <- readRef rectsRef
108 positionsBefore <- readRef positionsRef
111 positionsBefore <- readRef positionsRef
@@ -132,7 +135,7 @@ springsteen init windowSize rectsRef positionsRef arg mx my down tap springs = d
132 , y = my + topOffset
135 , y = my + topOffset
133 , zIndex = 1
136 , zIndex = 1
134 , transform = scaledUp
137 , transform = scaledUp
135− , shadow = 20
138+ , shadow = 10
136 , immediate = \n -> n == "x" || n == "y" || n == "zIndex"
139 , immediate = \n -> n == "x" || n == "y" || n == "zIndex"
138 true, Just { index, value }
141 true, Just { index, value }
@@ -140,7 +143,7 @@ springsteen init windowSize rectsRef positionsRef arg mx my down tap springs = d
140 defaultSprings
143 defaultSprings
141 { x = rectDragged.left - currentRect.left + leftOffset
144 { x = rectDragged.left - currentRect.left + leftOffset
142 , y = rectDragged.top - currentRect.top + topOffset
145 , y = rectDragged.top - currentRect.top + topOffset
143− , immediate = const false
146+ , immediate = \n -> n == "zIndex"
146 defaultSprings
149 defaultSprings
@@ -190,23 +193,30 @@ makeComponent = do
191 theme ∷ CSSTheme <- useTheme
194 theme ∷ CSSTheme <- useTheme
192 bindDragProps <-
195 bindDragProps <-
193− useDrag (justifill { filterTaps: true }) \{ arg, down, movement: mx /\ my, tap } ->
196+ useDrag (justifill { filterTaps: true }) \input ->
194− springsteen init windowSize rectsRef positionsRef arg mx my down tap springs
197+ springsteen springs init windowSize rectsRef positionsRef input
196 renderSpells =
199 renderSpells =
197 mapWithIndex \i (spell /\ style) ->
200 mapWithIndex \i (spell /\ style) ->
202+ { style: css { height: "100px", overflow: "visible" }
198− animatedDiv
204+ [ animatedDiv
199− $ { style:
205+ $ { style:
201− $ Record.insert (SProxy ∷ _ "boxShadow")
207+ $ disjointUnion
202− ((unsafeCoerce (style.shadow ∷ Int)).interpolate (\s -> Interp.i "rgba(0, 0, 0, 0.15) 0px " s "px " (2 * s) "px 0px" ∷ String))
208+ { boxShadow: ((unsafeCoerce (style.shadow ∷ Int)).interpolate \s -> Interp.i "rgba(0, 0, 0, 0.15) 0px " s "px " (2 * s) "px 0px" ∷ String)
209+ , position: "relative"
204− , className: classes.container
212+ , className: classes.container
205− , ref: unsafeCoerce (unsafeUpdateRefs nodeRefs i)
213+ , ref: unsafeCoerce (unsafeUpdateRefs nodeRefs i)
206− , children: [ element spellComponent { spell } ]
214+ , children: [ element spellComponent { spell } ]
208− `withDragProps`
216+ `withDragProps`
209− bindDragProps i
217+ bindDragProps i
211 $ jsx grid {}
221 $ jsx grid {}
212 $ renderSpells (spells `zip` springs.styles)
222 $ renderSpells (spells `zip` springs.styles)