@@ -6,6 +6,7 @@ import Data.Array (foldMap, intercalate)
66import Data.Array as A
77import Data.Either (Either(..))
88import Data.Foldable (foldl)
9+import Data.Function.Uncurried (mkFn2)
910import Data.Lens ((%~))
1011import Data.Lens.Index (ix)
1112import Data.Maybe (Maybe(..), fromMaybe', isJust)
@@ -17,6 +18,7 @@ import Data.String.Regex as Regex
1718import Data.String.Regex.Flags as RegexFlags
1819import Data.String.Regex.Unsafe (unsafeRegex)
1920import Data.Tuple.Nested ((/\))
21+import Debug.Trace (spy)
2022import Effect (Effect)
2123import Effect.Aff (launchAff_)
2224import Effect.Class (liftEffect)
@@ -155,7 +157,21 @@ mkFillInTheGaps fetch = do
155157 { from: { opacity: 0.0, transform: "translate3d(-50%, -50%, 0) scale3d(0.3, 0.3, 1.0)" }
156158 , enter: { opacity: 1.0, transform: "translate3d(-50%, -50%, 0) scale3d(1.0, 1.0, 1.0)" }
157159 , leave: { opacity: 0.0, transform: "translate3d(-50%, -50%, 0) scale3d(0.3, 0.3, 1.0)" }
158− , config: { mass: 1.0, tension: 170, friction: 20 }
160+ , config: mkFn2 \_ state ->
161+ case spy "state" state of
162+ "leave" -> { mass: 1.0, tension: 140, friction: 15 }
163+ _ -> { mass: 1.0, tension: 170, friction: 20 }
164+ }
165+ clickAwayTransitions <-
166+ useTransition [ result ] (Just show)
167+ $ css
168+ { from: { opacity: 0.0 }
169+ , enter: { opacity: 1.0 }
170+ , leave: { opacity: 0.0 }
171+ , config: mkFn2 \_ state ->
172+ case spy "state" state of
173+ "leave" -> { mass: 1.0, tension: 140, friction: 15 }
174+ _ -> { mass: 1.0, tension: 170, friction: 20 }
159175 }
160176 let
161177 expectedResult = findResult (join segments)
@@ -181,25 +197,31 @@ mkFillInTheGaps fetch = do
181197 [ R.text "Try it" ]
182198 ]
183199 ]
184− , guard (isJust result) do
185− element clickAway (justifill { onClick: modifyResult (const Nothing) })
200+ , fragment
201+ $ clickAwayTransitions
202+ >>= \{ item, key, props } ->
203+ guard (isJust item)
204+ $ join item
205+ # foldMap \_ ->
206+ [element clickAway (justifill { style: props, onClick: modifyResult (const Nothing) })]
186207 , fragment
187208 $ modalTransitions
188− <#> \{ item, key, props } ->
209+ >>= \{ item, key, props } ->
189210 guard (isJust item)
190211 $ join item
191212 # foldMap \r ->
192− jsx modal
193− { title:
194− case r of
195− (Right { stdout })
196− | S.stripSuffix (S.Pattern "\n") stdout == Just expectedResult -> "Hooray!"
197− (Left l) -> "Does not compile"
198− (Right _) -> "Not " <> (findResult $ join segments)
199− , icon: element closeIcon { onClick: modifyResult (const Nothing), style: Nothing }
200− , style: props
201− }
202− [ R.text $ compileResultToString result ]
213+ [ jsx modal
214+ { title:
215+ case r of
216+ (Right { stdout })
217+ | S.stripSuffix (S.Pattern "\n") stdout == Just expectedResult -> "Hooray!"
218+ (Left l) -> "Does not compile"
219+ (Right _) -> "Not " <> (findResult $ join segments)
220+ , icon: element closeIcon { onClick: modifyResult (const Nothing), style: Nothing }
221+ , style: props
222+ }
223+ [ R.text $ compileResultToString result ]
224+ ]
203225 ]
204226
205227compileResultToString ∷ Maybe (Either CompileResult RunResult) -> String