git.iko.soy/rowtype-yoga/psfp
on master help sign in
Components to 0.14
2001db5Mark Eibes
components/package.json+3−6
@@ -58,17 +58,14 @@
58 "monaco-editor": "^0.20.0",
58 "monaco-editor": "^0.20.0",
59 "monaco-editor-webpack-plugin": "^1.8.2",
59 "monaco-editor-webpack-plugin": "^1.8.2",
60 "npm-run-all": "^4.1.5",
60 "npm-run-all": "^4.1.5",
61− "purescript": "^0.13.8",
61+ "purescript": "^0.14.0",
62− "purescript-psa": "^0.7.3",
63− "purs-loader": "^3.6.0",
64− "purty": "^6.2.0",
65 "react": "^16.13.1",
62 "react": "^16.13.1",
66 "react-dom": "^16.13.1",
63 "react-dom": "^16.13.1",
67 "react-hot-loader": "^4.12.21",
64 "react-hot-loader": "^4.12.21",
68 "react-monaco-editor": "^0.36.0",
65 "react-monaco-editor": "^0.36.0",
69 "react-svg-loader": "^3.0.3",
66 "react-svg-loader": "^3.0.3",
70 "smoothscroll-polyfill": "^0.4.4",
67 "smoothscroll-polyfill": "^0.4.4",
71− "spago": "^0.15.2",
68+ "spago": "^0.19.1",
72 "typescript": "^3.7.5",
69 "typescript": "^3.7.5",
73 "webpack": "^4.41.0",
70 "webpack": "^4.41.0",
74 "webpack-cli": "^3.3.6",
71 "webpack-cli": "^3.3.6",
@@ -76,4 +73,4 @@
76 "webpack-merge": "^4.2.2",
73 "webpack-merge": "^4.2.2",
77 "wrappy": "^1.0.2"
74 "wrappy": "^1.0.2"
78 }
75 }
79−}
76+}
components/packages.dhall+4−8
@@ -116,20 +116,14 @@ let additions =
116 }
116 }
117-------------------------------
117-------------------------------
118-}
118-}
119−
120−
121let upstream =
119let upstream =
122− https://github.com/purescript/package-sets/releases/download/psc-0.13.8-20201223/packages.dhall sha256:a1a8b096175f841c4fef64c9b605fb0d691229241fd2233f6cf46e213de8a185
120+ https://github.com/purescript/package-sets/releases/download/psc-0.14.0-20210318/packages.dhall sha256:98bbacd65191cef354ecbafa1610be13e183ee130491ab9c0ef6e3d606f781b5
123
121
124let overrides =
122let overrides =
125 { css =
123 { css =
126 upstream.css
124 upstream.css
127 // { repo = "https://github.com/i-am-the-slime/purescript-css.git"
125 // { repo = "https://github.com/i-am-the-slime/purescript-css.git"
128− , version = "8ea0bab17c268d9c62a09892d7ba231dcbe6308b"
126+ , version = "39c9a9d4344e97e561eeac26eb2ce065c12bfcb1"
129− }
130− , react-testing-library =
131− upstream.react-testing-library
132− // { version = "main"
133 }
127 }
134 }
128 }
135
129
@@ -153,6 +147,8 @@ let additions =
153 }
147 }
154 , yoga-components = ../components/spago.dhall as Location
148 , yoga-components = ../components/spago.dhall as Location
155 , ry-blocks = ../../ry-blocks/spago.dhall as Location
149 , ry-blocks = ../../ry-blocks/spago.dhall as Location
150+ , react-testing-library =
151+ ../../purescript-react-testing-library/spago.dhall as Location
156 }
152 }
157
153
158in upstream // overrides // additions
154in upstream // overrides // additions
components/spago.dhall−2
@@ -18,10 +18,8 @@ You can edit this file as you like.
18 , "react-basic-dom"
18 , "react-basic-dom"
19 , "react-basic-hooks"
19 , "react-basic-hooks"
20 , "react-testing-library"
20 , "react-testing-library"
21− , "record-extra"
22 , "refs"
21 , "refs"
23 , "ry-blocks"
22 , "ry-blocks"
24− , "simple-json"
25 , "spec-discovery"
23 , "spec-discovery"
26 , "string-parsers"
24 , "string-parsers"
27 , "untagged-union"
25 , "untagged-union"
components/src/React/Basic/Hooks/Spring/Stories.purs+1−6
@@ -1,10 +1,7 @@
1module React.Basic.Hooks.Spring.Stories where
1module React.Basic.Hooks.Spring.Stories where
2
2
3import Prelude hiding (add)
3import Prelude hiding (add)
4−
5import CSS (backgroundColor, height, position, relative, vh, vw, width)
4import CSS (backgroundColor, height, position, relative, vh, vw, width)
6−import Data.Generic.Rep (class Generic)
7−import Data.Generic.Rep.Eq (genericEq)
8import Data.Int (pow)
5import Data.Int (pow)
9import Data.Time.Duration (Seconds(..), convertDuration)
6import Data.Time.Duration (Seconds(..), convertDuration)
10import Data.Tuple.Nested ((/\))
7import Data.Tuple.Nested ((/\))
@@ -143,9 +140,7 @@ data Countdown
143 | CountdownRunning Int
140 | CountdownRunning Int
144 | CountdownFinished
141 | CountdownFinished
145
142
146−derive instance genericCountdown ∷ Generic Countdown _
147−instance eqCountdown ∷ Eq Countdown where
143+derive instance eqCountdown ∷ Eq Countdown
148− eq = genericEq
149
144
150mkCountdown ∷ Effect (ReactComponent {})
145mkCountdown ∷ Effect (ReactComponent {})
151mkCountdown = do
146mkCountdown = do
components/src/Simple/JSON.jsnew file+7
@@ -0,0 +1,7 @@
1+exports._parseJSON = JSON.parse;
2+
3+exports._undefined = undefined;
4+
5+exports.unsafeStringify = function (x) {
6+ return JSON.stringify(x);
7+};
components/src/Simple/JSON.pursnew file+421
@@ -0,0 +1,421 @@
1+module Simple.JSON
2+ ( E
3+ , readJSON
4+ , readJSON'
5+ , readJSON_
6+ , writeJSON
7+ , write
8+ , read
9+ , read'
10+ , read_
11+ , parseJSON
12+ , undefined
13+ , class ReadForeign
14+ , readImpl
15+ , class ReadForeignFields
16+ , getFields
17+ , class ReadForeignVariant
18+ , readVariantImpl
19+ , class WriteForeign
20+ , writeImpl
21+ , class WriteForeignFields
22+ , writeImplFields
23+ , class WriteForeignVariant
24+ , writeVariantImpl
25+ ) where
26+
27+import Prelude
28+import Control.Alt ((<|>))
29+import Control.Monad.Except (ExceptT(..), except, runExcept, runExceptT, withExcept)
30+import Data.Array.NonEmpty (NonEmptyArray, fromArray, toArray)
31+import Data.Bifunctor (lmap)
32+import Data.Either (Either(..), hush, note)
33+import Data.Identity (Identity(..))
34+import Data.List.NonEmpty (singleton)
35+import Data.Maybe (Maybe(..), maybe)
36+import Data.Nullable (Nullable, toMaybe, toNullable)
37+import Data.Symbol (class IsSymbol, reflectSymbol)
38+import Data.Traversable (sequence, traverse)
39+import Data.TraversableWithIndex (traverseWithIndex)
40+import Data.Variant (Variant, inj, on)
41+import Effect.Exception (message, try)
42+import Effect.Uncurried as EU
43+import Effect.Unsafe (unsafePerformEffect)
44+import Foreign (F, Foreign, ForeignError(..), MultipleErrors, fail, isNull, isUndefined, readArray, readBoolean, readChar, readInt, readNull, readNumber, readString, tagOf, unsafeFromForeign, unsafeToForeign)
45+import Foreign.Index (readProp)
46+import Foreign.Object (Object)
47+import Foreign.Object as Object
48+import Partial.Unsafe (unsafeCrashWith)
49+import Prim.Row as Row
50+import Prim.RowList (class RowToList, Cons, Nil, RowList)
51+import Record (get)
52+import Record.Builder (Builder)
53+import Record.Builder as Builder
54+import Type.Prelude (Proxy(..))
55+
56+-- | An alias for the Either result of decoding
57+type E a =
58+ Either MultipleErrors a
59+
60+-- | Read a JSON string to a type `a` while returning a `MultipleErrors` if the
61+-- | parsing failed.
62+readJSON ∷
63+ ∀ a.
64+ ReadForeign a =>
65+ String ->
66+ E a
67+readJSON = runExcept <<< (readImpl <=< parseJSON)
68+
69+-- | Read a JSON string to a type `a` using `F a`. Useful with record types.
70+readJSON' ∷
71+ ∀ a.
72+ ReadForeign a =>
73+ String ->
74+ F a
75+readJSON' = readImpl <=< parseJSON
76+
77+-- | Read a JSON string to a type `a` while returning `Nothing` if the parsing
78+-- | failed.
79+readJSON_ ∷
80+ ∀ a.
81+ ReadForeign a =>
82+ String ->
83+ Maybe a
84+readJSON_ = hush <<< readJSON
85+
86+-- | Write a JSON string from a type `a`.
87+writeJSON ∷
88+ ∀ a.
89+ WriteForeign a =>
90+ a ->
91+ String
92+writeJSON = unsafeStringify <<< writeImpl
93+
94+write ∷
95+ ∀ a.
96+ WriteForeign a =>
97+ a ->
98+ Foreign
99+write = writeImpl
100+
101+-- | Read a Foreign value to a type
102+read ∷
103+ ∀ a.
104+ ReadForeign a =>
105+ Foreign ->
106+ E a
107+read = runExcept <<< readImpl
108+
109+-- | Read a value of any type as Foreign to a type
110+readAsForeign ∷
111+ ∀ a b.
112+ ReadForeign a =>
113+ b ->
114+ E a
115+readAsForeign = read <<< unsafeToForeign
116+
117+read' ∷
118+ ∀ a.
119+ ReadForeign a =>
120+ Foreign ->
121+ F a
122+read' = readImpl
123+
124+-- | Read a Foreign value to a type, as a Maybe of type
125+read_ ∷
126+ ∀ a.
127+ ReadForeign a =>
128+ Foreign ->
129+ Maybe a
130+read_ = hush <<< read
131+
132+foreign import _parseJSON ∷ EU.EffectFn1 String Foreign
133+
134+parseJSON ∷ String -> F Foreign
135+parseJSON =
136+ ExceptT
137+ <<< Identity
138+ <<< lmap (pure <<< ForeignError <<< message)
139+ <<< runPure
140+ <<< try
141+ <<< EU.runEffectFn1 _parseJSON
142+ where
143+ -- Nate Faubion: "It uses unsafePerformEffect because that’s the only way to catch exceptions and still use the builtin json decoder"
144+ runPure = unsafePerformEffect
145+
146+foreign import _undefined ∷ Foreign
147+
148+undefined ∷ Foreign
149+undefined = _undefined
150+
151+foreign import unsafeStringify ∷ ∀ a. a -> String
152+
153+-- | A class for reading foreign values to a type
154+class ReadForeign a where
155+ readImpl ∷ Foreign -> F a
156+
157+instance readForeign ∷ ReadForeign Foreign where
158+ readImpl = pure
159+
160+instance readChar ∷ ReadForeign Char where
161+ readImpl = readChar
162+
163+instance readNumber ∷ ReadForeign Number where
164+ readImpl = readNumber
165+
166+instance readInt ∷ ReadForeign Int where
167+ readImpl = readInt
168+
169+instance readString ∷ ReadForeign String where
170+ readImpl = readString
171+
172+instance readBoolean ∷ ReadForeign Boolean where
173+ readImpl = readBoolean
174+
175+instance readArray ∷ ReadForeign a => ReadForeign (Array a) where
176+ readImpl = traverseWithIndex readAtIdx <=< readArray
177+ where
178+ readAtIdx i f = withExcept (map (ErrorAtIndex i)) (readImpl f)
179+
180+instance readMaybe ∷ ReadForeign a => ReadForeign (Maybe a) where
181+ readImpl = readNullOrUndefined readImpl
182+ where
183+ readNullOrUndefined _ value
184+ | isNull value || isUndefined value = pure Nothing
185+
186+ readNullOrUndefined f value = Just <$> f value
187+
188+instance readNullable ∷ ReadForeign a => ReadForeign (Nullable a) where
189+ readImpl o =
190+ withExcept (map reformat)
191+ $ map toNullable
192+ <$> traverse readImpl
193+ =<< readNull o
194+ where
195+ reformat error = case error of
196+ TypeMismatch inner other -> TypeMismatch ("Nullable " <> inner) other
197+ _ -> error
198+
199+instance readObject ∷ ReadForeign a => ReadForeign (Object.Object a) where
200+ readImpl = sequence <<< Object.mapWithKey (const readImpl) <=< readObject'
201+ where
202+ readObject' ∷ Foreign -> F (Object Foreign)
203+ readObject' value
204+ | tagOf value == "Object" = pure $ unsafeFromForeign value
205+ | otherwise = fail $ TypeMismatch "Object" (tagOf value)
206+
207+instance readRecord ∷
208+ ( RowToList fields fieldList
209+ , ReadForeignFields fieldList () fields
210+ ) =>
211+ ReadForeign (Record fields) where
212+ readImpl o = flip Builder.build {} <$> getFields fieldListP o
213+ where
214+ fieldListP = Proxy ∷ Proxy fieldList
215+
216+-- | A class for reading foreign values from properties
217+class ReadForeignFields (xs ∷ RowList Type) (from ∷ Row Type) (to ∷ Row Type) | xs -> from to where
218+ getFields ∷
219+ Proxy xs ->
220+ Foreign ->
221+ F (Builder (Record from) (Record to))
222+
223+instance readFieldsCons ∷
224+ ( IsSymbol name
225+ , ReadForeign ty
226+ , ReadForeignFields tail from from'
227+ , Row.Lacks name from'
228+ , Row.Cons name ty from' to
229+ ) =>
230+ ReadForeignFields (Cons name ty tail) from to where
231+ getFields _ obj = (compose <$> first) `exceptTApply` rest
232+ where
233+ first = do
234+ value <- withExcept' (readImpl =<< readProp name obj)
235+ pure $ Builder.insert nameP value
236+
237+ rest = getFields tailP obj
238+
239+ nameP = Proxy ∷ Proxy name
240+
241+ tailP = Proxy ∷ Proxy tail
242+
243+ name = reflectSymbol nameP
244+
245+ withExcept' = withExcept <<< map $ ErrorAtProperty name
246+
247+exceptTApply ∷ ∀ a b e m. Semigroup e => Applicative m => ExceptT e m (a -> b) -> ExceptT e m a -> ExceptT e m b
248+exceptTApply fun a =
249+ ExceptT $ applyEither
250+ <$> runExceptT fun
251+ <*> runExceptT a
252+
253+applyEither ∷ ∀ e a b. Semigroup e => Either e (a -> b) -> Either e a -> Either e b
254+applyEither (Left e) (Right _) = Left e
255+
256+applyEither (Left e1) (Left e2) = Left (e1 <> e2)
257+
258+applyEither (Right _) (Left e) = Left e
259+
260+applyEither (Right fun) (Right a) = Right (fun a)
261+
262+instance readFieldsNil ∷
263+ ReadForeignFields Nil () () where
264+ getFields _ _ = pure identity
265+
266+instance readForeignVariant ∷
267+ ( RowToList variants rl
268+ , ReadForeignVariant rl variants
269+ ) =>
270+ ReadForeign (Variant variants) where
271+ readImpl o = readVariantImpl (Proxy ∷ Proxy rl) o
272+
273+class ReadForeignVariant (xs ∷ RowList Type) (row ∷ Row Type) | xs -> row where
274+ readVariantImpl ∷
275+ Proxy xs ->
276+ Foreign ->
277+ F (Variant row)
278+
279+instance readVariantNil ∷
280+ ReadForeignVariant Nil trash where
281+ readVariantImpl _ _ = fail $ ForeignError "Unable to match any variant member."
282+
283+instance readVariantCons ∷
284+ ( IsSymbol name
285+ , ReadForeign ty
286+ , Row.Cons name ty trash row
287+ , ReadForeignVariant tail row
288+ ) =>
289+ ReadForeignVariant (Cons name ty tail) row where
290+ readVariantImpl _ o =
291+ do
292+ obj ∷ { type ∷ String, value ∷ Foreign } <- readImpl o
293+ if obj.type == name then do
294+ value ∷ ty <- readImpl obj.value
295+ pure $ inj namep value
296+ else
297+ (fail <<< ForeignError $ "Did not match variant tag " <> name)
298+ <|> readVariantImpl (Proxy ∷ Proxy tail) o
299+ where
300+ namep = Proxy ∷ Proxy name
301+
302+ name = reflectSymbol namep
303+
304+-- -- | A class for writing a value into JSON
305+-- -- | need to do this intelligently using Foreign probably, because of null and undefined whatever
306+class WriteForeign a where
307+ writeImpl ∷ a -> Foreign
308+
309+instance writeForeignForeign ∷ WriteForeign Foreign where
310+ writeImpl = identity
311+
312+instance writeForeignString ∷ WriteForeign String where
313+ writeImpl = unsafeToForeign
314+
315+instance writeForeignInt ∷ WriteForeign Int where
316+ writeImpl = unsafeToForeign
317+
318+instance writeForeignChar ∷ WriteForeign Char where
319+ writeImpl = unsafeToForeign
320+
321+instance writeForeignNumber ∷ WriteForeign Number where
322+ writeImpl = unsafeToForeign
323+
324+instance writeForeignBoolean ∷ WriteForeign Boolean where
325+ writeImpl = unsafeToForeign
326+
327+instance writeForeignArray ∷ WriteForeign a => WriteForeign (Array a) where
328+ writeImpl xs = unsafeToForeign $ writeImpl <$> xs
329+
330+instance writeForeignMaybe ∷ WriteForeign a => WriteForeign (Maybe a) where
331+ writeImpl = maybe undefined writeImpl
332+
333+instance writeForeignNullable ∷ WriteForeign a => WriteForeign (Nullable a) where
334+ writeImpl = maybe (unsafeToForeign $ toNullable Nothing) writeImpl <<< toMaybe
335+
336+instance writeForeignObject ∷ WriteForeign a => WriteForeign (Object.Object a) where
337+ writeImpl = unsafeToForeign <<< Object.mapWithKey (const writeImpl)
338+
339+instance recordWriteForeign ∷
340+ ( RowToList row rl
341+ , WriteForeignFields rl row () to
342+ ) =>
343+ WriteForeign (Record row) where
344+ writeImpl rec = unsafeToForeign $ Builder.build steps {}
345+ where
346+ rlp = Proxy ∷ Proxy rl
347+
348+ steps = writeImplFields rlp rec
349+
350+class WriteForeignFields (rl ∷ RowList Type) row (from ∷ Row Type) (to ∷ Row Type) | rl -> row from to where
351+ writeImplFields ∷ ∀ g. g rl -> Record row -> Builder (Record from) (Record to)
352+
353+instance consWriteForeignFields ∷
354+ ( IsSymbol name
355+ , WriteForeign ty
356+ , WriteForeignFields tail row from from'
357+ , Row.Cons name ty whatever row
358+ , Row.Lacks name from'
359+ , Row.Cons name Foreign from' to
360+ ) =>
361+ WriteForeignFields (Cons name ty tail) row from to where
362+ writeImplFields _ rec = result
363+ where
364+ namep = Proxy ∷ Proxy name
365+
366+ value = writeImpl $ get namep rec
367+
368+ tailp = Proxy ∷ Proxy tail
369+
370+ rest = writeImplFields tailp rec
371+
372+ result = Builder.insert namep value <<< rest
373+
374+instance nilWriteForeignFields ∷
375+ WriteForeignFields Nil row () () where
376+ writeImplFields _ _ = identity
377+
378+instance writeForeignVariant ∷
379+ ( RowToList row rl
380+ , WriteForeignVariant rl row
381+ ) =>
382+ WriteForeign (Variant row) where
383+ writeImpl variant = writeVariantImpl (Proxy ∷ Proxy rl) variant
384+
385+class WriteForeignVariant (rl ∷ RowList Type) (row ∷ Row Type) | rl -> row where
386+ writeVariantImpl ∷ ∀ g. g rl -> Variant row -> Foreign
387+
388+instance nilWriteForeignVariant ∷
389+ WriteForeignVariant Nil () where
390+ -- a PureScript-defined variant cannot reach this path, but a JavaScript FFI one could.
391+ writeVariantImpl _ _ = unsafeCrashWith "Variant was not able to be writen row WriteForeign."
392+
393+instance consWriteForeignVariant ∷
394+ ( IsSymbol name
395+ , WriteForeign ty
396+ , Row.Cons name ty subRow row
397+ , WriteForeignVariant tail subRow
398+ ) =>
399+ WriteForeignVariant (Cons name ty tail) row where
400+ writeVariantImpl _ variant =
401+ on
402+ namep
403+ writeVariant
404+ (writeVariantImpl (Proxy ∷ Proxy tail))
405+ variant
406+ where
407+ namep = Proxy ∷ Proxy name
408+
409+ writeVariant value =
410+ unsafeToForeign
411+ { type: reflectSymbol namep
412+ , value: writeImpl value
413+ }
414+
415+instance readForeignNEArray ∷ ReadForeign a => ReadForeign (NonEmptyArray a) where
416+ readImpl f = do
417+ raw ∷ Array a <- readImpl f
418+ except $ note (singleton $ ForeignError "Nonempty array expected, got empty array") $ fromArray raw
419+
420+instance writeForeignNEArray ∷ WriteForeign a => WriteForeign (NonEmptyArray a) where
421+ writeImpl a = writeImpl <<< toArray $ a
components/src/Yoga/Centre/Component.purs+10−10
@@ -1,7 +1,7 @@
1module Yoga.Centre.Component where
1module Yoga.Centre.Component where
2
2
3import Prelude
3import Prelude
4−import Data.Array (foldMap)
4+import Data.Foldable (foldMap)
5import Data.Maybe (Maybe)
5import Data.Maybe (Maybe)
6import Effect (Effect)
6import Effect (Effect)
7import React.Basic (JSX)
7import React.Basic (JSX)
@@ -12,17 +12,17 @@ import Record.Extra (pick)
12import Yoga.Centre.Styles as Style
12import Yoga.Centre.Styles as Style
13import Yoga.Theme.Styles (makeStylesJSS)
13import Yoga.Theme.Styles (makeStylesJSS)
14
14
15−type Props
15+type Props =
16− = Record PropsR
16+ Record PropsR
17
17
18−type PropsR
18+type PropsR =
19− = OptionalProps Style.PropsR
19+ OptionalProps Style.PropsR
20
20
21−type OptionalProps r
21+type OptionalProps r =
22− = ( kids ∷ Array JSX
22+ ( kids ∷ Array JSX
23− , className ∷ Maybe String
23+ , className ∷ Maybe String
24− | r
24+ | r
25− )
25+ )
26
26
27makeComponent ∷ Effect (ReactComponent Props)
27makeComponent ∷ Effect (ReactComponent Props)
28makeComponent = do
28makeComponent = do
components/src/Yoga/Cluster/Component.purs+10−11
@@ -1,8 +1,7 @@
1module Yoga.Cluster.Component where
1module Yoga.Cluster.Component where
2
2
3import Prelude
3import Prelude
4−
5−import Data.Array (foldMap)
4+import Data.Foldable (foldMap)
6import Data.Maybe (Maybe)
5import Data.Maybe (Maybe)
7import Effect (Effect)
6import Effect (Effect)
8import React.Basic (JSX)
7import React.Basic (JSX)
@@ -13,17 +12,17 @@ import Record.Extra (pick)
13import Yoga.Cluster.Styles as Style
12import Yoga.Cluster.Styles as Style
14import Yoga.Theme.Styles (makeStylesJSS)
13import Yoga.Theme.Styles (makeStylesJSS)
15
14
16−type Props
15+type Props =
17− = Record PropsR
16+ Record PropsR
18
17
19−type PropsR
18+type PropsR =
20− = OptionalProps Style.PropsR
19+ OptionalProps Style.PropsR
21
20
22−type OptionalProps r
21+type OptionalProps r =
23− = ( kids ∷ Array JSX
22+ ( kids ∷ Array JSX
24− , className ∷ Maybe String
23+ , className ∷ Maybe String
25− | r
24+ | r
26− )
25+ )
27
26
28makeComponent ∷ Effect (ReactComponent Props)
27makeComponent ∷ Effect (ReactComponent Props)
29makeComponent = do
28makeComponent = do
components/src/Yoga/Cover/Component.purs+12−12
@@ -1,7 +1,7 @@
1module Yoga.Cover.Component where
1module Yoga.Cover.Component where
2
2
3import Prelude
3import Prelude
4−import Data.Array (foldMap)
4+import Data.Foldable (foldMap)
5import Data.Array as Array
5import Data.Array as Array
6import Data.Maybe (Maybe)
6import Data.Maybe (Maybe)
7import Effect (Effect)
7import Effect (Effect)
@@ -12,19 +12,19 @@ import React.Basic.Hooks as React
12import Yoga.Cover.Styles as Cover
12import Yoga.Cover.Styles as Cover
13import Yoga.Theme.Styles (makeStylesJSS)
13import Yoga.Theme.Styles (makeStylesJSS)
14
14
15−type Props
15+type Props =
16− = Record PropsR
16+ Record PropsR
17
17
18−type PropsR
18+type PropsR =
19− = OptionalProps ()
19+ OptionalProps ()
20
20
21−type OptionalProps r
21+type OptionalProps r =
22− = ( header ∷ Maybe JSX
22+ ( header ∷ Maybe JSX
23− , footer ∷ Maybe JSX
23+ , footer ∷ Maybe JSX
24− , kids ∷ Array JSX
24+ , kids ∷ Array JSX
25− , className ∷ Maybe String
25+ , className ∷ Maybe String
26− | r
26+ | r
27− )
27+ )
28
28
29makeComponent ∷ Effect (ReactComponent Props)
29makeComponent ∷ Effect (ReactComponent Props)
30makeComponent = do
30makeComponent = do
components/src/Yoga/DOM/Hook.purs−1
@@ -7,7 +7,6 @@ import Data.Nullable (Nullable)
7import Data.Nullable as Nullable
7import Data.Nullable as Nullable
8import Data.Traversable (for_)
8import Data.Traversable (for_)
9import Data.Tuple.Nested (type (/\))
9import Data.Tuple.Nested (type (/\))
10−import Debug.Trace (spy, traceM)
11import React.Basic (Ref)
10import React.Basic (Ref)
12import React.Basic.Hooks (Hook, UseLayoutEffect, UseRef, UseState, coerceHook, readRefMaybe, useLayoutEffect, useRef, useState, (/\))
11import React.Basic.Hooks (Hook, UseLayoutEffect, UseRef, UseState, coerceHook, readRefMaybe, useLayoutEffect, useRef, useState, (/\))
13import React.Basic.Hooks as React
12import React.Basic.Hooks as React
components/src/Yoga/Imposter/Component.purs+12−12
@@ -1,7 +1,7 @@
1module Yoga.Imposter.Component where
1module Yoga.Imposter.Component where
2
2
3import Prelude
3import Prelude
4−import Data.Array (foldMap)
4+import Data.Foldable (foldMap)
5import Data.Maybe (Maybe)
5import Data.Maybe (Maybe)
6import Effect (Effect)
6import Effect (Effect)
7import React.Basic (JSX)
7import React.Basic (JSX)
@@ -16,19 +16,19 @@ import Yoga.Helpers (ifJustFalse, (?||))
16import Yoga.Imposter.Styles as Style
16import Yoga.Imposter.Styles as Style
17import Yoga.Theme.Styles (makeStylesJSS)
17import Yoga.Theme.Styles (makeStylesJSS)
18
18
19−type Props
19+type Props =
20− = Record PropsR
20+ Record PropsR
21
21
22−type PropsR
22+type PropsR =
23− = OptionalProps Style.PropsR
23+ OptionalProps Style.PropsR
24
24
25−type OptionalProps r
25+type OptionalProps r =
26− = ( kids ∷ Array JSX
26+ ( kids ∷ Array JSX
27− , className ∷ Maybe String
27+ , className ∷ Maybe String
28− , onClick ∷ Maybe EventHandler
28+ , onClick ∷ Maybe EventHandler
29− , style ∷ Maybe CSS
29+ , style ∷ Maybe CSS
30− | r
30+ | r
31− )
31+ )
32
32
33makeComponent ∷ Effect (ReactComponent Props)
33makeComponent ∷ Effect (ReactComponent Props)
34makeComponent = do
34makeComponent = do
components/src/Yoga/JSS.purs+38−38
@@ -33,19 +33,19 @@ jssClasses ∷
33 ({ | theme } -> { | row }) -> JSSClasses theme props to
33 ({ | theme } -> { | row }) -> JSSClasses theme props to
34jssClasses f = JSSClasses f'
34jssClasses f = JSSClasses f'
35 where
35 where
36− f' theme = built
36+ f' theme = built
37− where
37+ where
38− rec = f theme
38+ rec = f theme
39
39
40− built ∷ Record to
40+ built ∷ Record to
41− built = Builder.build builder {}
41+ built = Builder.build builder {}
42
42
43− rlp = RL.RLProxy ∷ RL.RLProxy rowRL
43+ rlp = RL.RLProxy ∷ RL.RLProxy rowRL
44
44
45− propsy = Proxy ∷ Proxy props
45+ propsy = Proxy ∷ Proxy props
46
46
47− builder ∷ Builder.Builder (Record ()) (Record to)
47+ builder ∷ Builder.Builder (Record ()) (Record to)
48− builder = jssifyFields propsy rlp rec
48+ builder = jssifyFields propsy rlp rec
49
49
50data JSSElem props
50data JSSElem props
51 = PrimitiveJss (String |+| Int |+| Number)
51 = PrimitiveJss (String |+| Int |+| Number)
@@ -93,7 +93,7 @@ instance jssAbleColor ∷ JSSAble p Color where
93instance jssAbleBackgroundImage ∷ JSSAble p BackgroundImage where
93instance jssAbleBackgroundImage ∷ JSSAble p BackgroundImage where
94 jss v = PrimitiveJss (cast (render (value v)))
94 jss v = PrimitiveJss (cast (render (value v)))
95 where
95 where
96− render (Value val) = plain val
96+ render (Value val) = plain val
97
97
98instance jssAbleString ∷ JSSAble p String where
98instance jssAbleString ∷ JSSAble p String where
99 jss = cast >>> PrimitiveJss
99 jss = cast >>> PrimitiveJss
@@ -116,20 +116,20 @@ instance jssAbleNested ∷ JSSAble p jss => JSSAble p (Object jss) where
116instance jssAbleCss ∷ JSSAble p (StyleM Unit) where
116instance jssAbleCss ∷ JSSAble p (StyleM Unit) where
117 jss someCss = NestedJss (foldMap ruleToObject rules)
117 jss someCss = NestedJss (foldMap ruleToObject rules)
118 where
118 where
119− rules = runS someCss
119+ rules = runS someCss
120−
120+
121− ruleToObject = case _ of
121+ ruleToObject = case _ of
122− Property (Key k) (Value v) -> Object.singleton (plain k) (jss (plain v))
122+ Property (Key k) (Value v) -> Object.singleton (plain k) (jss (plain v))
123− Nested (Sub (Selector (Refinement preds) (Elem el))) rules -> Object.singleton (el <> foldMap predicate preds) (jss (foldMap ruleToObject rules))
123+ Nested (Sub (Selector (Refinement preds) (Elem el))) rules -> Object.singleton (el <> foldMap predicate preds) (jss (foldMap ruleToObject rules))
124− Keyframe (Keyframes name frames) ->
124+ Keyframe (Keyframes name frames) ->
125− frames
125+ frames
126− # foldMap \(Tuple pos rules) ->
126+ # foldMap \(Tuple pos rules) ->
127− Object.singleton
127+ Object.singleton
128− (show (round pos) <> "%")
128+ (show (round pos) <> "%")
129− (NestedJss (foldMap ruleToObject rules))
129+ (NestedJss (foldMap ruleToObject rules))
130− x ->
130+ x ->
131− unsafeCrashWith do
131+ unsafeCrashWith do
132− "tried to create CSS that I couldn't understand"
132+ "tried to create CSS that I couldn't understand"
133
133
134instance jssAbleRecord ∷
134instance jssAbleRecord ∷
135 ( JSSAbleFields props rowRL row () to
135 ( JSSAbleFields props rowRL row () to
@@ -139,20 +139,20 @@ instance jssAbleRecord ∷
139 JSSAble props (Record row) where
139 JSSAble props (Record row) where
140 jss rec = NestedJss <<< Object.fromHomogeneous $ built
140 jss rec = NestedJss <<< Object.fromHomogeneous $ built
141 where
141 where
142− built ∷ Record to
142+ built ∷ Record to
143− built = Builder.build builder {}
143+ built = Builder.build builder {}
144
144
145− rlp = RL.RLProxy ∷ RL.RLProxy rowRL
145+ rlp = RL.RLProxy ∷ RL.RLProxy rowRL
146
146
147− propsy = Proxy ∷ Proxy props
147+ propsy = Proxy ∷ Proxy props
148
148
149− builder ∷ Builder.Builder (Record ()) (Record to)
149+ builder ∷ Builder.Builder (Record ()) (Record to)
150− builder = jssifyFields propsy rlp rec
150+ builder = jssifyFields propsy rlp rec
151
151
152propsJss ∷ ∀ p a. JSSAble p a => (p -> a) -> JSSElem p
152propsJss ∷ ∀ p a. JSSAble p a => (p -> a) -> JSSElem p
153propsJss fn = PropsJss (map jss fn)
153propsJss fn = PropsJss (map jss fn)
154
154
155−class JSSAbleFields props (xs ∷ RowList) (row ∷ #Type) (from ∷ #Type) (to ∷ #Type) | xs -> props row from to where
155+class JSSAbleFields props (xs ∷ RowList Type) (row ∷ #Type) (from ∷ #Type) (to ∷ #Type) | xs -> props row from to where
156 jssifyFields ∷ Proxy props -> RLProxy xs -> Record row -> Builder (Record from) (Record to)
156 jssifyFields ∷ Proxy props -> RLProxy xs -> Record row -> Builder (Record from) (Record to)
157
157
158instance jssAbleFieldsNil ∷ JSSAbleFields props Nil row () () where
158instance jssAbleFieldsNil ∷ JSSAbleFields props Nil row () () where
@@ -169,16 +169,16 @@ instance jssAbleFieldsCons ∷
169 JSSAbleFields props (RL.Cons name a tail) row from to where
169 JSSAbleFields props (RL.Cons name a tail) row from to where
170 jssifyFields _ _ r = first <<< rest
170 jssifyFields _ _ r = first <<< rest
171 where
171 where
172− first = Builder.insert nameP (jss val)
172+ first = Builder.insert nameP (jss val)
173
173
174− val = Record.get nameP r
174+ val = Record.get nameP r
175
175
176− rest = jssifyFields propsP tailP r
176+ rest = jssifyFields propsP tailP r
177
177
178− nameP = SProxy ∷ SProxy name
178+ nameP = SProxy ∷ SProxy name
179
179
180− tailP = RL.RLProxy ∷ RL.RLProxy tail
180+ tailP = RL.RLProxy ∷ RL.RLProxy tail
181
181
182− propsP = Proxy ∷ Proxy props
182+ propsP = Proxy ∷ Proxy props
183
183
184− name = reflectSymbol nameP
184+ name = reflectSymbol nameP
components/src/Yoga/SVG/Image.purs+6−6
@@ -17,7 +17,7 @@ import React.Basic.DOM.SVG as SVG
17import React.Basic.Emotion as E
17import React.Basic.Emotion as E
18import React.Basic.Hooks (ReactComponent)
18import React.Basic.Hooks (ReactComponent)
19import React.Basic.Hooks as React
19import React.Basic.Hooks as React
20−import Yoga.Block.Container.Style (colour)
20+import Yoga.Block.Container.Style (DarkOrLightMode(..), colour)
21import Yoga.DOM.Hook (useBoundingBox)
21import Yoga.DOM.Hook (useBoundingBox)
22import Yoga.SVG.Icon (Raw)
22import Yoga.SVG.Icon (Raw)
23import Yoga.Scroll.Hook (useScrollYPosition)
23import Yoga.Scroll.Hook (useScrollYPosition)
@@ -67,7 +67,7 @@ rotateStars =
67mkClasses theme =
67mkClasses theme =
68 { laptopBackground:
68 { laptopBackground:
69 E.css
69 E.css
70− { fill: E.str colour.background
70+ { fill: E.var colour.background
71 }
71 }
72 , lightEllipsis:
72 , lightEllipsis:
73 E.css
73 E.css
@@ -82,7 +82,7 @@ mkClasses theme =
82 }
82 }
83 , screenText:
83 , screenText:
84 E.css
84 E.css
85− { fontFamily: E.var "--font-mono"
85+ { fontFamily: E.var "--mono-font"
86 , fontSize: E.str "0.85em"
86 , fontSize: E.str "0.85em"
87 , fill: E.str colour.text
87 , fill: E.str colour.text
88 }
88 }
@@ -134,10 +134,10 @@ mkClasses theme =
134 }
134 }
135 }
135 }
136
136
137−mkLandingPageBackground ∷ Effect (ReactComponent { className ∷ String })
137+mkLandingPageBackground ∷ Effect (ReactComponent { className ∷ String, themeVariant ∷ DarkOrLightMode })
138mkLandingPageBackground = do
138mkLandingPageBackground = do
139− React.reactComponent "LandingPageBackground" \{ className } -> React.do
139+ React.reactComponent "LandingPageBackground" \{ className, themeVariant } -> React.do
140− let theme = { isLight: true } -- [TODO]
140+ let theme = { isLight: themeVariant == LightMode }
141 let classes = mkClasses theme
141 let classes = mkClasses theme
142 scrollY <- useScrollYPosition
142 scrollY <- useScrollYPosition
143 bb /\ ref <- useBoundingBox
143 bb /\ ref <- useBoundingBox
components/src/Yoga/Switcher/Component.purs+10−10
@@ -1,7 +1,7 @@
1module Yoga.Switcher.Component where
1module Yoga.Switcher.Component where
2
2
3import Prelude
3import Prelude
4−import Data.Array (foldMap)
4+import Data.Foldable (foldMap)
5import Data.Maybe (Maybe)
5import Data.Maybe (Maybe)
6import Effect (Effect)
6import Effect (Effect)
7import React.Basic (JSX)
7import React.Basic (JSX)
@@ -12,17 +12,17 @@ import Record.Extra (pick)
12import Yoga.Switcher.Styles as Style
12import Yoga.Switcher.Styles as Style
13import Yoga.Theme.Styles (makeStylesJSS)
13import Yoga.Theme.Styles (makeStylesJSS)
14
14
15−type Props
15+type Props =
16− = Record PropsR
16+ Record PropsR
17
17
18−type PropsR
18+type PropsR =
19− = OptionalProps Style.PropsR
19+ OptionalProps Style.PropsR
20
20
21−type OptionalProps r
21+type OptionalProps r =
22− = ( kids ∷ Array JSX
22+ ( kids ∷ Array JSX
23− , className ∷ Maybe String
23+ , className ∷ Maybe String
24− | r
24+ | r
25− )
25+ )
26
26
27makeComponent ∷ Effect (ReactComponent Props)
27makeComponent ∷ Effect (ReactComponent Props)
28makeComponent = do
28makeComponent = do
components/src/Yoga/WithSidebar/Component.purs+15−15
@@ -1,7 +1,7 @@
1module Yoga.WithSidebar.Component where
1module Yoga.WithSidebar.Component where
2
2
3import Prelude
3import Prelude
4−import Data.Array (foldMap)
4+import Data.Foldable (foldMap)
5import Data.Array as A
5import Data.Array as A
6import Data.Maybe (Maybe(..))
6import Data.Maybe (Maybe(..))
7import Effect (Effect)
7import Effect (Effect)
@@ -12,23 +12,23 @@ import React.Basic.Hooks as React
12import Yoga.Theme.Styles (makeStylesJSS)
12import Yoga.Theme.Styles (makeStylesJSS)
13import Yoga.WithSidebar.Styles as WithSidebar
13import Yoga.WithSidebar.Styles as WithSidebar
14
14
15−type Props
15+type Props =
16− = Record PropsR
16+ Record PropsR
17
17
18−type PropsR
18+type PropsR =
19− = OptionalProps
19+ OptionalProps
20− ( sidebarChildren ∷ Array JSX
20+ ( sidebarChildren ∷ Array JSX
21− , notSidebarChildren ∷ Array JSX
21+ , notSidebarChildren ∷ Array JSX
22− )
23−
24−type OptionalProps r
25− = ( className ∷ Maybe String
26− , sidebarClassName ∷ Maybe String
27− , notSidebarClassName ∷ Maybe String
28− , sidebarRight ∷ Maybe Boolean
29− | r
30 )
22 )
31
23
24+type OptionalProps r =
25+ ( className ∷ Maybe String
26+ , sidebarClassName ∷ Maybe String
27+ , notSidebarClassName ∷ Maybe String
28+ , sidebarRight ∷ Maybe Boolean
29+ | r
30+ )
31+
32makeComponent ∷ Effect (ReactComponent Props)
32makeComponent ∷ Effect (ReactComponent Props)
33makeComponent = do
33makeComponent = do
34 useStyles <- makeStylesJSS WithSidebar.styles
34 useStyles <- makeStylesJSS WithSidebar.styles