git.iko.soy/rowtype-yoga/psfp
on master help sign in
Getting the mode
3823f3fMark Eibes
components/.vscode/settings.json+2−1
@@ -4,5 +4,6 @@
4 "search.exclude": {
4 "search.exclude": {
5 "**/.history": true
5 "**/.history": true
6 },
6 },
7− "purescript.addSpagoSources": true
7+ "purescript.addSpagoSources": true,
8+ "nixEnvSelector.nixShellConfig": "NOT_MODIFIED_ENV"
8}
9}
components/packages.dhall+5−21
@@ -127,30 +127,14 @@ let overrides =
127 // { repo = "https://github.com/i-am-the-slime/purescript-css.git"
127 // { repo = "https://github.com/i-am-the-slime/purescript-css.git"
128 , version = "8ea0bab17c268d9c62a09892d7ba231dcbe6308b"
128 , version = "8ea0bab17c268d9c62a09892d7ba231dcbe6308b"
129 }
129 }
130+ , react-testing-library =
131+ upstream.react-testing-library
132+ // { version = "main"
133+ }
130 }
134 }
131
135
132let additions =
136let additions =
133− { react-testing-library =
134− { dependencies =
135− [ "aff-promise"
136− , "console"
137− , "debug"
138− , "effect"
139− , "foreign"
140− , "foreign-object"
141− , "psci-support"
142− , "react-basic-hooks"
143− , "remotedata"
144− , "run"
145− , "simple-json"
146− , "spec"
147− , "spec-discovery"
148− ]
149− , repo =
150− "https://github.com/i-am-the-slime/purescript-react-testing-library.git"
151− , version = "master"
152− }
153− , pseudo-random =
137+ { pseudo-random =
154 { dependencies =
138 { dependencies =
155 [ "prelude", "console", "effect", "lcg", "arrays", "st" ]
139 [ "prelude", "console", "effect", "lcg", "arrays", "st" ]
156 , repo = "https://github.com/opyapeus/purescript-pseudo-random.git"
140 , repo = "https://github.com/opyapeus/purescript-pseudo-random.git"
components/src/Yoga/CompileEditor/Component.purs+14−8
@@ -8,6 +8,7 @@ import Data.Maybe (Maybe(..))
8import Data.Monoid (guard)
8import Data.Monoid (guard)
9import Data.Tuple.Nested ((/\))
9import Data.Tuple.Nested ((/\))
10import Data.TwoOrMore (twoOrMore)
10import Data.TwoOrMore (twoOrMore)
11+import Debug.Trace (spy)
11import Effect (Effect)
12import Effect (Effect)
12import Effect.Aff (Error, launchAff_, message, try)
13import Effect.Aff (Error, launchAff_, message, try)
13import Effect.Class (liftEffect)
14import Effect.Class (liftEffect)
@@ -24,7 +25,7 @@ import Yoga ((</>))
24import Yoga as Y
25import Yoga as Y
25import Yoga.Block as Block
26import Yoga.Block as Block
26import Yoga.Block.Atom.Button.Types as BT
27import Yoga.Block.Atom.Button.Types as BT
27−import Yoga.Block.Container.Style (colour)
28+import Yoga.Block.Container.Style (colour, getDarkOrLightMode)
28import Yoga.Compiler.Types (Compiler)
29import Yoga.Compiler.Types (Compiler)
29import Yoga.Editor (getValue, mkEditor, setValue)
30import Yoga.Editor (getValue, mkEditor, setValue)
30
31
@@ -39,7 +40,12 @@ mkCompileEditor { compileAndRun } = do
39 motionButton <- M.custom Block.button
40 motionButton <- M.custom Block.button
40 reactComponent "CompileEditor" \{ initialCode, height, language } -> React.do
41 reactComponent "CompileEditor" \{ initialCode, height, language } -> React.do
41 activeIndex /\ updateActiveIndex <- React.useState' 0
42 activeIndex /\ updateActiveIndex <- React.useState' 0
42− maybeEditor /\ modifyEditor <- useState Nothing
43+ maybeEditor /\ modifyEditor <- React.useState Nothing
44+ themeMode /\ setThemeMode <- React.useState' Nothing
45+ React.useEffectAlways do
46+ mode <- getDarkOrLightMode
47+ unless (mode == themeMode) do setThemeMode (spy "mode" mode)
48+ mempty
43 let
49 let
44 onLoad e = do
50 onLoad e = do
45 setValue initialCode e
51 setValue initialCode e
@@ -56,7 +62,7 @@ mkCompileEditor { compileAndRun } = do
56 compileResultToString ∷ Maybe (Either Error (Either CompileResult RunResult)) -> String
62 compileResultToString ∷ Maybe (Either Error (Either CompileResult RunResult)) -> String
57 compileResultToString = case _ of
63 compileResultToString = case _ of
58 Nothing -> ""
64 Nothing -> ""
59− Just (Right (Left cr)) -> cr.result <#> _.message # intercalate "/n"
65+ Just (Right (Left cr)) -> cr.result <#> _.message # intercalate "\n"
60 Just (Right (Right r)) -> r.stdout
66 Just (Right (Right r)) -> r.stdout
61 Just (Left e) -> message e
67 Just (Left e) -> message e
62 setCompileResult = modifyCompileResult <<< const
68 setCompileResult = modifyCompileResult <<< const
@@ -75,7 +81,7 @@ mkCompileEditor { compileAndRun } = do
75 , buttonContents:
81 , buttonContents:
76 twoOrMore
82 twoOrMore
77 { id: "editor", value: "Editor" }
83 { id: "editor", value: "Editor" }
78− { id: "Result", value: "Result" }
84+ { id: "result", value: "Result" }
79 []
85 []
80 }
86 }
81 editorView ∷ JSX
87 editorView ∷ JSX
@@ -126,10 +132,11 @@ mkCompileEditor { compileAndRun } = do
126 }
132 }
127 { css:
133 { css:
128 E.css
134 E.css
129− { background: E.str "rgb(42,42,59)"
135+ { background: E.str colour.backgroundLayer2
130 , boxSizing: E.str "content-box"
136 , boxSizing: E.str "content-box"
131 , margin: E.str "0"
137 , margin: E.str "0"
132 , minHeight: E.str "8em"
138 , minHeight: E.str "8em"
139+ , height: E.str height
133 , padding: E.str "0"
140 , padding: E.str "0"
134 , display: E.str "flex"
141 , display: E.str "flex"
135 }
142 }
@@ -155,9 +162,8 @@ mkCompileEditor { compileAndRun } = do
155 [ if activeIndex == 0 then
162 [ if activeIndex == 0 then
156 editorView
163 editorView
157 else
164 else
158− Y.el M.div
165+ Y.el R.div'
159− { layout: M.layout true
160− , initial: M.initial $ css { width: "100%" }
166+ { style: css { width: "100%" }
161 }
167 }
162 [ R.text (compileResultToString compileResult) ]
168 [ R.text (compileResultToString compileResult) ]
163 ]
169 ]