@@ -9,7 +9,7 @@ import Data.String.CodeUnits as String
9import Data.Tuple.Nested ((/\))
9import Data.Tuple.Nested ((/\))
10import Effect (Effect)
10import Effect (Effect)
11import Effect.Aff (Aff)
11import Effect.Aff (Aff)
12−import Effect.Class.Console (log)
12+import Effect.Console (log)
13import Justifill (justifill)
13import Justifill (justifill)
14import Milkis as M
14import Milkis as M
15import Milkis.Impl.Window (windowFetch)
15import Milkis.Impl.Window (windowFetch)
@@ -22,7 +22,6 @@ import React.Basic.Hooks as React
22import Storybook.Decorator.FullScreen (fullScreenDecorator)
22import Storybook.Decorator.FullScreen (fullScreenDecorator)
23import Storybook.React (Storybook, add, addDecorator, storiesOf)
23import Storybook.React (Storybook, add, addDecorator, storiesOf)
24import Yoga.CompileEditor.Component (compileAndRun)
24import Yoga.CompileEditor.Component (compileAndRun)
25−import Yoga.InlineCode.Component (Action(..))
26import Yoga.InlineCode.Component as InlineCode
25import Yoga.InlineCode.Component as InlineCode
27import Yoga.Modal.Component as Modal
26import Yoga.Modal.Component as Modal
@@ -32,7 +31,7 @@ stories = do
32 addDecorator fullScreenDecorator
31 addDecorator fullScreenDecorator
33 add "The InlineCode" InlineCode.makeComponent
32 add "The InlineCode" InlineCode.makeComponent
34 [ ( justifill
33 [ ( justifill
35− { dispatch: \(_ ∷ InlineCode.Action) -> ((log "hi") ∷ Effect Unit)
34+ { onSubmit: log
@@ -40,7 +39,7 @@ stories = do
40 [ { inside:
39 [ { inside:
41 \inlineCode ->
40 \inlineCode ->
42 [ R.text "hi!"
41 [ R.text "hi!"
43− , element inlineCode (justifill { dispatch: \(_ ∷ InlineCode.Action) -> (log "Hi") ∷ Effect Unit })
42+ , element inlineCode (justifill { onSubmit: log })
44 , R.text "hello again!"
43 , R.text "hello again!"
@@ -49,7 +48,7 @@ stories = do
49 [ { inside:
48 [ { inside:
50 \inlineCode ->
49 \inlineCode ->
51 [ R.code_ [ R.text "main = logShow \"" ]
50 [ R.code_ [ R.text "main = logShow \"" ]
52− , element inlineCode (justifill { dispatch: \(_ ∷ InlineCode.Action) -> (log "Hi") ∷ Effect Unit })
51+ , element inlineCode (justifill { onSubmit: log })
53 , R.code_ [ R.text "\"" ]
52 , R.code_ [ R.text "\"" ]
@@ -84,7 +83,7 @@ type State
84 = Maybe Boolean
83 = Maybe Boolean
86data RealAction
85data RealAction
87− = InlineCodeAction InlineCode.Action
86+ = InlineCodeSubmitted String
88 | CloseModal
87 | CloseModal
90derive instance eqRealAction ∷ Eq RealAction
89derive instance eqRealAction ∷ Eq RealAction
@@ -98,7 +97,7 @@ mkRealWrapper = do
99 [ R.h2_ [ R.text "Let's log some 'Magick'" ]
98 [ R.h2_ [ R.text "Let's log some 'Magick'" ]
100 , fragment $ renderCode codePrefix
99 , fragment $ renderCode codePrefix
101− , element inlineCode (justifill { dispatch: dispatch <<< InlineCodeAction, width: String.length "Magick" })
100+ , element inlineCode (justifill { onSubmit: dispatch <<< InlineCodeSubmitted, width: String.length "Magick" })
102 , fragment $ renderCode codeSuffix
101 , fragment $ renderCode codeSuffix
103 , R.br {}
102 , R.br {}
104 , case state of
103 , case state of
@@ -110,7 +109,7 @@ mkRealWrapper = do
110realReducer ∷ State -> RealAction -> Aff State
109realReducer ∷ State -> RealAction -> Aff State
111realReducer state = case _ of
110realReducer state = case _ of
112 CloseModal -> pure Nothing
111 CloseModal -> pure Nothing
113− InlineCodeAction (CompileAndRunCode code) -> do
112+ InlineCodeSubmitted code -> do
114 res <- compileAndRun (M.fetch windowFetch) { code: codePrefix <> code <> codeSuffix }
113 res <- compileAndRun (M.fetch windowFetch) { code: codePrefix <> code <> codeSuffix }
115 (pure <<< pure) case res of
114 (pure <<< pure) case res of
116 Right { stdout }
115 Right { stdout }