@@ -1,4 +1,4 @@
1−module Yoga.Layer.Stories where
1+module Yoga.InlineCode.Stories where
3import Prelude hiding (add)
3import Prelude hiding (add)
4import Data.Array (intercalate)
4import Data.Array (intercalate)
@@ -21,39 +21,39 @@ import React.Basic.Hooks as React
21import Storybook.Decorator.FullScreen (fullScreenDecorator)
21import Storybook.Decorator.FullScreen (fullScreenDecorator)
22import Storybook.React (Storybook, add, addDecorator, storiesOf)
22import Storybook.React (Storybook, add, addDecorator, storiesOf)
23import Yoga.CompileEditor.Component (compileAndRun)
23import Yoga.CompileEditor.Component (compileAndRun)
24−import Yoga.Layer.Component (Action(..))
24+import Yoga.InlineCode.Component (Action(..))
25−import Yoga.Layer.Component as Layer
25+import Yoga.InlineCode.Component as InlineCode
26import Yoga.Modal.Component as Modal
26import Yoga.Modal.Component as Modal
28stories ∷ Effect Storybook
28stories ∷ Effect Storybook
29stories = do
29stories = do
30− storiesOf "Layer" do
30+ storiesOf "InlineCode" do
31 addDecorator fullScreenDecorator
31 addDecorator fullScreenDecorator
32− add "The Layer" Layer.makeComponent
32+ add "The InlineCode" InlineCode.makeComponent
33 [ ( justifill
33 [ ( justifill
34− { dispatch: \(_ ∷ Layer.Action) -> ((log "hi") ∷ Effect Unit)
34+ { dispatch: \(_ ∷ InlineCode.Action) -> ((log "hi") ∷ Effect Unit)
38− add "The Layer with some context" mkWrapper
38+ add "The InlineCode with some context" mkWrapper
39 [ { inside:
39 [ { inside:
40 \inlineCode ->
40 \inlineCode ->
41 [ R.text "hi!"
41 [ R.text "hi!"
42− , element inlineCode (justifill { dispatch: \(_ ∷ Layer.Action) -> (log "Hi") ∷ Effect Unit })
42+ , element inlineCode (justifill { dispatch: \(_ ∷ InlineCode.Action) -> (log "Hi") ∷ Effect Unit })
43 , R.text "hello again!"
43 , R.text "hello again!"
47− add "The Layer with some code" mkWrapper
47+ add "The InlineCode with some code" mkWrapper
48 [ { inside:
48 [ { inside:
49 \inlineCode ->
49 \inlineCode ->
50 [ R.code_ [ R.text "main = logShow \"" ]
50 [ R.code_ [ R.text "main = logShow \"" ]
51− , element inlineCode (justifill { dispatch: \(_ ∷ Layer.Action) -> (log "Hi") ∷ Effect Unit })
51+ , element inlineCode (justifill { dispatch: \(_ ∷ InlineCode.Action) -> (log "Hi") ∷ Effect Unit })
52 , R.code_ [ R.text "\"" ]
52 , R.code_ [ R.text "\"" ]
56− add "The Layer with some real code" mkRealWrapper
56+ add "The InlineCode with some real code" mkRealWrapper
59codePrefix =
59codePrefix =
@@ -69,10 +69,10 @@ renderCode c = intercalate [ R.br {} ] (toJSX <$> lines)
69 toJSX line = [ R.code_ [ R.text line ] ]
69 toJSX line = [ R.code_ [ R.text line ] ]
70 lines = split (Pattern "\n") c
70 lines = split (Pattern "\n") c
72−mkWrapper ∷ Effect (ReactComponent { inside ∷ ReactComponent Layer.Props -> Array JSX })
72+mkWrapper ∷ Effect (ReactComponent { inside ∷ ReactComponent InlineCode.Props -> Array JSX })
73mkWrapper = do
73mkWrapper = do
74− inlineCode <- Layer.makeComponent
74+ inlineCode <- InlineCode.makeComponent
75− component "LayerWrapper" \{ inside } -> React.do
75+ component "InlineCodeWrapper" \{ inside } -> React.do
77 $ R.div_ (inside inlineCode)
77 $ R.div_ (inside inlineCode)
@@ -80,21 +80,21 @@ type State
80 = Maybe Boolean
80 = Maybe Boolean
82data RealAction
82data RealAction
83− = LayerAction Layer.Action
83+ = InlineCodeAction InlineCode.Action
84 | CloseModal
84 | CloseModal
86derive instance eqRealAction ∷ Eq RealAction
86derive instance eqRealAction ∷ Eq RealAction
87mkRealWrapper ∷ Effect (ReactComponent {})
87mkRealWrapper ∷ Effect (ReactComponent {})
88mkRealWrapper = do
88mkRealWrapper = do
89− inlineCode <- Layer.makeComponent
89+ inlineCode <- InlineCode.makeComponent
90 modal <- Modal.makeComponent
90 modal <- Modal.makeComponent
91− component "LayerWrapper" \{} -> React.do
91+ component "InlineCodeWrapper" \{} -> React.do
92 state /\ dispatch <- useAffReducer Nothing realReducer
92 state /\ dispatch <- useAffReducer Nothing realReducer
95 [ R.h2_ [ R.text "Let's log some 'Magick'" ]
95 [ R.h2_ [ R.text "Let's log some 'Magick'" ]
96 , fragment $ renderCode codePrefix
96 , fragment $ renderCode codePrefix
97− , element inlineCode (justifill { dispatch: dispatch <<< LayerAction, width: String.length "Magick" })
97+ , element inlineCode (justifill { dispatch: dispatch <<< InlineCodeAction, width: String.length "Magick" })
98 , fragment $ renderCode codeSuffix
98 , fragment $ renderCode codeSuffix
100 , case state of
100 , case state of
@@ -106,7 +106,7 @@ mkRealWrapper = do
106realReducer ∷ State -> RealAction -> Aff State
106realReducer ∷ State -> RealAction -> Aff State
107realReducer state = case _ of
107realReducer state = case _ of
108 CloseModal -> pure Nothing
108 CloseModal -> pure Nothing
109− LayerAction (CompileAndRunCode code) -> do
109+ InlineCodeAction (CompileAndRunCode code) -> do
110 res <- compileAndRun (M.fetch windowFetch) { code: codePrefix <> code <> codeSuffix }
110 res <- compileAndRun (M.fetch windowFetch) { code: codePrefix <> code <> codeSuffix }
111 (pure <<< pure) case res of
111 (pure <<< pure) case res of
112 Right { stdout }
112 Right { stdout }