@@ -6,6 +6,7 @@ import Data.Array (foldMap, intercalate)
6import Data.Array as A
6import Data.Array as A
7import Data.Either (Either(..))
7import Data.Either (Either(..))
8import Data.Foldable (foldl)
8import Data.Foldable (foldl)
9+import Data.Function.Uncurried (mkFn2)
9import Data.Lens ((%~))
10import Data.Lens ((%~))
10import Data.Lens.Index (ix)
11import Data.Lens.Index (ix)
11import Data.Maybe (Maybe(..), fromMaybe', isJust)
12import Data.Maybe (Maybe(..), fromMaybe', isJust)
@@ -17,6 +18,7 @@ import Data.String.Regex as Regex
17import Data.String.Regex.Flags as RegexFlags
18import Data.String.Regex.Flags as RegexFlags
18import Data.String.Regex.Unsafe (unsafeRegex)
19import Data.String.Regex.Unsafe (unsafeRegex)
19import Data.Tuple.Nested ((/\))
20import Data.Tuple.Nested ((/\))
21+import Debug.Trace (spy)
20import Effect (Effect)
22import Effect (Effect)
21import Effect.Aff (launchAff_)
23import Effect.Aff (launchAff_)
22import Effect.Class (liftEffect)
24import Effect.Class (liftEffect)
@@ -155,7 +157,21 @@ mkFillInTheGaps fetch = do
155 { from: { opacity: 0.0, transform: "translate3d(-50%, -50%, 0) scale3d(0.3, 0.3, 1.0)" }
157 { from: { opacity: 0.0, transform: "translate3d(-50%, -50%, 0) scale3d(0.3, 0.3, 1.0)" }
156 , enter: { opacity: 1.0, transform: "translate3d(-50%, -50%, 0) scale3d(1.0, 1.0, 1.0)" }
158 , enter: { opacity: 1.0, transform: "translate3d(-50%, -50%, 0) scale3d(1.0, 1.0, 1.0)" }
157 , leave: { opacity: 0.0, transform: "translate3d(-50%, -50%, 0) scale3d(0.3, 0.3, 1.0)" }
159 , leave: { opacity: 0.0, transform: "translate3d(-50%, -50%, 0) scale3d(0.3, 0.3, 1.0)" }
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 }
165+ clickAwayTransitions <-
166+ useTransition [ result ] (Just show)
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 }
158− , config: { mass: 1.0, tension: 170, friction: 20 }
174+ _ -> { mass: 1.0, tension: 170, friction: 20 }
161 expectedResult = findResult (join segments)
177 expectedResult = findResult (join segments)
@@ -181,25 +197,31 @@ mkFillInTheGaps fetch = do
181 [ R.text "Try it" ]
197 [ R.text "Try it" ]
201+ $ clickAwayTransitions
202+ >>= \{ item, key, props } ->
184− , guard (isJust result) do
203+ guard (isJust item)
185− element clickAway (justifill { onClick: modifyResult (const Nothing) })
206+ [element clickAway (justifill { style: props, onClick: modifyResult (const Nothing) })]
186 , fragment
207 , fragment
187 $ modalTransitions
208 $ modalTransitions
188− <#> \{ item, key, props } ->
209+ >>= \{ item, key, props } ->
189 guard (isJust item)
210 guard (isJust item)
190 $ join item
211 $ join item
191 # foldMap \r ->
212 # foldMap \r ->
192− jsx modal
213+ [ jsx modal
193− { title:
214+ { title:
194− case r of
215+ case r of
195− (Right { stdout })
216+ (Right { stdout })
196− | S.stripSuffix (S.Pattern "\n") stdout == Just expectedResult -> "Hooray!"
217+ | S.stripSuffix (S.Pattern "\n") stdout == Just expectedResult -> "Hooray!"
197− (Left l) -> "Does not compile"
218+ (Left l) -> "Does not compile"
198− (Right _) -> "Not " <> (findResult $ join segments)
219+ (Right _) -> "Not " <> (findResult $ join segments)
199− , icon: element closeIcon { onClick: modifyResult (const Nothing), style: Nothing }
220+ , icon: element closeIcon { onClick: modifyResult (const Nothing), style: Nothing }
200− , style: props
221+ , style: props
202− [ R.text $ compileResultToString result ]
223+ [ R.text $ compileResultToString result ]
205compileResultToString ∷ Maybe (Either CompileResult RunResult) -> String
227compileResultToString ∷ Maybe (Either CompileResult RunResult) -> String