git.iko.soy/rowtype-yoga/ry-blocks
on main help sign in
Refactor Motion
commita5712170041e76ca55040409c115ec0f80bdd9b7 authorMark Eibes <mark.eibes@gmail.com> dateMon 4 Jan 2021, 10:27 (6 years ago) parent5d0b781
46 files changed+1771−1357
src/Framer/Motion.js−14 src/Framer/Motion.purs+8−547 src/Framer/Motion/MotionComponent.js+14 src/Framer/Motion/MotionComponent.purs+521 src/Framer/Motion/Types.js+4 src/Framer/Motion/Types.purs+290 src/Yoga/Block.purs+12 src/Yoga/Block/Atom/Button.purs+5 src/Yoga/Block/Atom/Button/Style.purs+1−1 src/Yoga/Block/Atom/CodeInput/Style.purs+6−2 src/Yoga/Block/Atom/Icon/Story.purs+2 src/Yoga/Block/Atom/Icon/Style.purs+3−5 src/Yoga/Block/Atom/Input/Types.purs+4−3 src/Yoga/Block/Atom/Input/View.purs+30−40 src/Yoga/Block/Atom/Input/View/Container.purs+47−42 src/Yoga/Block/Atom/Input/View/HTMLInput.purs+40 src/Yoga/Block/Atom/Input/View/Label.purs+30−25 src/Yoga/Block/Atom/Range/Style.purs+2−2 src/Yoga/Block/Atom/Segmented/Style.purs+9−9 src/Yoga/Block/Atom/Segmented/View.purs+15−15 src/Yoga/Block/Atom/Segmented/View/ActiveIndicator.purs+57−76 src/Yoga/Block/Atom/Toggle.purs+1−1 src/Yoga/Block/Atom/Toggle/Story.purs+4−7 src/Yoga/Block/Atom/Toggle/Style.purs+24−25 src/Yoga/Block/Atom/Toggle/View.purs+75−47 src/Yoga/Block/Atom/Tooltip/Style.purs+1−1 src/Yoga/Block/Atom/Tooltip/View.purs+11−3 src/Yoga/Block/Container/Story.purs+33−2 src/Yoga/Block/Container/Style.purs+258−258 src/Yoga/Block/Container/View.purs+2−2 src/Yoga/Block/Icon/SVG/Icon.purs+4 src/Yoga/Block/Icon/SVG/Moon.purs+21 src/Yoga/Block/Icon/SVG/Off.purs+3−8 src/Yoga/Block/Icon/SVG/On.purs+4−21 src/Yoga/Block/Icon/SVG/Sun.purs+27 src/Yoga/Block/Icon/SVG/moon.afdesign src/Yoga/Block/Icon/SVG/moon.svg+1 src/Yoga/Block/Icon/SVG/sun.svg+1 src/Yoga/Block/Layout/Box/Style.purs+1 src/Yoga/Block/Layout/Centre/Style.purs+1−1 src/Yoga/Block/Layout/Sidebar/Story.purs+8−16 src/Yoga/Block/Layout/Sidebar/View.purs+1 src/Yoga/Block/Layout/Stack/Style.purs+1−1 src/Yoga/Block/Layout/Stack/View.purs+4 src/Yoga/Block/Modal/View.purs+9−9 src/Yoga/Block/Motion/Story.purs+176−174
src/Framer/Motion.js−14
@@ -1,19 +1,5 @@
11const framerMotion = require("framer-motion")
22
3−exports.divImpl = framerMotion.motion.div
4−exports.spanImpl = framerMotion.motion.span
5−exports.buttonImpl = framerMotion.motion.button
6−exports.h1Impl = framerMotion.motion.h1
7−exports.svgImpl = framerMotion.motion.svg
8−exports.pathImpl = framerMotion.motion.path
9−exports.rectImpl = framerMotion.motion.rect
10−
11−exports.infinity = Infinity
12−
13−exports.custom = (component) => () => {
14− return framerMotion.motion.custom(component)
15−}
16−
173exports.animatePresence = () => framerMotion.AnimatePresence
184
195exports.animateSharedLayout = () => framerMotion.AnimateSharedLayout
src/Framer/Motion.purs+8−547
@@ -1,393 +1,19 @@
11module Framer.Motion
2− ( animate
3− , makeVariantLabels
4− , WhileTap
5− , whileTap
6− , callback
7− , class EffectFnMaker
8− , toEffectFn
9− , OnHoverStart
10− , span
11− , onHoverStart
12− , LayoutId
13− , layoutId
14− , customProp
15− , OnHoverEnd
16− , onHoverEnd
17− , whileHover
18− , WhileHover
19− , EventInfo
20− , OnTap
21− , TapInfo
22− , OnTapStart
23− , OnTapEnd
24− , onTapStart
25− , onTapEnd
26− , onTapCancel
27− , onTap
28− , OnTapCancel
29− , TargetAndTransition
30− , MakeVariantLabel
31− , div
32− , h1
33− , variantsFromObject
34− , custom
35− , Exit
36− , exit
37− , MotionProps
38− , initial
39− , MotionPropsF
40− , prop
41− , Drag
42− , DragMomentum
43− , button
44− , dragMomentum
45− , DragPropagation
46− , DragElastic
47− , dragElastic
48− , dragPropagation
49− , drag
50− , Transition
51− , transition
52− , Initial
53− , BoundingBox2D
54− , boundingBox2D
55− , dragConstraints
56− , (>>)
57− , variants
58− , Animate
59− , Infinity
60− , infinity
61− , VariantLabel
62− , Variants
63− , layout
64− , Layout
65− , AnimationControls
2+ ( motion
663 , withMotion
67− , motion
68− , animateSharedLayout
69− , AnimateSharedLayoutProps
70− , AnimateSharedLayoutType
71− , OnDragEnd
72− , onDragEnd
73− , OnDragStart
74− , onDragStart
75− , OnDrag
76− , onDrag
77− , PanInfo
78− , Point2D
79− , switch
80− , crossfade
81− , AnimatePresenceProps
82− , DragConstraints
834 , animatePresence
84− , svg
85− , path
86− , rect
5+ , animateSharedLayout
6+ , module Framer.Motion.Types
7+ , module Framer.Motion.MotionComponent
878 ) where
889
89−import Prelude
90−import Data.Nullable (Nullable)
91−import Data.Symbol (class IsSymbol, SProxy, reflectSymbol)
92−import Effect (Effect)
93−import Effect.Uncurried (EffectFn1, EffectFn2, mkEffectFn1, mkEffectFn2)
94−import Foreign (Foreign, unsafeToForeign)
95−import Foreign.Object (Object)
96−import Heterogeneous.Mapping (class HMapWithIndex, class MappingWithIndex, hmapWithIndex)
97−import Literals.Undefined (Undefined)
10+import Prelude hiding (div, map, sub)
11+import Framer.Motion.Types (class EffectFnMaker, Animate, AnimatePresenceProps, AnimateSharedLayoutProps, AnimateSharedLayoutType(..), AnimationControls, BoundingBox2D, Drag, DragConstraints, DragElastic, DragMomentum, DragPropagation, EventInfo, Exit, Infinity, Initial, Layout, LayoutId, LayoutTransition, MakeVariantLabel(..), MotionProps, MotionPropsF, OnDrag, OnDragEnd, OnDragStart, OnHoverEnd, OnHoverStart, OnTap, OnTapCancel, OnTapEnd, OnTapStart, PanInfo, Point2D, TapInfo, Target(..), TargetAndTransition, Transition, VariantLabel(..), Variants, WhileHover, WhileTap, animate, boundingBox2D, callback, crossfade, customProp, drag, dragConstraints, dragElastic, dragMomentum, dragPropagation, exit, infinity, initial, layout, layoutId, makeVariantLabels, onDrag, onDragEnd, onDragStart, onHoverEnd, onHoverStart, onTap, onTapCancel, onTapEnd, onTapStart, prop, switch, toEffectFn, transition, variants, variantsFromObject, whileHover, whileTap)
9812import Prim.Row (class Nub, class Union)
99−import React.Basic (JSX, ReactComponent)
100−import React.Basic.DOM (CSS, Props_button, Props_div, Props_h1, Props_span, css)
101−import React.Basic.DOM.Internal (SharedSVGProps)
102−import React.Basic.DOM.SVG (Props_svg, Props_rect, Props_path)
103−import React.Basic.Events (EventHandler)
104−import React.Basic.Hooks (Ref)
13+import React.Basic (ReactComponent)
10514import Record (disjointUnion)
106−import Type.Row (type (+))
107−import Unsafe.Coerce (unsafeCoerce)
10815import Untagged.Castable (class Castable, cast)
109−import Untagged.Union (type (|+|))
110−import Web.DOM (Node)
111−import Web.Event.Internal.Types (Event)
112−import Web.UIEvent.MouseEvent (MouseEvent)
113−import Yoga.Block.Internal (Id)
114−
115−foreign import divImpl ∷ ∀ a. ReactComponent { | a }
116−
117−foreign import spanImpl ∷ ∀ a. ReactComponent { | a }
118−
119−foreign import buttonImpl ∷ ∀ a. ReactComponent { | a }
120−
121−foreign import h1Impl ∷ ∀ a. ReactComponent { | a }
122−
123−foreign import svgImpl ∷ ∀ a. ReactComponent { | a }
124−
125−foreign import pathImpl ∷ ∀ a. ReactComponent { | a }
126−
127−foreign import rectImpl ∷ ∀ a. ReactComponent { | a }
128−
129−type Transition =
130− CSS |+| Undefined
131−
132−newtype VariantLabel = VariantLabel String
133−
134−data Target
135− = Target
136−
137−type Exit =
138− CSS |+| VariantLabel |+| Array VariantLabel |+| Undefined
139−
140−foreign import data AnimationControls ∷ Type
141−
142−prop ∷ ∀ a b. Castable a b => a -> b
143−prop = cast
144−
145−type Animate =
146− CSS
147− |+| VariantLabel
148− |+| Array VariantLabel
149− |+| AnimationControls
150− |+| Undefined
151−
152−type Initial =
153− Boolean |+| CSS |+| VariantLabel |+| Array VariantLabel |+| Undefined
154−
155−type Layout =
156− Boolean |+| Undefined
157−
158−type Variants =
159− CSS |+| Undefined
160−
161−type LayoutTransition =
162− Boolean |+| Undefined
163−
164−type Drag =
165− Boolean |+| String |+| Undefined
166−
167−type DragMomentum =
168− Boolean |+| Undefined
169−
170−dragMomentum ∷ ∀ c. Castable c DragMomentum => c -> DragMomentum
171−dragMomentum = cast
172−
173−type DragConstraints =
174− Ref (Nullable Node) |+| BoundingBox2D |+| Undefined
175−
176−type DragElastic =
177− Boolean |+| Number |+| Undefined
178−
179−dragElastic ∷ ∀ c. Castable c DragElastic => c -> DragElastic
180−dragElastic = cast
181−
182−type BoundingBox2D =
183− { left ∷ Int |+| Number |+| Undefined
184− , right ∷ Int |+| Number |+| Undefined
185− , top ∷ Int |+| Number |+| Undefined
186− , bottom ∷ Int |+| Number |+| Undefined
187− }
188−
189−boundingBox2D ∷ ∀ c. Castable c BoundingBox2D => c -> BoundingBox2D
190−boundingBox2D = cast
191−
192−type Point2D =
193− { x ∷ Number, y ∷ Number }
194−
195−type PanInfo =
196− { point ∷ Point2D, delta ∷ Point2D, offset ∷ Point2D, velocity ∷ Point2D }
197−
198−type OnDragStart =
199− (EffectFn2 Event PanInfo Unit |+| Undefined)
200−
201−type OnDragEnd =
202− (EffectFn2 Event PanInfo Unit |+| Undefined)
203−
204−type OnDrag =
205− (EffectFn2 Event PanInfo Unit |+| Undefined)
206−
207−type WhileTap =
208− TargetAndTransition |+| String |+| Undefined
209−
210−type OnTap =
211− (EffectFn2 Event TapInfo Unit |+| Undefined)
212−
213−type OnTapStart =
214− (EffectFn2 Event TapInfo Unit |+| Undefined)
215−
216−type OnTapEnd =
217− (EffectFn2 Event TapInfo Unit |+| Undefined)
218−
219−type OnTapCancel =
220− (EffectFn2 Event TapInfo Unit |+| Undefined)
221−
222−onTapStart ∷ (Event -> TapInfo -> Effect Unit) -> OnTapStart
223−onTapStart = cast <<< toEffectFn
224−
225−onTapEnd ∷ (Event -> TapInfo -> Effect Unit) -> OnTapEnd
226−onTapEnd = cast <<< toEffectFn
227−
228−onTap ∷ (Event -> TapInfo -> Effect Unit) -> OnTap
229−onTap fn2 = cast (mkEffectFn2 fn2)
230−
231−onTapCancel ∷ (Event -> TapInfo -> Effect Unit) -> OnTap
232−onTapCancel fn2 = cast (mkEffectFn2 fn2)
233−
234−type EventInfo =
235− { point ∷ { x ∷ Number, y ∷ Number }
236− }
237−
238−type WhileHover =
239− (EffectFn2 MouseEvent EventInfo Unit |+| Undefined)
240−
241−type OnHoverEnd =
242− (EffectFn2 MouseEvent EventInfo Unit |+| Undefined)
243−
244−type OnHoverStart =
245− (EffectFn2 MouseEvent EventInfo Unit |+| Undefined)
246−
247−onHoverStart ∷ (MouseEvent -> EventInfo -> Effect Unit) -> OnHoverStart
248−onHoverStart = cast <<< toEffectFn
249−
250−onHoverEnd ∷ (MouseEvent -> EventInfo -> Effect Unit) -> OnHoverEnd
251−onHoverEnd = cast <<< toEffectFn
252−
253−whileHover ∷ ∀ c. Castable c WhileHover => c -> WhileHover
254−whileHover = cast
255−
256−type TapInfo =
257− { x ∷ Number, y ∷ Number }
258−
259−-- Can contain "transition" and "transitionEnd"
260−type TargetAndTransition =
261− CSS
262−
263−type DragPropagation =
264− Boolean |+| Undefined
265−
266−whileTap ∷ ∀ c. Castable c WhileTap => c -> WhileTap
267−whileTap = cast
268−
269−class EffectFnMaker fn effectFn | fn -> effectFn where
270− toEffectFn ∷ fn -> effectFn
271−
272−instance callbackableEffectFn2 ∷ EffectFnMaker (a -> b -> Effect c) (EffectFn2 a b c) where
273− toEffectFn = mkEffectFn2
274−
275−instance callbackableEffectFn1 ∷ EffectFnMaker (a -> Effect b) (EffectFn1 a b) where
276− toEffectFn = mkEffectFn1
277−
278−callback ∷ ∀ a c f. Castable c a => EffectFnMaker f c => f -> a
279−callback = cast <<< toEffectFn
280−
281−onDragStart ∷ (Event -> PanInfo -> Effect Unit) -> OnDragStart
282−onDragStart = cast <<< toEffectFn
283−
284−onDragEnd ∷ (Event -> PanInfo -> Effect Unit) -> OnDragEnd
285−onDragEnd = cast <<< toEffectFn
286−
287−onDrag ∷ (Event -> PanInfo -> Effect Unit) -> OnDrag
288−onDrag fn2 = cast (mkEffectFn2 fn2)
289−
290−customProp ∷ ∀ a. a -> Foreign
291−customProp = unsafeToForeign
292−
293−type LayoutId =
294− String |+| Undefined
295−
296−layoutId ∷ ∀ a. Castable a LayoutId => a -> LayoutId
297−layoutId = cast
298−
299−type MotionPropsF f r =
300− ( initial ∷ f Initial
301− , animate ∷ f Animate
302− , custom ∷ f Foreign
303− , drag ∷ f Drag
304− , dragMomentum ∷ f DragMomentum
305− , dragElastic ∷ f DragElastic
306− , onDragStart ∷ f OnDragStart
307− , onDrag ∷ f OnDrag
308− , onDragEnd ∷ f OnDragEnd
309− , dragConstraints ∷ f DragConstraints
310− , dragPropagation ∷ f DragPropagation
311− , variants ∷ f Variants
312− , transition ∷ f Transition
313− , layout ∷ f Layout
314− , layoutId ∷ f LayoutId
315− , whileTap ∷ f WhileTap
316− , onTap ∷ f OnTap
317− , onTapStart ∷ f OnTapStart
318− , onTapEnd ∷ f OnTapEnd
319− , onTapCancel ∷ f OnTapCancel
320− , whileHover ∷ f WhileHover
321− , onHoverStart ∷ f OnHoverStart
322− , onHoverEnd ∷ f OnHoverEnd
323− , exit ∷ f Exit
324− | r
325− )
326−
327−type MotionProps r =
328− MotionPropsF Id r
329−
330−animate ∷ ∀ a. Castable a Animate => a -> Animate
331−animate = cast
332−
333−initial ∷ ∀ a. Castable a Initial => a -> Initial
334−initial = cast
335−
336−transition ∷ ∀ r. { | r } -> Transition
337−transition = cast <<< css
338−
339−drag ∷ ∀ a. Castable a Drag => a -> Drag
340−drag = cast
341−
342−dragConstraints ∷ ∀ a. Castable a BoundingBox2D => a -> DragConstraints
343−dragConstraints x = cast ((cast x) ∷ BoundingBox2D)
344−
345−dragPropagation ∷ ∀ a. Castable a DragPropagation => a -> DragPropagation
346−dragPropagation = cast
347−
348−exit ∷ ∀ a. Castable a Exit => a -> Exit
349−exit = cast
350−
351−variants ∷ ∀ r. { | r } -> Variants
352−variants = cast <<< css
353−
354−variantsFromObject ∷ ∀ o. Object o -> Variants
355−variantsFromObject = cast <<< (unsafeCoerce ∷ _ -> CSS)
356−
357−layout ∷ ∀ a. Castable a Layout => a -> Layout
358−layout = cast
359−
360−data MakeVariantLabel
361− = MakeVariantLabel
362−
363−instance makeVariantLabels' ∷
364− (IsSymbol sym) =>
365− MappingWithIndex MakeVariantLabel (SProxy sym) a VariantLabel where
366− mappingWithIndex MakeVariantLabel prop' _ = VariantLabel (reflectSymbol prop')
367−
368−makeVariantLabels ∷ ∀ a b. HMapWithIndex MakeVariantLabel a b => a -> b
369−makeVariantLabels = hmapWithIndex MakeVariantLabel
370−
371−div ∷ ∀ attrs attrs_. Union attrs attrs_ (MotionProps + Props_div) => ReactComponent { | attrs }
372−div = divImpl
373−
374−span ∷ ∀ attrs attrs_. Union attrs attrs_ (MotionProps + Props_span) => ReactComponent { | attrs }
375−span = spanImpl
376−
377−button ∷ ∀ attrs attrs_. Union attrs attrs_ (MotionProps + Props_button) => ReactComponent { | attrs }
378−button = buttonImpl
379−
380−svg ∷ ∀ attrs attrs_. Union attrs attrs_ (MotionProps + (SharedSVGProps Props_svg)) => ReactComponent { | attrs }
381−svg = svgImpl
382−
383−path ∷ ∀ attrs attrs_. Union attrs attrs_ (MotionProps + (SharedSVGProps Props_path)) => ReactComponent { | attrs }
384−path = pathImpl
385−
386−rect ∷ ∀ attrs attrs_. Union attrs attrs_ (MotionProps + (SharedSVGProps Props_rect)) => ReactComponent { | attrs }
387−rect = rectImpl
388−
389−h1 ∷ ∀ attrs attrs_. Union attrs attrs_ (MotionProps + Props_h1) => ReactComponent { | attrs }
390−h1 = h1Impl
16+import Framer.Motion.MotionComponent (_data, abbr, address, area, article, aside, audio, b, base, bdi, bdo, blockquote, body, br, button, canvas, caption, circle, cite, clipPath, code, col, colgroup, custom, datalist, dd, defs, del, desc, details, dfn, dialog, div, dl, dt, ellipse, em, embed, feBlend, feColorMatrix, feComponentTransfer, feComposite, feConvolveMatrix, feDiffuseLighting, feDisplacementMap, feDistantLight, feDropShadow, feFlood, feFuncA, feFuncB, feFuncG, feFuncR, feGaussianBlur, feImage, feMerge, feMergeNode, feMorphology, feOffset, fePointLight, feSpecularLighting, feSpotLight, feTile, feTurbulence, fieldset, figcaption, figure, filter, footer, foreignObject, form, g, h1, h2, h3, h4, h5, h6, head, header, hgroup, hr, html, i, iframe, image, img, input, ins, kbd, keygen, label, legend, li, line, linearGradient, link, main, map, mark, marker, mask, menu, menuitem, meta, metadata, meter, motionComponentImpl, nav, noscript, object, ol, optgroup, option, output, p, param, path, pattern, picture, polygon, polyline, pre, progress, q, radialGradient, rect, rp, rt, ruby, s, samp, script, section, select, small, source, span, stop, strong, style, sub, summary, sup, svg, svgAnimate, svgSwitch, symbol, table, tbody, td, text, textPath, textarea, tfoot, th, thead, time, title, tr, track, tspan, u, ul, use, var, video, view, wbr)
39117
39218withMotion ∷
39319 ∀ result baseProps motionSubset.
@@ -399,177 +25,12 @@ motion ∷
39925 Union baseProps (MotionProps ()) result => Nub result result => Castable motionSubset { | MotionProps () } => motionSubset -> Record baseProps -> Record result
40026motion = flip withMotion
40127
402−infixr 7 withMotion as >>
403−
404−foreign import data Infinity ∷ Type
405−
406−foreign import infinity ∷ Infinity
407−
408−foreign import custom ∷
409− ∀ old.
410− ReactComponent { | old } ->
411− Effect (ReactComponent { | MotionProps old })
412−
413−type AnimatePresenceProps =
414− ( initial ∷ Boolean
415− , custom ∷ ∀ a. a
416− , exitBeforeEnter ∷ Boolean
417− , onExitComplete ∷ Effect Unit
418− , children ∷ Array JSX
419− )
420−
42128foreign import animatePresence ∷
42229 ∀ attrs attrs_.
42330 Union attrs attrs_ AnimatePresenceProps =>
42431 ReactComponent { | attrs }
42532
426−type AnimateSharedLayoutProps =
427− ( type ∷ AnimateSharedLayoutType
428− , children ∷ Array JSX
429− )
430−
431−newtype AnimateSharedLayoutType = AnimateSharedLayoutType String
432−
433−switch ∷ AnimateSharedLayoutType
434−switch = AnimateSharedLayoutType "switch"
435−
436−crossfade ∷ AnimateSharedLayoutType
437−crossfade = AnimateSharedLayoutType "crossfade"
438−
43933foreign import animateSharedLayout ∷
44034 ∀ attrs attrs_.
44135 Union attrs attrs_ AnimateSharedLayoutProps =>
44236 ReactComponent { | attrs }
443−
444−type Props_div_no_key =
445− ( _aria ∷ Object String
446− , _data ∷ Object String
447− , about ∷ String
448− , acceptCharset ∷ String
449− , accessKey ∷ String
450− , allowFullScreen ∷ Boolean
451− , allowTransparency ∷ Boolean
452− , autoFocus ∷ Boolean
453− , autoPlay ∷ Boolean
454− , capture ∷ Boolean
455− , cellPadding ∷ String
456− , cellSpacing ∷ String
457− , charSet ∷ String
458− , children ∷ Array JSX
459− , classID ∷ String
460− , className ∷ String
461− , colSpan ∷ Int
462− , contentEditable ∷ Boolean
463− , contextMenu ∷ String
464− , crossOrigin ∷ String
465− , dangerouslySetInnerHTML ∷ { __html ∷ String }
466− , datatype ∷ String
467− , dateTime ∷ String
468− , dir ∷ String
469− , draggable ∷ Boolean
470− , encType ∷ String
471− , formAction ∷ String
472− , formEncType ∷ String
473− , formMethod ∷ String
474− , formNoValidate ∷ Boolean
475− , formTarget ∷ String
476− , frameBorder ∷ String
477− , hidden ∷ Boolean
478− , hrefLang ∷ String
479− , htmlFor ∷ String
480− , httpEquiv ∷ String
481− , icon ∷ String
482− , id ∷ String
483− , inlist ∷ String
484− , inputMode ∷ String
485− , is ∷ String
486− , itemID ∷ String
487− , itemProp ∷ String
488− , itemRef ∷ String
489− , itemScope ∷ Boolean
490− , itemType ∷ String
491− , keyParams ∷ String
492− , keyType ∷ String
493− , lang ∷ String
494− , marginHeight ∷ String
495− , marginWidth ∷ String
496− , maxLength ∷ Int
497− , mediaGroup ∷ String
498− , minLength ∷ Int
499− , noValidate ∷ Boolean
500− , onAnimationEnd ∷ EventHandler
501− , onAnimationIteration ∷ EventHandler
502− , onAnimationStart ∷ EventHandler
503− , onBlur ∷ EventHandler
504− , onClick ∷ EventHandler
505− , onCompositionEnd ∷ EventHandler
506− , onCompositionStart ∷ EventHandler
507− , onCompositionUpdate ∷ EventHandler
508− , onContextMenu ∷ EventHandler
509− , onCopy ∷ EventHandler
510− , onCut ∷ EventHandler
511− , onDoubleClick ∷ EventHandler
512− , onDrag ∷ EventHandler
513− , onDragEnd ∷ EventHandler
514− , onDragEnter ∷ EventHandler
515− , onDragExit ∷ EventHandler
516− , onDragLeave ∷ EventHandler
517− , onDragOver ∷ EventHandler
518− , onDragStart ∷ EventHandler
519− , onDrop ∷ EventHandler
520− , onFocus ∷ EventHandler
521− , onGotPointerCapture ∷ EventHandler
522− , onInvalid ∷ EventHandler
523− , onKeyDown ∷ EventHandler
524− , onKeyPress ∷ EventHandler
525− , onKeyUp ∷ EventHandler
526− , onLostPointerCapture ∷ EventHandler
527− , onMouseDown ∷ EventHandler
528− , onMouseEnter ∷ EventHandler
529− , onMouseLeave ∷ EventHandler
530− , onMouseMove ∷ EventHandler
531− , onMouseOut ∷ EventHandler
532− , onMouseOver ∷ EventHandler
533− , onMouseUp ∷ EventHandler
534− , onPaste ∷ EventHandler
535− , onPointerCancel ∷ EventHandler
536− , onPointerDown ∷ EventHandler
537− , onPointerEnter ∷ EventHandler
538− , onPointerLeave ∷ EventHandler
539− , onPointerMove ∷ EventHandler
540− , onPointerOut ∷ EventHandler
541− , onPointerOver ∷ EventHandler
542− , onPointerUp ∷ EventHandler
543− , onSelect ∷ EventHandler
544− , onSubmit ∷ EventHandler
545− , onTouchCancel ∷ EventHandler
546− , onTouchEnd ∷ EventHandler
547− , onTouchMove ∷ EventHandler
548− , onTouchStart ∷ EventHandler
549− , onTransitionEnd ∷ EventHandler
550− , onWheel ∷ EventHandler
551− , prefix ∷ String
552− , property ∷ String
553− , radioGroup ∷ String
554− , readOnly ∷ Boolean
555− , ref ∷ Ref (Nullable Node)
556− , resource ∷ String
557− , role ∷ String
558− , rowSpan ∷ Int
559− , scoped ∷ Boolean
560− , seamless ∷ Boolean
561− , security ∷ String
562− , spellCheck ∷ Boolean
563− , srcDoc ∷ JSX
564− , srcLang ∷ String
565− , srcSet ∷ String
566− , style ∷ CSS
567− , suppressContentEditableWarning ∷ Boolean
568− , tabIndex ∷ Int
569− , title ∷ String
570− , typeof ∷ String
571− , unselectable ∷ Boolean
572− , useMap ∷ String
573− , vocab ∷ String
574− , wmode ∷ String
575− )
src/Framer/Motion/MotionComponent.jsnew file+14
@@ -0,0 +1,14 @@
1+const framerMotion = require("framer-motion")
2+
3+exports.motionComponentImpl = (str) => {
4+ const html = ["a", "abbr", "address", "area", "article", "aside", "audio", "b", "base", "bdi", "bdo", "big", "blockquote", "body", "br", "button", "canvas", "caption", "cite", "code", "col", "colgroup", "data", "datalist", "dd", "del", "details", "dfn", "dialog", "div", "dl", "dt", "em", "embed", "fieldset", "figcaption", "figure", "footer", "form", "h1", "h2", "h3", "h4", "h5", "h6", "head", "header", "hgroup", "hr", "html", "i", "iframe", "img", "input", "ins", "kbd", "keygen", "label", "legend", "li", "link", "main", "map", "mark", "menu", "menuitem", "meta", "meter", "nav", "noscript", "object", "ol", "optgroup", "option", "output", "p", "param", "picture", "pre", "progress", "q", "rp", "rt", "ruby", "s", "samp", "script", "section", "select", "small", "source", "span", "strong", "style", "sub", "summary", "sup", "table", "tbody", "td", "textarea", "tfoot", "th", "thead", "time", "title", "tr", "track", "u", "ul", "var", "video", "wbr", "webview"]
5+ const svg = ["animate", "circle", "clipPath", "defs", "desc", "ellipse", "feBlend", "feColorMatrix", "feComponentTransfer", "feComposite", "feConvolveMatrix", "feDiffuseLighting", "feDisplacementMap", "feDistantLight", "feDropShadow", "feFlood", "feFuncA", "feFuncB", "feFuncG", "feFuncR", "feGaussianBlur", "feImage", "feMerge", "feMergeNode", "feMorphology", "feOffset", "fePointLight", "feSpecularLighting", "feSpotLight", "feTile", "feTurbulence", "filter", "foreignObject", "g", "image", "line", "linearGradient", "marker", "mask", "metadata", "path", "pattern", "polygon", "polyline", "radialGradient", "rect", "stop", "svg", "switch", "symbol", "text", "textPath", "tspan", "use", "view"]
6+ if (html.indexOf(str) === -1 && svg.indexOf(str) === -1) {
7+ console.error("Tried to use non-existing motion component " + str)
8+ }
9+ return framerMotion.motion[str]
10+}
11+
12+exports.custom = (component) => () => {
13+ return framerMotion.motion.custom(component)
14+}
src/Framer/Motion/MotionComponent.pursnew file+521
@@ -0,0 +1,521 @@
1+module Framer.Motion.MotionComponent where
2+
3+import Effect (Effect)
4+import Framer.Motion.Types (MotionProps)
5+import Prim.Row (class Union)
6+import React.Basic (ReactComponent)
7+import React.Basic.DOM as DOM
8+import React.Basic.DOM.SVG as SVG
9+import Type.Row (type (+))
10+
11+foreign import motionComponentImpl ∷ ∀ a. String -> ReactComponent { | a }
12+
13+foreign import custom ∷
14+ ∀ old.
15+ ReactComponent { | old } ->
16+ Effect (ReactComponent { | MotionProps old })
17+
18+-- DOM
19+abbr :: forall attrs attrs_. Union attrs attrs_ (MotionProps + DOM.Props_abbr) => ReactComponent { | attrs }
20+abbr = motionComponentImpl "abbr"
21+
22+address :: forall attrs attrs_. Union attrs attrs_ (MotionProps + DOM.Props_address) => ReactComponent { | attrs }
23+address = motionComponentImpl "address"
24+
25+area :: forall attrs attrs_. Union attrs attrs_ (MotionProps + DOM.Props_area) => ReactComponent { | attrs }
26+area = motionComponentImpl "area"
27+
28+article :: forall attrs attrs_. Union attrs attrs_ (MotionProps + DOM.Props_article) => ReactComponent { | attrs }
29+article = motionComponentImpl "article"
30+
31+aside :: forall attrs attrs_. Union attrs attrs_ (MotionProps + DOM.Props_aside) => ReactComponent { | attrs }
32+aside = motionComponentImpl "aside"
33+
34+audio :: forall attrs attrs_. Union attrs attrs_ (MotionProps + DOM.Props_audio) => ReactComponent { | attrs }
35+audio = motionComponentImpl "audio"
36+
37+b :: forall attrs attrs_. Union attrs attrs_ (MotionProps + DOM.Props_b) => ReactComponent { | attrs }
38+b = motionComponentImpl "b"
39+
40+base :: forall attrs attrs_. Union attrs attrs_ (MotionProps + DOM.Props_base) => ReactComponent { | attrs }
41+base = motionComponentImpl "base"
42+
43+bdi :: forall attrs attrs_. Union attrs attrs_ (MotionProps + DOM.Props_bdi) => ReactComponent { | attrs }
44+bdi = motionComponentImpl "bdi"
45+
46+bdo :: forall attrs attrs_. Union attrs attrs_ (MotionProps + DOM.Props_bdo) => ReactComponent { | attrs }
47+bdo = motionComponentImpl "bdo"
48+
49+-- No support in React Basic Hooks
50+-- big :: forall attrs attrs_. Union attrs attrs_ (MotionProps + DOM.Props_big) => ReactComponent { | attrs }
51+-- big = motionComponentImpl "big"
52+blockquote :: forall attrs attrs_. Union attrs attrs_ (MotionProps + DOM.Props_blockquote) => ReactComponent { | attrs }
53+blockquote = motionComponentImpl "blockquote"
54+
55+body :: forall attrs attrs_. Union attrs attrs_ (MotionProps + DOM.Props_body) => ReactComponent { | attrs }
56+body = motionComponentImpl "body"
57+
58+br :: forall attrs attrs_. Union attrs attrs_ (MotionProps + DOM.Props_br) => ReactComponent { | attrs }
59+br = motionComponentImpl "br"
60+
61+button :: forall attrs attrs_. Union attrs attrs_ (MotionProps + DOM.Props_button) => ReactComponent { | attrs }
62+button = motionComponentImpl "button"
63+
64+canvas :: forall attrs attrs_. Union attrs attrs_ (MotionProps + DOM.Props_canvas) => ReactComponent { | attrs }
65+canvas = motionComponentImpl "canvas"
66+
67+caption :: forall attrs attrs_. Union attrs attrs_ (MotionProps + DOM.Props_caption) => ReactComponent { | attrs }
68+caption = motionComponentImpl "caption"
69+
70+cite :: forall attrs attrs_. Union attrs attrs_ (MotionProps + DOM.Props_cite) => ReactComponent { | attrs }
71+cite = motionComponentImpl "cite"
72+
73+code :: forall attrs attrs_. Union attrs attrs_ (MotionProps + DOM.Props_code) => ReactComponent { | attrs }
74+code = motionComponentImpl "code"
75+
76+col :: forall attrs attrs_. Union attrs attrs_ (MotionProps + DOM.Props_col) => ReactComponent { | attrs }
77+col = motionComponentImpl "col"
78+
79+colgroup :: forall attrs attrs_. Union attrs attrs_ (MotionProps + DOM.Props_colgroup) => ReactComponent { | attrs }
80+colgroup = motionComponentImpl "colgroup"
81+
82+_data :: forall attrs attrs_. Union attrs attrs_ (MotionProps + DOM.Props_data) => ReactComponent { | attrs }
83+_data = motionComponentImpl "data"
84+
85+datalist :: forall attrs attrs_. Union attrs attrs_ (MotionProps + DOM.Props_datalist) => ReactComponent { | attrs }
86+datalist = motionComponentImpl "datalist"
87+
88+dd :: forall attrs attrs_. Union attrs attrs_ (MotionProps + DOM.Props_dd) => ReactComponent { | attrs }
89+dd = motionComponentImpl "dd"
90+
91+del :: forall attrs attrs_. Union attrs attrs_ (MotionProps + DOM.Props_del) => ReactComponent { | attrs }
92+del = motionComponentImpl "del"
93+
94+details :: forall attrs attrs_. Union attrs attrs_ (MotionProps + DOM.Props_details) => ReactComponent { | attrs }
95+details = motionComponentImpl "details"
96+
97+dfn :: forall attrs attrs_. Union attrs attrs_ (MotionProps + DOM.Props_dfn) => ReactComponent { | attrs }
98+dfn = motionComponentImpl "dfn"
99+
100+dialog :: forall attrs attrs_. Union attrs attrs_ (MotionProps + DOM.Props_dialog) => ReactComponent { | attrs }
101+dialog = motionComponentImpl "dialog"
102+
103+div :: forall attrs attrs_. Union attrs attrs_ (MotionProps + DOM.Props_div) => ReactComponent { | attrs }
104+div = motionComponentImpl "div"
105+
106+dl :: forall attrs attrs_. Union attrs attrs_ (MotionProps + DOM.Props_dl) => ReactComponent { | attrs }
107+dl = motionComponentImpl "dl"
108+
109+dt :: forall attrs attrs_. Union attrs attrs_ (MotionProps + DOM.Props_dt) => ReactComponent { | attrs }
110+dt = motionComponentImpl "dt"
111+
112+em :: forall attrs attrs_. Union attrs attrs_ (MotionProps + DOM.Props_em) => ReactComponent { | attrs }
113+em = motionComponentImpl "em"
114+
115+embed :: forall attrs attrs_. Union attrs attrs_ (MotionProps + DOM.Props_embed) => ReactComponent { | attrs }
116+embed = motionComponentImpl "embed"
117+
118+fieldset :: forall attrs attrs_. Union attrs attrs_ (MotionProps + DOM.Props_fieldset) => ReactComponent { | attrs }
119+fieldset = motionComponentImpl "fieldset"
120+
121+figcaption :: forall attrs attrs_. Union attrs attrs_ (MotionProps + DOM.Props_figcaption) => ReactComponent { | attrs }
122+figcaption = motionComponentImpl "figcaption"
123+
124+figure :: forall attrs attrs_. Union attrs attrs_ (MotionProps + DOM.Props_figure) => ReactComponent { | attrs }
125+figure = motionComponentImpl "figure"
126+
127+footer :: forall attrs attrs_. Union attrs attrs_ (MotionProps + DOM.Props_footer) => ReactComponent { | attrs }
128+footer = motionComponentImpl "footer"
129+
130+form :: forall attrs attrs_. Union attrs attrs_ (MotionProps + DOM.Props_form) => ReactComponent { | attrs }
131+form = motionComponentImpl "form"
132+
133+h1 :: forall attrs attrs_. Union attrs attrs_ (MotionProps + DOM.Props_h1) => ReactComponent { | attrs }
134+h1 = motionComponentImpl "h1"
135+
136+h2 :: forall attrs attrs_. Union attrs attrs_ (MotionProps + DOM.Props_h2) => ReactComponent { | attrs }
137+h2 = motionComponentImpl "h2"
138+
139+h3 :: forall attrs attrs_. Union attrs attrs_ (MotionProps + DOM.Props_h3) => ReactComponent { | attrs }
140+h3 = motionComponentImpl "h3"
141+
142+h4 :: forall attrs attrs_. Union attrs attrs_ (MotionProps + DOM.Props_h4) => ReactComponent { | attrs }
143+h4 = motionComponentImpl "h4"
144+
145+h5 :: forall attrs attrs_. Union attrs attrs_ (MotionProps + DOM.Props_h5) => ReactComponent { | attrs }
146+h5 = motionComponentImpl "h5"
147+
148+h6 :: forall attrs attrs_. Union attrs attrs_ (MotionProps + DOM.Props_h6) => ReactComponent { | attrs }
149+h6 = motionComponentImpl "h6"
150+
151+head :: forall attrs attrs_. Union attrs attrs_ (MotionProps + DOM.Props_head) => ReactComponent { | attrs }
152+head = motionComponentImpl "head"
153+
154+header :: forall attrs attrs_. Union attrs attrs_ (MotionProps + DOM.Props_header) => ReactComponent { | attrs }
155+header = motionComponentImpl "header"
156+
157+hgroup :: forall attrs attrs_. Union attrs attrs_ (MotionProps + DOM.Props_hgroup) => ReactComponent { | attrs }
158+hgroup = motionComponentImpl "hgroup"
159+
160+hr :: forall attrs attrs_. Union attrs attrs_ (MotionProps + DOM.Props_hr) => ReactComponent { | attrs }
161+hr = motionComponentImpl "hr"
162+
163+html :: forall attrs attrs_. Union attrs attrs_ (MotionProps + DOM.Props_html) => ReactComponent { | attrs }
164+html = motionComponentImpl "html"
165+
166+i :: forall attrs attrs_. Union attrs attrs_ (MotionProps + DOM.Props_i) => ReactComponent { | attrs }
167+i = motionComponentImpl "i"
168+
169+iframe :: forall attrs attrs_. Union attrs attrs_ (MotionProps + DOM.Props_iframe) => ReactComponent { | attrs }
170+iframe = motionComponentImpl "iframe"
171+
172+img :: forall attrs attrs_. Union attrs attrs_ (MotionProps + DOM.Props_img) => ReactComponent { | attrs }
173+img = motionComponentImpl "img"
174+
175+input :: forall attrs attrs_. Union attrs attrs_ (MotionProps + DOM.Props_input) => ReactComponent { | attrs }
176+input = motionComponentImpl "input"
177+
178+ins :: forall attrs attrs_. Union attrs attrs_ (MotionProps + DOM.Props_ins) => ReactComponent { | attrs }
179+ins = motionComponentImpl "ins"
180+
181+kbd :: forall attrs attrs_. Union attrs attrs_ (MotionProps + DOM.Props_kbd) => ReactComponent { | attrs }
182+kbd = motionComponentImpl "kbd"
183+
184+keygen :: forall attrs attrs_. Union attrs attrs_ (MotionProps + DOM.Props_keygen) => ReactComponent { | attrs }
185+keygen = motionComponentImpl "keygen"
186+
187+label :: forall attrs attrs_. Union attrs attrs_ (MotionProps + DOM.Props_label) => ReactComponent { | attrs }
188+label = motionComponentImpl "label"
189+
190+legend :: forall attrs attrs_. Union attrs attrs_ (MotionProps + DOM.Props_legend) => ReactComponent { | attrs }
191+legend = motionComponentImpl "legend"
192+
193+li :: forall attrs attrs_. Union attrs attrs_ (MotionProps + DOM.Props_li) => ReactComponent { | attrs }
194+li = motionComponentImpl "li"
195+
196+link :: forall attrs attrs_. Union attrs attrs_ (MotionProps + DOM.Props_link) => ReactComponent { | attrs }
197+link = motionComponentImpl "link"
198+
199+main :: forall attrs attrs_. Union attrs attrs_ (MotionProps + DOM.Props_main) => ReactComponent { | attrs }
200+main = motionComponentImpl "main"
201+
202+map :: forall attrs attrs_. Union attrs attrs_ (MotionProps + DOM.Props_map) => ReactComponent { | attrs }
203+map = motionComponentImpl "map"
204+
205+mark :: forall attrs attrs_. Union attrs attrs_ (MotionProps + DOM.Props_mark) => ReactComponent { | attrs }
206+mark = motionComponentImpl "mark"
207+
208+menu :: forall attrs attrs_. Union attrs attrs_ (MotionProps + DOM.Props_menu) => ReactComponent { | attrs }
209+menu = motionComponentImpl "menu"
210+
211+menuitem :: forall attrs attrs_. Union attrs attrs_ (MotionProps + DOM.Props_menuitem) => ReactComponent { | attrs }
212+menuitem = motionComponentImpl "menuitem"
213+
214+meta :: forall attrs attrs_. Union attrs attrs_ (MotionProps + DOM.Props_meta) => ReactComponent { | attrs }
215+meta = motionComponentImpl "meta"
216+
217+meter :: forall attrs attrs_. Union attrs attrs_ (MotionProps + DOM.Props_meter) => ReactComponent { | attrs }
218+meter = motionComponentImpl "meter"
219+
220+nav :: forall attrs attrs_. Union attrs attrs_ (MotionProps + DOM.Props_nav) => ReactComponent { | attrs }
221+nav = motionComponentImpl "nav"
222+
223+noscript :: forall attrs attrs_. Union attrs attrs_ (MotionProps + DOM.Props_noscript) => ReactComponent { | attrs }
224+noscript = motionComponentImpl "noscript"
225+
226+object :: forall attrs attrs_. Union attrs attrs_ (MotionProps + DOM.Props_object) => ReactComponent { | attrs }
227+object = motionComponentImpl "object"
228+
229+ol :: forall attrs attrs_. Union attrs attrs_ (MotionProps + DOM.Props_ol) => ReactComponent { | attrs }
230+ol = motionComponentImpl "ol"
231+
232+optgroup :: forall attrs attrs_. Union attrs attrs_ (MotionProps + DOM.Props_optgroup) => ReactComponent { | attrs }
233+optgroup = motionComponentImpl "optgroup"
234+
235+option :: forall attrs attrs_. Union attrs attrs_ (MotionProps + DOM.Props_option) => ReactComponent { | attrs }
236+option = motionComponentImpl "option"
237+
238+output :: forall attrs attrs_. Union attrs attrs_ (MotionProps + DOM.Props_output) => ReactComponent { | attrs }
239+output = motionComponentImpl "output"
240+
241+p :: forall attrs attrs_. Union attrs attrs_ (MotionProps + DOM.Props_p) => ReactComponent { | attrs }
242+p = motionComponentImpl "p"
243+
244+param :: forall attrs attrs_. Union attrs attrs_ (MotionProps + DOM.Props_param) => ReactComponent { | attrs }
245+param = motionComponentImpl "param"
246+
247+picture :: forall attrs attrs_. Union attrs attrs_ (MotionProps + DOM.Props_picture) => ReactComponent { | attrs }
248+picture = motionComponentImpl "picture"
249+
250+pre :: forall attrs attrs_. Union attrs attrs_ (MotionProps + DOM.Props_pre) => ReactComponent { | attrs }
251+pre = motionComponentImpl "pre"
252+
253+progress :: forall attrs attrs_. Union attrs attrs_ (MotionProps + DOM.Props_progress) => ReactComponent { | attrs }
254+progress = motionComponentImpl "progress"
255+
256+q :: forall attrs attrs_. Union attrs attrs_ (MotionProps + DOM.Props_q) => ReactComponent { | attrs }
257+q = motionComponentImpl "q"
258+
259+rp :: forall attrs attrs_. Union attrs attrs_ (MotionProps + DOM.Props_rp) => ReactComponent { | attrs }
260+rp = motionComponentImpl "rp"
261+
262+rt :: forall attrs attrs_. Union attrs attrs_ (MotionProps + DOM.Props_rt) => ReactComponent { | attrs }
263+rt = motionComponentImpl "rt"
264+
265+ruby :: forall attrs attrs_. Union attrs attrs_ (MotionProps + DOM.Props_ruby) => ReactComponent { | attrs }
266+ruby = motionComponentImpl "ruby"
267+
268+s :: forall attrs attrs_. Union attrs attrs_ (MotionProps + DOM.Props_s) => ReactComponent { | attrs }
269+s = motionComponentImpl "s"
270+
271+samp :: forall attrs attrs_. Union attrs attrs_ (MotionProps + DOM.Props_samp) => ReactComponent { | attrs }
272+samp = motionComponentImpl "samp"
273+
274+script :: forall attrs attrs_. Union attrs attrs_ (MotionProps + DOM.Props_script) => ReactComponent { | attrs }
275+script = motionComponentImpl "script"
276+
277+section :: forall attrs attrs_. Union attrs attrs_ (MotionProps + DOM.Props_section) => ReactComponent { | attrs }
278+section = motionComponentImpl "section"
279+
280+select :: forall attrs attrs_. Union attrs attrs_ (MotionProps + DOM.Props_select) => ReactComponent { | attrs }
281+select = motionComponentImpl "select"
282+
283+small :: forall attrs attrs_. Union attrs attrs_ (MotionProps + DOM.Props_small) => ReactComponent { | attrs }
284+small = motionComponentImpl "small"
285+
286+source :: forall attrs attrs_. Union attrs attrs_ (MotionProps + DOM.Props_source) => ReactComponent { | attrs }
287+source = motionComponentImpl "source"
288+
289+span :: forall attrs attrs_. Union attrs attrs_ (MotionProps + DOM.Props_span) => ReactComponent { | attrs }
290+span = motionComponentImpl "span"
291+
292+strong :: forall attrs attrs_. Union attrs attrs_ (MotionProps + DOM.Props_strong) => ReactComponent { | attrs }
293+strong = motionComponentImpl "strong"
294+
295+style :: forall attrs attrs_. Union attrs attrs_ (MotionProps + DOM.Props_style) => ReactComponent { | attrs }
296+style = motionComponentImpl "style"
297+
298+sub :: forall attrs attrs_. Union attrs attrs_ (MotionProps + DOM.Props_sub) => ReactComponent { | attrs }
299+sub = motionComponentImpl "sub"
300+
301+summary :: forall attrs attrs_. Union attrs attrs_ (MotionProps + DOM.Props_summary) => ReactComponent { | attrs }
302+summary = motionComponentImpl "summary"
303+
304+sup :: forall attrs attrs_. Union attrs attrs_ (MotionProps + DOM.Props_sup) => ReactComponent { | attrs }
305+sup = motionComponentImpl "sup"
306+
307+table :: forall attrs attrs_. Union attrs attrs_ (MotionProps + DOM.Props_table) => ReactComponent { | attrs }
308+table = motionComponentImpl "table"
309+
310+tbody :: forall attrs attrs_. Union attrs attrs_ (MotionProps + DOM.Props_tbody) => ReactComponent { | attrs }
311+tbody = motionComponentImpl "tbody"
312+
313+td :: forall attrs attrs_. Union attrs attrs_ (MotionProps + DOM.Props_td) => ReactComponent { | attrs }
314+td = motionComponentImpl "td"
315+
316+textarea :: forall attrs attrs_. Union attrs attrs_ (MotionProps + DOM.Props_textarea) => ReactComponent { | attrs }
317+textarea = motionComponentImpl "textarea"
318+
319+tfoot :: forall attrs attrs_. Union attrs attrs_ (MotionProps + DOM.Props_tfoot) => ReactComponent { | attrs }
320+tfoot = motionComponentImpl "tfoot"
321+
322+th :: forall attrs attrs_. Union attrs attrs_ (MotionProps + DOM.Props_th) => ReactComponent { | attrs }
323+th = motionComponentImpl "th"
324+
325+thead :: forall attrs attrs_. Union attrs attrs_ (MotionProps + DOM.Props_thead) => ReactComponent { | attrs }
326+thead = motionComponentImpl "thead"
327+
328+time :: forall attrs attrs_. Union attrs attrs_ (MotionProps + DOM.Props_time) => ReactComponent { | attrs }
329+time = motionComponentImpl "time"
330+
331+title :: forall attrs attrs_. Union attrs attrs_ (MotionProps + DOM.Props_title) => ReactComponent { | attrs }
332+title = motionComponentImpl "title"
333+
334+tr :: forall attrs attrs_. Union attrs attrs_ (MotionProps + DOM.Props_tr) => ReactComponent { | attrs }
335+tr = motionComponentImpl "tr"
336+
337+track :: forall attrs attrs_. Union attrs attrs_ (MotionProps + DOM.Props_track) => ReactComponent { | attrs }
338+track = motionComponentImpl "track"
339+
340+u :: forall attrs attrs_. Union attrs attrs_ (MotionProps + DOM.Props_u) => ReactComponent { | attrs }
341+u = motionComponentImpl "u"
342+
343+ul :: forall attrs attrs_. Union attrs attrs_ (MotionProps + DOM.Props_ul) => ReactComponent { | attrs }
344+ul = motionComponentImpl "ul"
345+
346+var :: forall attrs attrs_. Union attrs attrs_ (MotionProps + DOM.Props_var) => ReactComponent { | attrs }
347+var = motionComponentImpl "var"
348+
349+video :: forall attrs attrs_. Union attrs attrs_ (MotionProps + DOM.Props_video) => ReactComponent { | attrs }
350+video = motionComponentImpl "video"
351+
352+wbr :: forall attrs attrs_. Union attrs attrs_ (MotionProps + DOM.Props_wbr) => ReactComponent { | attrs }
353+wbr = motionComponentImpl "wbr"
354+
355+-- No support in React.Basic.Hooks
356+-- webview :: forall attrs attrs_. Union attrs attrs_ (MotionProps + DOM.Props_webview) => ReactComponent { | attrs }
357+-- webview = motionComponentImpl "webview"
358+svgAnimate :: forall attrs attrs_. Union attrs attrs_ (MotionProps + SVG.Props_animate) => ReactComponent { | attrs }
359+svgAnimate = motionComponentImpl "animate"
360+
361+circle :: forall attrs attrs_. Union attrs attrs_ (MotionProps + SVG.Props_circle) => ReactComponent { | attrs }
362+circle = motionComponentImpl "circle"
363+
364+clipPath :: forall attrs attrs_. Union attrs attrs_ (MotionProps + SVG.Props_clipPath) => ReactComponent { | attrs }
365+clipPath = motionComponentImpl "clipPath"
366+
367+defs :: forall attrs attrs_. Union attrs attrs_ (MotionProps + SVG.Props_defs) => ReactComponent { | attrs }
368+defs = motionComponentImpl "defs"
369+
370+desc :: forall attrs attrs_. Union attrs attrs_ (MotionProps + SVG.Props_desc) => ReactComponent { | attrs }
371+desc = motionComponentImpl "desc"
372+
373+ellipse :: forall attrs attrs_. Union attrs attrs_ (MotionProps + SVG.Props_ellipse) => ReactComponent { | attrs }
374+ellipse = motionComponentImpl "ellipse"
375+
376+feBlend :: forall attrs attrs_. Union attrs attrs_ (MotionProps + SVG.Props_feBlend) => ReactComponent { | attrs }
377+feBlend = motionComponentImpl "feBlend"
378+
379+feColorMatrix :: forall attrs attrs_. Union attrs attrs_ (MotionProps + SVG.Props_feColorMatrix) => ReactComponent { | attrs }
380+feColorMatrix = motionComponentImpl "feColorMatrix"
381+
382+feComponentTransfer :: forall attrs attrs_. Union attrs attrs_ (MotionProps + SVG.Props_feComponentTransfer) => ReactComponent { | attrs }
383+feComponentTransfer = motionComponentImpl "feComponentTransfer"
384+
385+feComposite :: forall attrs attrs_. Union attrs attrs_ (MotionProps + SVG.Props_feComposite) => ReactComponent { | attrs }
386+feComposite = motionComponentImpl "feComposite"
387+
388+feConvolveMatrix :: forall attrs attrs_. Union attrs attrs_ (MotionProps + SVG.Props_feConvolveMatrix) => ReactComponent { | attrs }
389+feConvolveMatrix = motionComponentImpl "feConvolveMatrix"
390+
391+feDiffuseLighting :: forall attrs attrs_. Union attrs attrs_ (MotionProps + SVG.Props_feDiffuseLighting) => ReactComponent { | attrs }
392+feDiffuseLighting = motionComponentImpl "feDiffuseLighting"
393+
394+feDisplacementMap :: forall attrs attrs_. Union attrs attrs_ (MotionProps + SVG.Props_feDisplacementMap) => ReactComponent { | attrs }
395+feDisplacementMap = motionComponentImpl "feDisplacementMap"
396+
397+feDistantLight :: forall attrs attrs_. Union attrs attrs_ (MotionProps + SVG.Props_feDistantLight) => ReactComponent { | attrs }
398+feDistantLight = motionComponentImpl "feDistantLight"
399+
400+feDropShadow :: forall attrs attrs_. Union attrs attrs_ (MotionProps + SVG.Props_feDropShadow) => ReactComponent { | attrs }
401+feDropShadow = motionComponentImpl "feDropShadow"
402+
403+feFlood :: forall attrs attrs_. Union attrs attrs_ (MotionProps + SVG.Props_feFlood) => ReactComponent { | attrs }
404+feFlood = motionComponentImpl "feFlood"
405+
406+feFuncA :: forall attrs attrs_. Union attrs attrs_ (MotionProps + SVG.Props_feFuncA) => ReactComponent { | attrs }
407+feFuncA = motionComponentImpl "feFuncA"
408+
409+feFuncB :: forall attrs attrs_. Union attrs attrs_ (MotionProps + SVG.Props_feFuncB) => ReactComponent { | attrs }
410+feFuncB = motionComponentImpl "feFuncB"
411+
412+feFuncG :: forall attrs attrs_. Union attrs attrs_ (MotionProps + SVG.Props_feFuncG) => ReactComponent { | attrs }
413+feFuncG = motionComponentImpl "feFuncG"
414+
415+feFuncR :: forall attrs attrs_. Union attrs attrs_ (MotionProps + SVG.Props_feFuncR) => ReactComponent { | attrs }
416+feFuncR = motionComponentImpl "feFuncR"
417+
418+feGaussianBlur :: forall attrs attrs_. Union attrs attrs_ (MotionProps + SVG.Props_feGaussianBlur) => ReactComponent { | attrs }
419+feGaussianBlur = motionComponentImpl "feGaussianBlur"
420+
421+feImage :: forall attrs attrs_. Union attrs attrs_ (MotionProps + SVG.Props_feImage) => ReactComponent { | attrs }
422+feImage = motionComponentImpl "feImage"
423+
424+feMerge :: forall attrs attrs_. Union attrs attrs_ (MotionProps + SVG.Props_feMerge) => ReactComponent { | attrs }
425+feMerge = motionComponentImpl "feMerge"
426+
427+feMergeNode :: forall attrs attrs_. Union attrs attrs_ (MotionProps + SVG.Props_feMergeNode) => ReactComponent { | attrs }
428+feMergeNode = motionComponentImpl "feMergeNode"
429+
430+feMorphology :: forall attrs attrs_. Union attrs attrs_ (MotionProps + SVG.Props_feMorphology) => ReactComponent { | attrs }
431+feMorphology = motionComponentImpl "feMorphology"
432+
433+feOffset :: forall attrs attrs_. Union attrs attrs_ (MotionProps + SVG.Props_feOffset) => ReactComponent { | attrs }
434+feOffset = motionComponentImpl "feOffset"
435+
436+fePointLight :: forall attrs attrs_. Union attrs attrs_ (MotionProps + SVG.Props_fePointLight) => ReactComponent { | attrs }
437+fePointLight = motionComponentImpl "fePointLight"
438+
439+feSpecularLighting :: forall attrs attrs_. Union attrs attrs_ (MotionProps + SVG.Props_feSpecularLighting) => ReactComponent { | attrs }
440+feSpecularLighting = motionComponentImpl "feSpecularLighting"
441+
442+feSpotLight :: forall attrs attrs_. Union attrs attrs_ (MotionProps + SVG.Props_feSpotLight) => ReactComponent { | attrs }
443+feSpotLight = motionComponentImpl "feSpotLight"
444+
445+feTile :: forall attrs attrs_. Union attrs attrs_ (MotionProps + SVG.Props_feTile) => ReactComponent { | attrs }
446+feTile = motionComponentImpl "feTile"
447+
448+feTurbulence :: forall attrs attrs_. Union attrs attrs_ (MotionProps + SVG.Props_feTurbulence) => ReactComponent { | attrs }
449+feTurbulence = motionComponentImpl "feTurbulence"
450+
451+filter :: forall attrs attrs_. Union attrs attrs_ (MotionProps + SVG.Props_filter) => ReactComponent { | attrs }
452+filter = motionComponentImpl "filter"
453+
454+foreignObject :: forall attrs attrs_. Union attrs attrs_ (MotionProps + SVG.Props_foreignObject) => ReactComponent { | attrs }
455+foreignObject = motionComponentImpl "foreignObject"
456+
457+g :: forall attrs attrs_. Union attrs attrs_ (MotionProps + SVG.Props_g) => ReactComponent { | attrs }
458+g = motionComponentImpl "g"
459+
460+image :: forall attrs attrs_. Union attrs attrs_ (MotionProps + SVG.Props_image) => ReactComponent { | attrs }
461+image = motionComponentImpl "image"
462+
463+line :: forall attrs attrs_. Union attrs attrs_ (MotionProps + SVG.Props_line) => ReactComponent { | attrs }
464+line = motionComponentImpl "line"
465+
466+linearGradient :: forall attrs attrs_. Union attrs attrs_ (MotionProps + SVG.Props_linearGradient) => ReactComponent { | attrs }
467+linearGradient = motionComponentImpl "linearGradient"
468+
469+marker :: forall attrs attrs_. Union attrs attrs_ (MotionProps + SVG.Props_marker) => ReactComponent { | attrs }
470+marker = motionComponentImpl "marker"
471+
472+mask :: forall attrs attrs_. Union attrs attrs_ (MotionProps + SVG.Props_mask) => ReactComponent { | attrs }
473+mask = motionComponentImpl "mask"
474+
475+metadata :: forall attrs attrs_. Union attrs attrs_ (MotionProps + SVG.Props_metadata) => ReactComponent { | attrs }
476+metadata = motionComponentImpl "metadata"
477+
478+path :: forall attrs attrs_. Union attrs attrs_ (MotionProps + SVG.Props_path) => ReactComponent { | attrs }
479+path = motionComponentImpl "path"
480+
481+pattern :: forall attrs attrs_. Union attrs attrs_ (MotionProps + SVG.Props_pattern) => ReactComponent { | attrs }
482+pattern = motionComponentImpl "pattern"
483+
484+polygon :: forall attrs attrs_. Union attrs attrs_ (MotionProps + SVG.Props_polygon) => ReactComponent { | attrs }
485+polygon = motionComponentImpl "polygon"
486+
487+polyline :: forall attrs attrs_. Union attrs attrs_ (MotionProps + SVG.Props_polyline) => ReactComponent { | attrs }
488+polyline = motionComponentImpl "polyline"
489+
490+radialGradient :: forall attrs attrs_. Union attrs attrs_ (MotionProps + SVG.Props_radialGradient) => ReactComponent { | attrs }
491+radialGradient = motionComponentImpl "radialGradient"
492+
493+rect :: forall attrs attrs_. Union attrs attrs_ (MotionProps + SVG.Props_rect) => ReactComponent { | attrs }
494+rect = motionComponentImpl "rect"
495+
496+stop :: forall attrs attrs_. Union attrs attrs_ (MotionProps + SVG.Props_stop) => ReactComponent { | attrs }
497+stop = motionComponentImpl "stop"
498+
499+svg :: forall attrs attrs_. Union attrs attrs_ (MotionProps + SVG.Props_svg) => ReactComponent { | attrs }
500+svg = motionComponentImpl "svg"
501+
502+svgSwitch :: forall attrs attrs_. Union attrs attrs_ (MotionProps + SVG.Props_switch) => ReactComponent { | attrs }
503+svgSwitch = motionComponentImpl "switch"
504+
505+symbol :: forall attrs attrs_. Union attrs attrs_ (MotionProps + SVG.Props_symbol) => ReactComponent { | attrs }
506+symbol = motionComponentImpl "symbol"
507+
508+text :: forall attrs attrs_. Union attrs attrs_ (MotionProps + SVG.Props_text) => ReactComponent { | attrs }
509+text = motionComponentImpl "text"
510+
511+textPath :: forall attrs attrs_. Union attrs attrs_ (MotionProps + SVG.Props_textPath) => ReactComponent { | attrs }
512+textPath = motionComponentImpl "textPath"
513+
514+tspan :: forall attrs attrs_. Union attrs attrs_ (MotionProps + SVG.Props_tspan) => ReactComponent { | attrs }
515+tspan = motionComponentImpl "tspan"
516+
517+use :: forall attrs attrs_. Union attrs attrs_ (MotionProps + SVG.Props_use) => ReactComponent { | attrs }
518+use = motionComponentImpl "use"
519+
520+view :: forall attrs attrs_. Union attrs attrs_ (MotionProps + SVG.Props_view) => ReactComponent { | attrs }
521+view = motionComponentImpl "view"
src/Framer/Motion/Types.jsnew file+4
@@ -0,0 +1,4 @@
1+const framerMotion = require("framer-motion")
2+
3+exports.infinity = Infinity
4+
src/Framer/Motion/Types.pursnew file+290
@@ -0,0 +1,290 @@
1+module Framer.Motion.Types where
2+
3+import Prelude
4+import Data.Nullable (Nullable)
5+import Data.Symbol (class IsSymbol, SProxy, reflectSymbol)
6+import Effect (Effect)
7+import Effect.Uncurried (EffectFn1, EffectFn2, mkEffectFn1, mkEffectFn2)
8+import Foreign (Foreign, unsafeToForeign)
9+import Foreign.Object (Object)
10+import Heterogeneous.Mapping (class HMapWithIndex, class MappingWithIndex, hmapWithIndex)
11+import Literals.Undefined (Undefined)
12+import React.Basic (JSX)
13+import React.Basic.DOM (CSS, css)
14+import React.Basic.Hooks (Ref)
15+import Unsafe.Coerce (unsafeCoerce)
16+import Untagged.Castable (class Castable, cast)
17+import Untagged.Union (type (|+|))
18+import Web.DOM (Node)
19+import Web.Event.Internal.Types (Event)
20+import Web.UIEvent.MouseEvent (MouseEvent)
21+import Yoga.Block.Internal (Id)
22+
23+type Transition
24+ = CSS |+| Undefined
25+
26+newtype VariantLabel
27+ = VariantLabel String
28+
29+data Target
30+ = Target
31+
32+type Exit
33+ = CSS |+| VariantLabel |+| Array VariantLabel |+| Undefined
34+
35+foreign import data AnimationControls ∷ Type
36+
37+prop ∷ ∀ a b. Castable a b => a -> b
38+prop = cast
39+
40+type Animate
41+ = CSS
42+ |+| VariantLabel
43+ |+| Array VariantLabel
44+ |+| AnimationControls
45+ |+| Undefined
46+
47+type Initial
48+ = Boolean |+| CSS |+| VariantLabel |+| Array VariantLabel |+| Undefined
49+
50+type Layout
51+ = Boolean |+| Undefined
52+
53+type Variants
54+ = CSS |+| Undefined
55+
56+type LayoutTransition
57+ = Boolean |+| Undefined
58+
59+type Drag
60+ = Boolean |+| String |+| Undefined
61+
62+type DragMomentum
63+ = Boolean |+| Undefined
64+
65+dragMomentum ∷ ∀ c. Castable c DragMomentum => c -> DragMomentum
66+dragMomentum = cast
67+
68+type DragConstraints
69+ = Ref (Nullable Node) |+| BoundingBox2D |+| Undefined
70+
71+type DragElastic
72+ = Boolean |+| Number |+| Undefined
73+
74+dragElastic ∷ ∀ c. Castable c DragElastic => c -> DragElastic
75+dragElastic = cast
76+
77+type BoundingBox2D
78+ = { left ∷ Int |+| Number |+| Undefined
79+ , right ∷ Int |+| Number |+| Undefined
80+ , top ∷ Int |+| Number |+| Undefined
81+ , bottom ∷ Int |+| Number |+| Undefined
82+ }
83+
84+boundingBox2D ∷ ∀ c. Castable c BoundingBox2D => c -> BoundingBox2D
85+boundingBox2D = cast
86+
87+type Point2D
88+ = { x ∷ Number, y ∷ Number }
89+
90+type PanInfo
91+ = { point ∷ Point2D, delta ∷ Point2D, offset ∷ Point2D, velocity ∷ Point2D }
92+
93+type OnDragStart
94+ = (EffectFn2 Event PanInfo Unit |+| Undefined)
95+
96+type OnDragEnd
97+ = (EffectFn2 Event PanInfo Unit |+| Undefined)
98+
99+type OnDrag
100+ = (EffectFn2 Event PanInfo Unit |+| Undefined)
101+
102+type WhileTap
103+ = TargetAndTransition |+| String |+| Undefined
104+
105+type OnTap
106+ = (EffectFn2 Event TapInfo Unit |+| Undefined)
107+
108+type OnTapStart
109+ = (EffectFn2 Event TapInfo Unit |+| Undefined)
110+
111+type OnTapEnd
112+ = (EffectFn2 Event TapInfo Unit |+| Undefined)
113+
114+type OnTapCancel
115+ = (EffectFn2 Event TapInfo Unit |+| Undefined)
116+
117+onTapStart ∷ (Event -> TapInfo -> Effect Unit) -> OnTapStart
118+onTapStart = cast <<< toEffectFn
119+
120+onTapEnd ∷ (Event -> TapInfo -> Effect Unit) -> OnTapEnd
121+onTapEnd = cast <<< toEffectFn
122+
123+onTap ∷ (Event -> TapInfo -> Effect Unit) -> OnTap
124+onTap fn2 = cast (mkEffectFn2 fn2)
125+
126+onTapCancel ∷ (Event -> TapInfo -> Effect Unit) -> OnTap
127+onTapCancel fn2 = cast (mkEffectFn2 fn2)
128+
129+type EventInfo
130+ = { point ∷ { x ∷ Number, y ∷ Number }
131+ }
132+
133+type WhileHover
134+ = (EffectFn2 MouseEvent EventInfo Unit |+| Undefined)
135+
136+type OnHoverEnd
137+ = (EffectFn2 MouseEvent EventInfo Unit |+| Undefined)
138+
139+type OnHoverStart
140+ = (EffectFn2 MouseEvent EventInfo Unit |+| Undefined)
141+
142+onHoverStart ∷ (MouseEvent -> EventInfo -> Effect Unit) -> OnHoverStart
143+onHoverStart = cast <<< toEffectFn
144+
145+onHoverEnd ∷ (MouseEvent -> EventInfo -> Effect Unit) -> OnHoverEnd
146+onHoverEnd = cast <<< toEffectFn
147+
148+whileHover ∷ ∀ c. Castable c WhileHover => c -> WhileHover
149+whileHover = cast
150+
151+type TapInfo
152+ = { x ∷ Number, y ∷ Number }
153+
154+-- Can contain "transition" and "transitionEnd"
155+type TargetAndTransition
156+ = CSS
157+
158+type DragPropagation
159+ = Boolean |+| Undefined
160+
161+whileTap ∷ ∀ c. Castable c WhileTap => c -> WhileTap
162+whileTap = cast
163+
164+class EffectFnMaker fn effectFn | fn -> effectFn where
165+ toEffectFn ∷ fn -> effectFn
166+
167+instance callbackableEffectFn2 ∷ EffectFnMaker (a -> b -> Effect c) (EffectFn2 a b c) where
168+ toEffectFn = mkEffectFn2
169+
170+instance callbackableEffectFn1 ∷ EffectFnMaker (a -> Effect b) (EffectFn1 a b) where
171+ toEffectFn = mkEffectFn1
172+
173+callback ∷ ∀ a c f. Castable c a => EffectFnMaker f c => f -> a
174+callback = cast <<< toEffectFn
175+
176+onDragStart ∷ (Event -> PanInfo -> Effect Unit) -> OnDragStart
177+onDragStart = cast <<< toEffectFn
178+
179+onDragEnd ∷ (Event -> PanInfo -> Effect Unit) -> OnDragEnd
180+onDragEnd = cast <<< toEffectFn
181+
182+onDrag ∷ (Event -> PanInfo -> Effect Unit) -> OnDrag
183+onDrag fn2 = cast (mkEffectFn2 fn2)
184+
185+customProp ∷ ∀ a. a -> Foreign
186+customProp = unsafeToForeign
187+
188+type LayoutId
189+ = String |+| Undefined
190+
191+layoutId ∷ ∀ a. Castable a LayoutId => a -> LayoutId
192+layoutId = cast
193+
194+type MotionPropsF f r
195+ = ( initial ∷ f Initial
196+ , animate ∷ f Animate
197+ , custom ∷ f Foreign
198+ , drag ∷ f Drag
199+ , dragMomentum ∷ f DragMomentum
200+ , dragElastic ∷ f DragElastic
201+ , onDragStart ∷ f OnDragStart
202+ , onDrag ∷ f OnDrag
203+ , onDragEnd ∷ f OnDragEnd
204+ , dragConstraints ∷ f DragConstraints
205+ , dragPropagation ∷ f DragPropagation
206+ , variants ∷ f Variants
207+ , transition ∷ f Transition
208+ , layout ∷ f Layout
209+ , layoutId ∷ f LayoutId
210+ , whileTap ∷ f WhileTap
211+ , onTap ∷ f OnTap
212+ , onTapStart ∷ f OnTapStart
213+ , onTapEnd ∷ f OnTapEnd
214+ , onTapCancel ∷ f OnTapCancel
215+ , whileHover ∷ f WhileHover
216+ , onHoverStart ∷ f OnHoverStart
217+ , onHoverEnd ∷ f OnHoverEnd
218+ , exit ∷ f Exit
219+ | r
220+ )
221+
222+type MotionProps r
223+ = MotionPropsF Id r
224+
225+animate ∷ ∀ a. Castable a Animate => a -> Animate
226+animate = cast
227+
228+initial ∷ ∀ a. Castable a Initial => a -> Initial
229+initial = cast
230+
231+transition ∷ ∀ r. { | r } -> Transition
232+transition = cast <<< css
233+
234+drag ∷ ∀ a. Castable a Drag => a -> Drag
235+drag = cast
236+
237+dragConstraints ∷ ∀ a. Castable a BoundingBox2D => a -> DragConstraints
238+dragConstraints x = cast ((cast x) ∷ BoundingBox2D)
239+
240+dragPropagation ∷ ∀ a. Castable a DragPropagation => a -> DragPropagation
241+dragPropagation = cast
242+
243+exit ∷ ∀ a. Castable a Exit => a -> Exit
244+exit = cast
245+
246+variants ∷ ∀ r. { | r } -> Variants
247+variants = cast <<< css
248+
249+variantsFromObject ∷ ∀ o. Object o -> Variants
250+variantsFromObject = cast <<< (unsafeCoerce ∷ _ -> CSS)
251+
252+layout ∷ ∀ a. Castable a Layout => a -> Layout
253+layout = cast
254+
255+data MakeVariantLabel
256+ = MakeVariantLabel
257+
258+instance makeVariantLabels' ∷
259+ (IsSymbol sym) =>
260+ MappingWithIndex MakeVariantLabel (SProxy sym) a VariantLabel where
261+ mappingWithIndex MakeVariantLabel prop' _ = VariantLabel (reflectSymbol prop')
262+
263+makeVariantLabels ∷ ∀ a b. HMapWithIndex MakeVariantLabel a b => a -> b
264+makeVariantLabels = hmapWithIndex MakeVariantLabel
265+
266+foreign import data Infinity ∷ Type
267+
268+foreign import infinity ∷ Infinity
269+
270+type AnimatePresenceProps
271+ = ( initial ∷ Boolean
272+ , custom ∷ ∀ a. a
273+ , exitBeforeEnter ∷ Boolean
274+ , onExitComplete ∷ Effect Unit
275+ , children ∷ Array JSX
276+ )
277+
278+type AnimateSharedLayoutProps
279+ = ( type ∷ AnimateSharedLayoutType
280+ , children ∷ Array JSX
281+ )
282+
283+newtype AnimateSharedLayoutType
284+ = AnimateSharedLayoutType String
285+
286+switch ∷ AnimateSharedLayoutType
287+switch = AnimateSharedLayoutType "switch"
288+
289+crossfade ∷ AnimateSharedLayoutType
290+crossfade = AnimateSharedLayoutType "crossfade"
src/Yoga/Block.purs+12
@@ -2,9 +2,11 @@ module Yoga.Block where
22
33import Prim.Row (class Union)
44import React.Basic (ReactComponent)
5+import Yoga.Block.Atom.Button as Button
56import Yoga.Block.Atom.Icon as Icon
67import Yoga.Block.Atom.Range as Range
78import Yoga.Block.Atom.Segmented as Segmented
9+import Yoga.Block.Atom.Toggle as Toggle
810import Yoga.Block.Container as Container
911import Yoga.Block.Layout.Box as Box
1012import Yoga.Block.Layout.Centre as Centre
@@ -12,11 +14,15 @@ import Yoga.Block.Layout.Cluster as Cluster
1214import Yoga.Block.Layout.Imposter as Imposter
1315import Yoga.Block.Layout.Sidebar as Sidebar
1416import Yoga.Block.Layout.Stack as Stack
17+import Yoga.Block.Layout.Switcher as Switcher
1518import Yoga.Block.Modal as Modal
1619
1720box ∷ ∀ p q. Union p q Box.Props => ReactComponent { | p }
1821box = Box.component
1922
23+button ∷ ∀ p q. Union p q Button.Props => ReactComponent { | p }
24+button = Button.component
25+
2026centre ∷ ∀ p q. Union p q Centre.Props => ReactComponent { | p }
2127centre = Centre.component
2228
@@ -46,3 +52,9 @@ sidebar = Sidebar.component
4652
4753stack ∷ ∀ p q. Union p q Stack.Props => ReactComponent { | p }
4854stack = Stack.component
55+
56+switcher ∷ ∀ p q. Union p q Switcher.Props => ReactComponent { | p }
57+switcher = Switcher.component
58+
59+toggle ∷ ∀ p q. Union p q Toggle.Props => ReactComponent { | Toggle.MandatoryProps p }
60+toggle = Toggle.component
src/Yoga/Block/Atom/Button.pursnew file+5
@@ -0,0 +1,5 @@
1+module Yoga.Block.Atom.Button
2+ ( module Yoga.Block.Atom.Button.View
3+ ) where
4+
5+import Yoga.Block.Atom.Button.View (component, Props)
src/Yoga/Block/Atom/Button/Style.purs+1−1
@@ -70,7 +70,7 @@ button =
7070 , color: str colour.highlightText
7171 , """&:focus-visible""":
7272 nest
73− { borderColor: str $ colour.background0
73+ { borderColor: str "inherit"
7474 }
7575 , """&:active""":
7676 nest
src/Yoga/Block/Atom/CodeInput/Style.purs+6−2
@@ -24,12 +24,16 @@ codeInput props = styles <>? props.css
2424 , fontSize: str "var(--s0)"
2525 , lineHeight: str "var(--s0)"
2626 , width: str $ i "calc(" (props.maxLength ?|| 10) "ch + 4.3 * var(--s-5))"
27− , padding: str "calc(var(--s-5) - 1px)"
27+ , padding: str "calc(var(--s-4) - 1px)"
2828 , color: str colour.text
2929 , "&:focus":
30+ nest
31+ { outline: none
32+ }
33+ , "&:focus-visible":
3034 nest
3135 { animation: plopAnimation <> str " 260ms ease-in"
32− , border: str $ "solid var(--s-5) " <> colour.highlight
36+ , border: str $ "solid var(--s-4) " <> colour.highlight
3337 , padding: _0
3438 }
3539 }
src/Yoga/Block/Atom/Icon/Story.purs+2
@@ -33,5 +33,7 @@ icon = do
3333 [ R.h2_ [ R.text "Icon" ]
3434 , element Icon.component { icon: SVGIcon.on }
3535 , element Icon.component { icon: SVGIcon.off }
36+ , element Icon.component { icon: SVGIcon.sun }
37+ , element Icon.component { icon: SVGIcon.moon }
3638 ]
3739 ]
src/Yoga/Block/Atom/Icon/Style.purs+3−5
@@ -19,9 +19,7 @@ span props =
1919 css
2020 { "--stroke-colour": (props.stroke <|> props.colour) ?|| (str colour.text)
2121 , "--fill-colour": (props.fill <|> props.colour) ?|| (str "transparent")
22− , display: inlineFlex
23− , justifyContent: center
24− , alignItems: center
22+ , display: inlineBlock
2523 , margin: _0
2624 , padding: _0
2725 , width
@@ -36,6 +34,6 @@ span props =
3634 }
3735 }
3836 where
39− width = (props.width <|> props.size) ?|| (str "auto")
37+ width = (props.width <|> props.size) ?|| (str "1em")
4038
41− height = (props.height <|> props.size) ?|| (str "1ch")
39+ height = (props.height <|> props.size) ?|| (str "1em")
src/Yoga/Block/Atom/Input/Types.purs+4−3
@@ -4,7 +4,7 @@ import Prelude
44
55-- No support for "button" because of the dedicated
66-- HTML Element
7−data HTMLInput
7+data HTMLInputType
88 = Checkbox
99 | Color
1010 | Date
@@ -26,9 +26,10 @@ data HTMLInput
2626 | Time
2727 | Url
2828 | Week
29−derive instance eqHTMLInput ∷ Eq HTMLInput
3029
31−toString ∷ HTMLInput -> String
30+derive instance eqHTMLInput ∷ Eq HTMLInputType
31+
32+toString ∷ HTMLInputType -> String
3233toString = case _ of
3334 Checkbox -> "checkbox"
3435 Color -> "color"
src/Yoga/Block/Atom/Input/View.purs+30−40
@@ -2,19 +2,21 @@ module Yoga.Block.Atom.Input.View where
22
33import Yoga.Prelude.View
44import Data.String.NonEmpty (NonEmptyString)
5+import Data.Symbol (SProxy(..))
56import Foreign.Object (Object)
67import Foreign.Object as Object
78import Framer.Motion as M
89import React.Basic.DOM (css)
910import React.Basic.DOM as R
1011import React.Basic.Hooks as React
11−import Unsafe.Coerce (unsafeCoerce)
12+import Record.Builder as RB
1213import Web.HTML.HTMLInputElement as InputElement
1314import Yoga.Block.Atom.Icon as Icon
1415import Yoga.Block.Atom.Input.Style as Style
15−import Yoga.Block.Atom.Input.Types (HTMLInput)
16−import Yoga.Block.Atom.Input.Types as HTMLInput
16+import Yoga.Block.Atom.Input.Types (HTMLInputType)
17+import Yoga.Block.Atom.Input.Types as InputTypes
1718import Yoga.Block.Atom.Input.View.Container (rawContainer)
19+import Yoga.Block.Atom.Input.View.HTMLInput as HTMLInput
1820import Yoga.Block.Atom.Input.View.Label as Label
1921import Yoga.Block.Icon.SVG as SVGIcon
2022
@@ -22,13 +24,10 @@ type PropsF f =
2224 ( leading ∷ f JSX
2325 , trailing ∷ f JSX
2426 , label ∷ f NonEmptyString
25− , type ∷ f HTMLInput
27+ , type ∷ f HTMLInputType
2628 | Style.Props f (InputPropsF f ())
2729 )
2830
29−coerceProps ∷ { | PropsOptional } -> { | Props }
30−coerceProps = unsafeCoerce
31−
3231type Props =
3332 PropsF Id
3433
@@ -50,23 +49,6 @@ mkLeftIcon icon =
5049 }
5150 ]
5251
53−inputComponent ∷ ∀ p q. Union p q Props => ReactComponent { | p }
54−inputComponent = rawInput
55−
56−inputComponentOptional ∷ ∀ p q. Union p q PropsOptional => ReactComponent { | p }
57−inputComponentOptional = rawInput
58−
59−rawInput ∷ ∀ p. ReactComponent { | p }
60−rawInput =
61− mkForwardRefComponent "Input" do
62− \(props ∷ { | PropsOptional }) ref -> React.do
63− let
64− result = inputWrapper [ input ]
65− inputWrapper = div </* { className: "ry-input-wrapper", css: Style.inputWrapper }
66− input = emotionInput ref inputProps { className: "ry-input", css: Style.input }
67− inputProps = props { type = HTMLInput.toString <$> props.type }
68− pure result
69−
7052rawComponent ∷ ∀ p. ReactComponent (Record p)
7153rawComponent =
7254 mkForwardRefComponent "InputContainer" do
@@ -110,7 +92,7 @@ rawComponent =
11092 leading ∷ Maybe JSX
11193 leading =
11294 opToMaybe props.leading
113− <|> if (props.type <#> (_ == HTMLInput.Search)) ?|| false then
95+ <|> if (props.type <#> (_ == InputTypes.Search)) ?|| false then
11496 Just $ mkLeftIcon SVGIcon.magnifyingGlass
11597 else
11698 Nothing
@@ -131,20 +113,28 @@ rawComponent =
131113 setHasValue (v /= "")
132114 )
133115 onFocus = handler preventDefault (const $ unless hasFocus $ setHasFocus true)
116+ inputProps =
117+ props
118+ { onFocus = composeHandler onFocus props.onFocus
119+ , onBlur = composeHandler onBlur props.onBlur
120+ , ref = ref
121+ , placeholder = maybePlaceholder # maybeToOp
122+ , _aria =
123+ if props.label # opToMaybe # isJust then
124+ aria # Object.insert "labelledby" labelId
125+ else
126+ aria
127+ }
134128 theInput =
135− inputComponentOptional
136− </> ( (cast ∷ _ -> { | PropsOptional })
137− $ props
138− { onFocus = composeHandler onFocus props.onFocus
139− , onBlur = composeHandler onBlur props.onBlur
140− , ref = ref
141− , placeholder = maybePlaceholder # maybeToOp
142− , _aria =
143− if props.label # opToMaybe # isJust then
144− aria # Object.insert "labelledby" labelId
145− else
146− aria
147− }
129+ HTMLInput.componentOptional
130+ </> ( (cast ∷ _ -> { | HTMLInput.PropsOptional })
131+ ( inputProps
132+ # RB.build
133+ ( RB.delete (SProxy ∷ _ "leading")
134+ >>> RB.delete (SProxy ∷ _ "label")
135+ >>> RB.delete (SProxy ∷ _ "trailing")
136+ )
137+ )
148138 )
149139 inputContainer =
150140 rawContainer
@@ -159,7 +149,7 @@ rawComponent =
159149 ]
160150 pure
161151 $ case props.type # opToMaybe of
162− Just HTMLInput.Password -> password </> props
152+ Just InputTypes.Password -> password </> props
163153 _ -> case maybeLabelText of
164154 Nothing -> inputContainer
165155 Just labelText ->
@@ -221,7 +211,7 @@ password =
221211 , R.div' </ {}
222212 /> [ emotionInput
223213 ref
224− (props { type = HTMLInput.toString <$> props.type })
214+ (props { type = InputTypes.toString <$> props.type })
225215 { className: "ry-input"
226216 , css: Style.input
227217 , type: if hidePassword then "password" else "text"
src/Yoga/Block/Atom/Input/View/Container.purs+47−42
@@ -10,33 +10,33 @@ import React.Basic.DOM (CSS, css)
1010import React.Basic.Emotion (Style)
1111import Yoga.Block.Atom.Input.Style as Style
1212
13−type PropsF f =
14− ( css ∷ f Style
15− , isInvalid ∷ f Boolean
16− | Style.Props f (MandatoryProps ())
17− )
13+type PropsF f
14+ = ( css ∷ f Style
15+ , isInvalid ∷ f Boolean
16+ | Style.Props f (MandatoryProps ())
17+ )
1818
19−type MandatoryProps r =
20− ( children ∷ Array JSX
21− , hasFocus ∷ Boolean
22− | r
23− )
19+type MandatoryProps r
20+ = ( children ∷ Array JSX
21+ , hasFocus ∷ Boolean
22+ | r
23+ )
2424
25−type Props =
26− PropsF Id
25+type Props
26+ = PropsF Id
2727
28−type PropsOptional =
29− PropsF OptionalProp
28+type PropsOptional
29+ = PropsF OptionalProp
3030
3131component ∷ ∀ p q. Union p q Props => ReactComponent { | MandatoryProps p }
3232component = rawContainer
3333
34−type Propski =
35− { css ∷ OptionalProp Style
36− , hasFocus ∷ Boolean
37− , isInvalid ∷ OptionalProp Boolean
38− , children ∷ Array JSX
39− }
34+type Propski
35+ = { css ∷ OptionalProp Style
36+ , hasFocus ∷ Boolean
37+ , isInvalid ∷ OptionalProp Boolean
38+ , children ∷ Array JSX
39+ }
4040
4141rawContainer ∷ ∀ p. ReactComponent { | p }
4242rawContainer =
@@ -52,11 +52,11 @@ rawContainer =
5252 { className: "ry-input-container"
5353 , css: Style.inputContainer props
5454 , _data:
55− props.isInvalid
56− # foldMap \isInvalid ->
57− Object.fromHomogeneous
58− { "invalid": show isInvalid
59− }
55+ props.isInvalid
56+ # foldMap \isInvalid ->
57+ Object.fromHomogeneous
58+ { "invalid": show isInvalid
59+ }
6060 , ref
6161 }
6262 /> props.children
@@ -64,10 +64,14 @@ rawContainer =
6464
6565drawPathUntil ∷ Int -> Array Point -> String
6666drawPathUntil idx thePath = do
67− let fn { x, y } = i x "%" " " y "%"
68− let firstFew = Array.take idx thePath
69− let lastFew = Array.drop idx thePath $> (Array.last firstFew # fromMaybe' \_ -> unsafeCrashWith "ogod")
70− let rendered = intercalate "," $ fn <$> (firstFew <> lastFew)
67+ let
68+ fn { x, y } = i x "%" " " y "%"
69+ let
70+ firstFew = Array.take idx thePath
71+ let
72+ lastFew = Array.drop idx thePath $> (Array.last firstFew # fromMaybe' \_ -> unsafeCrashWith "ogod")
73+ let
74+ rendered = intercalate "," $ fn <$> (firstFew <> lastFew)
7175 i "polygon(" rendered ")"
7276
7377path ∷ Array Point
@@ -83,6 +87,7 @@ mkPath borderX borderY = do
8387 , {- ⌝ -} p (100 - borderX) borderY
8488 , {- ⌜ -} p borderX borderY
8589 ]
90+
8691 outside =
8792 [ {-⌜ -} p 0 0
8893 , {-⌞ -} p 0 100
@@ -98,8 +103,8 @@ mkPath borderX borderY = do
98103 ]
99104 inside <> outside <> (Array.reverse inside)
100105 where
101− p ∷ Int -> Int -> Point
102− p x y = { x, y }
106+ p ∷ Int -> Int -> Point
107+ p x y = { x, y }
103108
104109containerVariantLabels ∷
105110 { blurred ∷ M.VariantLabel
@@ -113,18 +118,18 @@ containerVariants ∷
113118 }
114119containerVariants =
115120 { focussed:
116− css
117− { clipPath
118− , transition: { duration: 0.6 }
119− }
121+ css
122+ { clipPath
123+ , transition: { duration: 0.6 }
124+ }
120125 , blurred:
121− css
122− { clipPath:
123− drawPathUntil (Array.length path + 1) path
124− }
126+ css
127+ { clipPath:
128+ drawPathUntil (Array.length path + 1) path
129+ }
125130 }
126131 where
127− clipPath = 6 Array... (Array.length path) <#> \ln -> drawPathUntil ln path
132+ clipPath = 6 Array... (Array.length path) <#> \ln -> drawPathUntil ln path
128133
129−type Point =
130− { x ∷ Int, y ∷ Int }
134+type Point
135+ = { x ∷ Int, y ∷ Int }
src/Yoga/Block/Atom/Input/View/HTMLInput.pursnew file+40
@@ -0,0 +1,40 @@
1+module Yoga.Block.Atom.Input.View.HTMLInput
2+ ( Props
3+ , PropsF
4+ , PropsOptional
5+ , component
6+ , componentOptional
7+ ) where
8+
9+import Yoga.Prelude.View
10+import Yoga.Block.Atom.Input.Style as Style
11+import Yoga.Block.Atom.Input.Types (HTMLInputType)
12+import Yoga.Block.Atom.Input.Types as HTMLInput
13+
14+type PropsF f =
15+ ( type ∷ f HTMLInputType
16+ | Style.Props f (InputPropsF f ())
17+ )
18+
19+type Props =
20+ PropsF Id
21+
22+type PropsOptional =
23+ PropsF OptionalProp
24+
25+component ∷ ∀ p q. Union p q Props => ReactComponent { | p }
26+component = rawComponent
27+
28+componentOptional ∷ ∀ p q. Union p q PropsOptional => ReactComponent { | p }
29+componentOptional = rawComponent
30+
31+rawComponent ∷ ∀ p. ReactComponent { | p }
32+rawComponent =
33+ mkForwardRefComponent "Input" do
34+ \(props ∷ { | PropsOptional }) ref -> React.do
35+ let
36+ result = inputWrapper [ input ]
37+ inputWrapper = div </* { className: "ry-input-wrapper", css: Style.inputWrapper }
38+ input = emotionInput ref inputProps { className: "ry-input", css: Style.input }
39+ inputProps = props { type = HTMLInput.toString <$> props.type }
40+ pure result
src/Yoga/Block/Atom/Input/View/Label.purs+30−25
@@ -11,18 +11,18 @@ import React.Basic.Hooks (reactComponent)
1111import React.Basic.Hooks as React
1212import Yoga.Block.Atom.Input.Style as Style
1313
14−type Props =
15− { onClickLargeLabel ∷ EventHandler
16− , isRequired ∷ Boolean
17− , isInvalid ∷ Boolean
18− , isFocussed ∷ Boolean
19− , renderLargeLabel ∷ Boolean
20− , inputRef ∷ NodeRef
21− , parentRef ∷ NodeRef
22− , labelId ∷ String
23− , inputId ∷ String
24− , labelText ∷ NonEmptyString
25− }
14+type Props
15+ = { onClickLargeLabel ∷ EventHandler
16+ , isRequired ∷ Boolean
17+ , isInvalid ∷ Boolean
18+ , isFocussed ∷ Boolean
19+ , renderLargeLabel ∷ Boolean
20+ , inputRef ∷ NodeRef
21+ , parentRef ∷ NodeRef
22+ , labelId ∷ String
23+ , inputId ∷ String
24+ , labelText ∷ NonEmptyString
25+ }
2626
2727component ∷ ReactComponent Props
2828component =
@@ -42,6 +42,7 @@ component =
4242 -- UI
4343 let
4444 text = R.text $ NonEmptyString.toString props.labelText
45+
4546 result =
4647 container
4748 [ sharedLayout
@@ -51,8 +52,11 @@ component =
5152 ]
5253 ]
5354 ]
55+
5456 container = div </* { className: "ry-input-label-container", css: Style.labelContainer }
57+
5558 sharedLayout = M.animateSharedLayout </ { type: M.switch }
59+
5660 labelContainer =
5761 guard (inputBbox /= zero && parentBbox /= zero)
5862 $ M.div
@@ -60,23 +64,24 @@ component =
6064 , layout: M.layout true
6165 , layoutId: M.layoutId "ry-input-label"
6266 , css:
63− if props.renderLargeLabel then
64− Style.labelLarge
65− { left: inputBbox.left - parentBbox.left
66− , width: inputBbox.width
67− , top: inputBbox.top - parentBbox.top
68− }
69− else
70− Style.labelSmall
67+ if props.renderLargeLabel then
68+ Style.labelLarge
69+ { left: inputBbox.left - parentBbox.left
70+ , width: inputBbox.width
71+ , top: inputBbox.top - parentBbox.top
72+ }
73+ else
74+ Style.labelSmall
7175 , transition: M.transition { duration: 0.18, ease: "easeOut" }
7276 , _data:
73− Object.fromHomogeneous
74− { "has-focus": show props.isFocussed
75− , "invalid": show props.isInvalid
76− , "required": show props.isRequired
77− }
77+ Object.fromHomogeneous
78+ { "has-focus": show props.isFocussed
79+ , "invalid": show props.isInvalid
80+ , "required": show props.isRequired
81+ }
7882 , initial: M.initial false
7983 }
84+
8085 labelSpan =
8186 M.span
8287 </ { onClick: props.onClickLargeLabel
src/Yoga/Block/Atom/Range/Style.purs+2−2
@@ -90,7 +90,7 @@ track =
9090 }
9191
9292disabled ∷ Style
93−disabled = css { backgroundColor: str colour.background30 }
93+disabled = css { backgroundColor: str colour.backgroundLayer2 }
9494
9595filled ∷ Style
9696filled =
@@ -106,5 +106,5 @@ notFilled =
106106 <> css
107107 { width: str "calc((1 - (var(--val)/var(--max))) * 100%)"
108108 , right: _0
109− , backgroundColor: str colour.background40
109+ , backgroundColor: str colour.backgroundLayer4
110110 }
src/Yoga/Block/Atom/Segmented/Style.purs+9−9
@@ -29,11 +29,11 @@ segmented = styles
2929 , display: flex
3030 , flex: str "1"
3131 , minHeight: str "min-content"
32− , background: str colour.background10
32+ , background: str colour.backgroundLayer3
3333 , boxShadow: str "inset 0 1 0 rgba(0,0,0,0.1)"
34− , borderRadius: var "--s-1"
35− , border: str $ i "1px solid " colour.background15
36− , borderBottom: str $ i "1px solid " colour.background20
34+ , borderRadius: str "calc(var(--s-1) * 0.8)"
35+ , border: str $ i "1px solid " colour.interfaceBackground
36+ , borderBottom: str $ i "1px solid " colour.interfaceBackgroundShadow
3737 , padding: _0
3838 , overflow: scroll
3939 , userSelect: none
@@ -43,8 +43,8 @@ activeElement ∷ Style
4343activeElement =
4444 css
4545 { position: absolute
46− , borderRadius: str "calc(var(--s-1) * 0.75)"
47− , background: str colour.interfaceBackground
46+ , borderRadius: str "calc(var(--s-1) * 0.8)"
47+ , background: str colour.backgroundLayer5
4848 , borderTop: str $ i "1px solid " colour.interfaceBackgroundHighlight
4949 , borderBottom: str $ i "1px solid " colour.interfaceBackgroundShadow
5050 , boxShadow: str "0 1px 2px rgba(20,20,20,0.67)"
@@ -61,11 +61,11 @@ button { isFirst, isLast } =
6161 , border: none
6262 , padding: _0
6363 , fontSize: str "var(--s0)"
64− , marginLeft: str if isFirst then "1px" else "0"
65− , marginRight: str if isLast then "1px" else "0"
64+ , marginLeft: _0
65+ , marginRight: _0
6666 , boxSizing: borderBox
6767 , zIndex: str "3"
68− , minWidth: var "--s3"
68+ , minWidth: var "--s2"
6969 , "&:active": nest { outline: str "0" }
7070 , "&:focus": nest { outline: none }
7171 , "&:focus > .ry-segmented-button__content":
src/Yoga/Block/Atom/Segmented/View.purs+15−15
@@ -8,11 +8,9 @@ import Data.Traversable (traverse)
88import Data.TwoOrMore (TwoOrMore)
99import Data.TwoOrMore as TwoOrMore
1010import Effect.Aff (delay)
11+import Effect.Class.Console (log)
1112import Effect.Unsafe (unsafePerformEffect)
1213import Foreign.Object as Object
13−import Yoga.Block.Hook.Key as Key
14−import Yoga.Block.Hook.UseResize (useResize)
15−import Yoga.Block.Hook.UseKeyDown (useKeyDown)
1614import Math as Math
1715import React.Basic.DOM (css)
1816import React.Basic.DOM as R
@@ -23,15 +21,18 @@ import React.Basic.Hooks.Aff (useAff)
2321import Web.HTML.HTMLElement as HTMLElement
2422import Yoga.Block.Atom.Segmented.Style as Style
2523import Yoga.Block.Atom.Segmented.View.ActiveIndicator as ActiveIndicator
24+import Yoga.Block.Hook.Key as Key
25+import Yoga.Block.Hook.UseKeyDown (useKeyDown)
26+import Yoga.Block.Hook.UseResize (useResize)
2627
27−type Item
28− = { id ∷ String, value ∷ String }
28+type Item =
29+ { id ∷ String, value ∷ String }
2930
30−type Props
31− = { buttonContents ∷ TwoOrMore Item
32− , activeIndex ∷ Int
33− , updateActiveIndex ∷ Int -> Effect Unit
34− }
31+type Props =
32+ { buttonContents ∷ TwoOrMore Item
33+ , activeIndex ∷ Int
34+ , updateActiveIndex ∷ Int -> Effect Unit
35+ }
3536
3637component ∷ ReactComponent Props
3738component =
@@ -68,13 +69,14 @@ component =
6869 -------------------------------------------
6970 -- Ensure redraw on window resize
7071 windowSize <- useResize
71− useAff { windowSize } do
72+ useAff windowSize.width do
7273 delay
7374 if Math.abs (windowWidth - windowSize.width) < 10.0 then
7475 100.0 # Milliseconds
7576 else
7677 10.0 # Milliseconds
7778 liftEffect do -- force rerender
79+ log "Forcing rerender"
7880 refs <- traverse (const createRef) buttonContents
7981 setItemRefs (Just refs)
8082 setWindowWidth windowSize.width
@@ -85,10 +87,8 @@ component =
8587 refsAndContents = TwoOrMore.zip buttonContents <$> itemRefs
8688 contentToChild ∷ Int -> (Item /\ Ref (Nullable Node)) -> JSX
8789 contentToChild idx ({ id, value } /\ ref) = do
88− let
89− isLast = idx + 1 == TwoOrMore.length buttonContents
90− let
91− isFirst = idx == 0
90+ let isLast = idx + 1 == TwoOrMore.length buttonContents
91+ let isFirst = idx == 0
9292 button
9393 </* { key: show idx
9494 , ref
src/Yoga/Block/Atom/Segmented/View/ActiveIndicator.purs+57−76
@@ -9,7 +9,6 @@ import Effect.Unsafe (unsafePerformEffect)
99import Foreign.Object as Object
1010import Framer.Motion (VariantLabel)
1111import Framer.Motion as Motion
12−import Yoga.Block.Hook.Scroll (useScrollPosition)
1312import Literals.Undefined (undefined)
1413import MotionValue (useMotionValue)
1514import MotionValue as MotionValue
@@ -20,13 +19,14 @@ import React.Basic.Hooks (reactComponent)
2019import React.Basic.Hooks as React
2120import Unsafe.Coerce (unsafeCoerce)
2221import Yoga.Block.Atom.Segmented.Style as Style
22+import Yoga.Block.Hook.Scroll (useScrollPosition)
2323
24−type Props
25− = { activeItemRefs ∷ TwoOrMore (Ref (Nullable Node))
26− , activeItemIndex ∷ Int
27− , updateActiveIndex ∷ Int -> Effect Unit
28− , windowWidth ∷ Number
29− }
24+type Props =
25+ { activeItemRefs ∷ TwoOrMore (Ref (Nullable Node))
26+ , activeItemIndex ∷ Int
27+ , updateActiveIndex ∷ Int -> Effect Unit
28+ , windowWidth ∷ Number
29+ }
3030
3131component ∷ ReactComponent Props
3232component =
@@ -42,16 +42,14 @@ component =
4242 _ <-
4343 runMaybeT do
4444 rawStyles <- traverse getStyle props.activeItemRefs
45− let
46− styles = rawStyles <#> \s -> s { left = s.left + scrollX }
45+ let styles = rawStyles <#> \s -> s { left = s.left + scrollX }
4746 unless (maybeAnimationVariants == Just styles) do
4847 setVariants (Just styles) # lift
4948 mempty
5049 useLayoutEffect maybeDragX do
5150 case maybeDragX, maybeAnimationVariants of
5251 Just x, Just animationVariants -> do
53− let
54− { left, width } = handleDrag { activeItemIndex: props.activeItemIndex, animationVariants, x }
52+ let { left, width } = handleDrag { activeItemIndex: props.activeItemIndex, animationVariants, x }
5553 activeLeft # MotionValue.set left
5654 activeWidth # MotionValue.set width
5755 _, _ -> mempty
@@ -61,22 +59,22 @@ component =
6159 variants = case maybeAnimationVariants of
6260 Just animationVariants ->
6361 animationVariants
64− # foldMapWithIndex (\i s -> Object.singleton (show i) (css s))
62+ # foldMapWithIndex
63+ (\i s -> Object.singleton (show i) (css s))
6564 # Motion.variantsFromObject
66− Nothing -> (cast undefined) ∷ Motion.Variants
65+ Nothing -> cast undefined
6766 pure $ maybeAnimationVariants
6867 # foldMap \animationVariants ->
6968 Emotion.elementKeyed Motion.div
7069 { css: Style.activeElement
70+ , layout: Motion.layout true
7171 , key: show props.windowWidth -- to force rerender
7272 , variants
7373 , className: "ry-active-segmented-element"
74− , initial: Motion.initial (indexToVariant props.activeItemIndex)
74+ , initial: Motion.initial $ indexToVariant props.activeItemIndex
7575 , drag: Motion.drag "x"
7676 , dragMomentum: Motion.dragMomentum false
7777 , animate: Motion.animate $ indexToVariant props.activeItemIndex
78− , layout: Motion.layout true
79− , whileTap: Motion.whileTap $ css { scale: 0.9 }
8078 , style:
8179 css
8280 { left: activeLeft
@@ -91,11 +89,17 @@ component =
9189 , onDragEnd:
9290 Motion.onDragEnd \_ pi -> do
9391 let
94− x = maybeDragX # fromMaybe' \_ -> unsafeCrashWith "no x should not happen"
95− let
96− newIdx = findOverlapping props.activeItemIndex animationVariants x
97− let
98− v = animationVariants TwoOrMore.!! newIdx # fromMaybe' \_ -> unsafeCrashWith "omg"
92+ x =
93+ maybeDragX
94+ # fromMaybe' \_ -> unsafeCrashWith "no x"
95+ newIdx =
96+ findOverlapping
97+ props.activeItemIndex
98+ animationVariants
99+ x
100+ v =
101+ animationVariants TwoOrMore.!! newIdx
102+ # fromMaybe' \_ -> unsafeCrashWith "omg"
99103 setDragX Nothing
100104 activeLeft # MotionValue.set v.left
101105 activeWidth # MotionValue.set v.width
@@ -104,7 +108,10 @@ component =
104108 , dragElastic: Motion.dragElastic false
105109 , transition:
106110 Motion.transition
107− { type: "tween", duration: if isJust maybeDragX then 0.0 else 0.167, ease: "easeOut" }
111+ { type: "tween"
112+ , duration: if isJust maybeDragX then 0.0 else 0.167
113+ , ease: "easeOut"
114+ }
108115 , _aria: Object.fromHomogeneous { hidden: "true" }
109116 }
110117
@@ -123,23 +130,18 @@ getStyle itemRef = do
123130indexToVariant ∷ Int -> VariantLabel
124131indexToVariant = show >>> unsafeCoerce
125132
126−type BBox
127− = { top ∷ Number, left ∷ Number, width ∷ Number, height ∷ Number }
133+type BBox =
134+ { top ∷ Number, left ∷ Number, width ∷ Number, height ∷ Number }
128135
129136findOverlapping ∷ Int -> TwoOrMore BBox -> Number -> Int
130137findOverlapping activeIndex styles x =
131138 fromMaybe activeIndex do
132139 curr <- styles TwoOrMore.!! activeIndex
133− let
134− fst = TwoOrMore.head styles
135− let
136− lst = TwoOrMore.last styles
137− let
138− inside e = (e.left < x) && (e.left + e.width) >= x
139− let
140− tooFarLeft = MZ.guard (x <= fst.left + fst.width) $> 0
141− let
142− tooFarRight = MZ.guard (x >= lst.left) $> TwoOrMore.length styles - 1
140+ let fst = TwoOrMore.head styles
141+ let lst = TwoOrMore.last styles
142+ let inside e = (e.left < x) && (e.left + e.width) >= x
143+ let tooFarLeft = MZ.guard (x <= fst.left + fst.width) $> 0
144+ let tooFarRight = MZ.guard (x >= lst.left) $> TwoOrMore.length styles - 1
143145 TwoOrMore.findIndex inside styles <|> tooFarLeft <|> tooFarRight
144146
145147handleDrag ∷
@@ -149,16 +151,11 @@ handleDrag ∷
149151 } ->
150152 { left ∷ Number, width ∷ Number }
151153handleDrag { x, activeItemIndex, animationVariants } = do
152− let
153− idx = findOverlapping activeItemIndex animationVariants x
154− let
155− av = animationVariants
156− let
157− firstVariant = av # TwoOrMore.head
158− let
159− lastVariant = av # TwoOrMore.last
160− let
161− baseVariant = av TwoOrMore.!! idx # fromMaybe' \_ -> unsafeCrashWith "shit"
154+ let idx = findOverlapping activeItemIndex animationVariants x
155+ let av = animationVariants
156+ let firstVariant = av # TwoOrMore.head
157+ let lastVariant = av # TwoOrMore.last
158+ let baseVariant = av TwoOrMore.!! idx # fromMaybe' \_ -> unsafeCrashWith "shit"
162159 let
163160 closestVariant =
164161 if x >= (baseVariant.left + (baseVariant.width / 2.0)) then
@@ -172,41 +169,25 @@ handleDrag { x, activeItemIndex, animationVariants } = do
172169 else
173170 closestVariant /\ baseVariant
174171 -- Total
175− let
176− rangeStart = smaller.left + (smaller.width / 2.0)
177− let
178− rangeEnd = greater.left + (greater.width / 2.0)
179− let
180− range = rangeEnd - rangeStart
181− let
182− ratio = ((x - rangeStart) / range)
183− let
184− interpolatedWidth = (greater.width * ratio) + smaller.width * (1.0 - ratio)
172+ let rangeStart = smaller.left + (smaller.width / 2.0)
173+ let rangeEnd = greater.left + (greater.width / 2.0)
174+ let range = rangeEnd - rangeStart
175+ let ratio = ((x - rangeStart) / range)
176+ let interpolatedWidth = (greater.width * ratio) + smaller.width * (1.0 - ratio)
185177 -- Right
186− let
187− rangeStartRight = smaller.left + smaller.width
188− let
189− rangeEndRight = greater.left + greater.width
190− let
191− rangeRight = rangeEndRight - rangeStartRight
192− let
193− ratioRight = ((x + (interpolatedWidth / 2.0) - rangeStartRight) / rangeRight)
178+ let rangeStartRight = smaller.left + smaller.width
179+ let rangeEndRight = greater.left + greater.width
180+ let rangeRight = rangeEndRight - rangeStartRight
181+ let ratioRight = ((x + (interpolatedWidth / 2.0) - rangeStartRight) / rangeRight)
194182 -- Left
195− let
196− rangeStartLeft = smaller.left
197− let
198− rangeEndLeft = greater.left
199− let
200− rangeLeft = rangeEndLeft - rangeStartLeft
201− let
202− ratioLeft = (((x - (interpolatedWidth / 2.0)) - rangeStartLeft) / rangeLeft)
183+ let rangeStartLeft = smaller.left
184+ let rangeEndLeft = greater.left
185+ let rangeLeft = rangeEndLeft - rangeStartLeft
186+ let ratioLeft = (((x - (interpolatedWidth / 2.0)) - rangeStartLeft) / rangeLeft)
203187 -- Individual
204− let
205− left = rangeStartLeft + (ratioLeft * rangeLeft)
206− let
207− right = rangeStartRight + (ratioRight * rangeRight)
208− let
209− width = right - left
188+ let left = rangeStartLeft + (ratioLeft * rangeLeft)
189+ let right = rangeStartRight + (ratioRight * rangeRight)
190+ let width = right - left
210191 if x < firstVariant.left then
211192 { left: firstVariant.left, width: firstVariant.width }
212193 else
src/Yoga/Block/Atom/Toggle.purs+1−1
@@ -2,4 +2,4 @@ module Yoga.Block.Atom.Toggle
22 ( module Yoga.Block.Atom.Toggle.View
33 ) where
44
5−import Yoga.Block.Atom.Toggle.View (component, Props)
5+import Yoga.Block.Atom.Toggle.View (component, Props, MandatoryProps)
src/Yoga/Block/Atom/Toggle/Story.purs+4−7
@@ -65,10 +65,7 @@ toggle = do
6565 Color.hsl 260.0 0.7 0.45
6666 }
6767 pure
68− $ case theme of
69− Nothing -> element Block.container { content }
70− Just themeVariant ->
71− element Block.container
72− { content
73− , themeVariant: themeVariant
74− }
68+ $ element Block.container
69+ { content
70+ , themeVariant: theme
71+ }
src/Yoga/Block/Atom/Toggle/Style.purs+24−25
@@ -14,26 +14,36 @@ button ∷ Style
1414button =
1515 css
1616 { position: relative
17− , background: str colour.inputBackground
17+ , "&:focus": nest { outline: str "none" }
1818 , border: str $ "1px solid " <> colour.inputBorder
19+ , "&:focus-visible":
20+ nest
21+ { boxShadow: str $ "0 0 0 var(--s-4) " <> colour.highlight
22+ }
1923 , borderRadius: str "calc(var(--s2) / 2)"
2024 , height: var "--s2"
21− , width: str "calc(1.15 * var(--s3))"
25+ , width: str "calc(var(--s2) + var(--s1))"
2226 , margin: _0
2327 , padding: _0
2428 }
2529
30+toggleLeft ∷ String
31+toggleLeft = "calc(var(--s-2) * 0.3)"
32+
33+dragWidthDelta ∷ Number
34+dragWidthDelta = 10.0
35+
2636theToggle ∷ Style
2737theToggle =
2838 css
29− { width: str "calc(var(--s2) * 0.8)"
30− , height: str "calc(var(--s2) * 0.8)"
39+ { width: str "calc(var(--s2) * 0.85)"
40+ , height: str "calc(var(--s2) * 0.85)"
3141 , background: str $ colour.interfaceBackground
3242 , border: none
3343 , borderRadius: str $ "calc(var(--s2) / 2)"
3444 , position: absolute
35− , top: str "3px"
36− , left: str "3px"
45+ , top: str "calc(var(--s-2) * 0.35)"
46+ , left: str toggleLeft
3747 , margin: _0
3848 , boxShadow: str "0 0.5px 3px rgba(0,0,0,0.50)"
3949 }
@@ -45,11 +55,16 @@ toggleTextContainer =
4555 , border: none
4656 , fontWeight: str "bold"
4757 , position: absolute
48− , top: _0
49− , fontSize: str "calc(0.6 * var(--s1))"
50− , lineHeight: var "--s2"
58+ , top: str "1px"
59+ , fontSize: str "calc(var(--s2)*0.5)"
60+ , lineHeight: str "calc(var(--s2)*0.5)"
61+ , textAlign: center
5162 , height: var "--s2"
5263 , display: flex
64+ , justifyContent: center
65+ , alignItems: center
66+ , margin: _0
67+ , padding: _0
5368 }
5469
5570successTextColour ∷ StyleProperty
@@ -75,19 +90,3 @@ toggleText =
7590 { color: successTextColour
7691 }
7792 }
78−
79−inputDisabled ∷ Style
80−inputDisabled =
81− css
82− { "input[type=toggle]::-webkit-slider-thumb": nested thumbStyleDisabled
83− , "input[type=toggle]::-moz-toggle-thumb": nested thumbStyleDisabled
84− }
85− where
86− thumbStyleDisabled =
87− css
88− { background: str "#fcfcfc"
89− , boxShadow: str "0 calc(var(--s-4)/2) var(--s-3) rgba(88,88,88,0.2)"
90− }
91−
92−disabled ∷ Style
93−disabled = css { backgroundColor: str colour.background30 }
src/Yoga/Block/Atom/Toggle/View.purs+75−47
@@ -1,4 +1,9 @@
1−module Yoga.Block.Atom.Toggle.View (component, MandatoryProps, Props, PropsF) where
1+module Yoga.Block.Atom.Toggle.View
2+ ( component
3+ , MandatoryProps
4+ , Props
5+ , PropsF
6+ ) where
27
38import Yoga.Prelude.View
49import Color as Color
@@ -40,6 +45,7 @@ data DragState
4045 = NotDragging
4146 | Dragging { startX ∷ Number, currentX ∷ Number }
4247 | DragDone { startX ∷ Number, endX ∷ Number }
48+
4349derive instance eqDragState ∷ Eq DragState
4450
4551instance showDragState ∷ Show DragState where
@@ -85,6 +91,7 @@ rawComponent =
8591 { left: { backgroundColor: (Emotion.str <<< Color.cssStringRGBA <$> props.backgroundLeft) ?|| Emotion.str colour.inputBackground }
8692 , right: { backgroundColor: (Emotion.str <<< Color.cssStringRGBA <$> props.backgroundRight) ?|| Emotion.str colour.success }
8793 }
94+
8895 buttonVariant = Motion.makeVariantLabels buttonVariants
8996 -- components
9097 let
@@ -110,16 +117,17 @@ rawComponent =
110117 ]
111118 , toggle
112119 ]
120+
113121 container =
114122 Motion.button
115− </* { className: "ry-toggle"
116− , css: Style.button
123+ </* { className: "ry-toggle" <>? props.className
124+ , css: Style.button <>? props.css
117125 , transition: Motion.transition { type: "tween", duration: 0.33, ease: "easeOut" }
118126 , variants: Motion.variants buttonVariants
119127 , animate:
120− Motion.animate case props.togglePosition of
121− ToggleIsRight -> buttonVariant.right
122− ToggleIsLeft -> buttonVariant.left
128+ Motion.animate case props.togglePosition of
129+ ToggleIsRight -> buttonVariant.right
130+ ToggleIsLeft -> buttonVariant.left
123131 , value: show props.togglePosition
124132 , onClick: handler preventDefault \_ -> props.setTogglePosition (flipToggle props.togglePosition)
125133 , style: props.style
@@ -128,21 +136,25 @@ rawComponent =
128136 , _aria: Object.singleton "checked" "switch"
129137 , ref: buttonRef
130138 }
139+
131140 textContainer =
132141 div
133142 </* { className: "ry-toggle-text"
134143 , css: Style.toggleTextContainer
135144 }
145+
136146 textOnContainer =
137147 div
138148 </* { className: "ry-toggle-text-on"
139149 , css: Style.toggleText
140150 }
151+
141152 textOffContainer =
142153 div
143154 </* { className: "ry-toggle-text-off"
144155 , css: Style.toggleText
145156 }
157+
146158 textOn =
147159 Motion.div
148160 </ { className: "ry-toggle-text-container"
@@ -151,6 +163,7 @@ rawComponent =
151163 , animate: Motion.animate $ css { scale: 1, opacity: 1 }
152164 , exit: Motion.exit $ css { scale: 0, opacity: 0 }
153165 }
166+
154167 textOff =
155168 Motion.div
156169 </ { className: "ry-toggle-text-container"
@@ -159,7 +172,9 @@ rawComponent =
159172 , animate: Motion.animate $ css { scale: 1, opacity: 1 }
160173 , exit: Motion.exit $ css { scale: 0, opacity: 0 }
161174 }
175+
162176 animateTextPresence = Motion.animatePresence </ {}
177+
163178 toggle =
164179 toggleCircle
165180 </> { buttonRef
@@ -209,6 +224,7 @@ toggleCircle =
209224 { left: { x: 0.0 }
210225 , right: { x: maxLeft # fromMaybe 0.0 }
211226 }
227+
212228 toggleVariant = Motion.makeVariantLabels toggleVariants
213229 pure
214230 $ Motion.div
@@ -223,56 +239,68 @@ toggleCircle =
223239 , key: if isNothing maxLeft then "initialising" else "ready"
224240 , dragElastic: Motion.dragElastic false
225241 , dragConstraints:
226− Motion.dragConstraints
227− { left:
228− case togglePosition of
229− ToggleIsLeft -> zero
230− ToggleIsRight -> negate (maxLeft # fromMaybe 0.0)
231− , right:
232− case togglePosition of
233− ToggleIsRight -> zero
234− ToggleIsLeft -> maxLeft # fromMaybe 0.0
235− }
242+ Motion.dragConstraints
243+ { left:
244+ case togglePosition of
245+ ToggleIsLeft -> zero
246+ ToggleIsRight -> -(maxLeft <#> (_ - Style.dragWidthDelta) # fromMaybe 0.0)
247+ , right:
248+ case togglePosition of
249+ ToggleIsRight -> zero
250+ ToggleIsLeft -> maxLeft <#> (_ - Style.dragWidthDelta) # fromMaybe 0.0
251+ }
236252 , variants: Motion.variants toggleVariants
237253 , transition: Motion.transition { type: "tween", duration: 0.33, ease: "easeOut" }
238− , whileTap: Motion.prop $ css { scale: 1.1, transition: { type: "tween", duration: 0.10, ease: "easeInOut" } }
254+ , whileTap:
255+ Motion.prop
256+ $ css
257+ { width: "calc(var(--s2)*0.85 + 10px)"
258+ , left:
259+ case togglePosition of
260+ ToggleIsLeft -> Style.toggleLeft
261+ ToggleIsRight -> "calc(" <> Style.toggleLeft <> " - 10px)"
262+ , transition: { type: "tween", duration: 0.10, ease: "easeInOut" }
263+ }
239264 , onTapStart: Motion.onTapStart \_ _ -> writeRef tapState TapAllowed
240265 , onTap:
241− Motion.onTap \_ pi -> do
242− ts <- readRef tapState
243− case ts of
244− TapAllowed -> setTogglePosition (flipToggle togglePosition)
245− _ -> mempty
246− mempty
266+ Motion.onTap \_ pi -> do
267+ ts <- readRef tapState
268+ case ts of
269+ TapAllowed -> setTogglePosition (flipToggle togglePosition)
270+ _ -> mempty
271+ mempty
247272 , onTapCancel:
248− Motion.onTapCancel \_ pi -> do
249− writeRef tapState TapNotAllowed
250− mempty
273+ Motion.onTapCancel \_ pi -> do
274+ writeRef tapState TapNotAllowed
275+ mempty
251276 , initial: Motion.initial false
252277 , animate:
253− Motion.animate case togglePosition of
254− ToggleIsLeft -> toggleVariant.left
255− ToggleIsRight -> toggleVariant.right
278+ Motion.animate case togglePosition of
279+ ToggleIsLeft -> toggleVariant.left
280+ ToggleIsRight -> toggleVariant.right
256281 , onDragStart:
257− Motion.onDragStart \_ pi -> do
258− maybeBBox <- getBoundingBoxFromRef toggleRef
259− let
260− x = maybeBBox <#> \bbox -> bbox.left + (bbox.width / 2.0)
261− setDragState $ Dragging { startX: x # fromMaybe pi.point.x, currentX: pi.point.x }
282+ Motion.onDragStart \_ pi -> do
283+ maybeBBox <- getBoundingBoxFromRef toggleRef
284+ let
285+ x = maybeBBox <#> \bbox -> bbox.left + (bbox.width / 2.0)
286+ setDragState
287+ $ Dragging
288+ { startX: x # fromMaybe pi.point.x, currentX: pi.point.x
289+ }
262290 , onDrag:
263− Motion.onDrag \_ pi -> do
264− case dragState of
265− Dragging { startX } -> do
266− setDragState $ Dragging { startX, currentX: pi.point.x }
267− other -> Console.warn $ i "Unexpected drag state " (show other) " in onDragEvent"
291+ Motion.onDrag \_ pi -> do
292+ case dragState of
293+ Dragging { startX } -> do
294+ setDragState $ Dragging { startX, currentX: pi.point.x }
295+ other -> Console.warn $ i "Unexpected drag state " (show other) " in onDragEvent"
268296 , onDragEnd:
269− Motion.onDragEnd \_ pi -> do
270− case dragState of
271− Dragging { startX } -> do
272− maybeBBox <- getBoundingBoxFromRef toggleRef
273− let
274− x = maybeBBox <#> \bbox -> bbox.left + (bbox.width / 2.0)
275− setDragState (DragDone { startX, endX: x # fromMaybe' \_ -> unsafeCrashWith "shit" })
276− other -> Console.warn $ i "Unexpected drag state " (show other) " in onDragEvent"
297+ Motion.onDragEnd \_ pi -> do
298+ case dragState of
299+ Dragging { startX } -> do
300+ maybeBBox <- getBoundingBoxFromRef toggleRef
301+ let
302+ x = maybeBBox <#> \bbox -> bbox.left + (bbox.width / 2.0)
303+ setDragState (DragDone { startX, endX: x # fromMaybe' \_ -> unsafeCrashWith "shit" })
304+ other -> Console.warn $ i "Unexpected drag state " (show other) " in onDragEvent"
277305 , ref: toggleRef
278306 }
src/Yoga/Block/Atom/Tooltip/Style.purs+1−1
@@ -38,7 +38,7 @@ content props =
3838 , minWidth: str "50px"
3939 , padding: str "6px"
4040 , zIndex: str "-1"
41− , color: str colour.background0
41+ , color: str colour.background
4242 , boxShadow: str "0 1px 8px rgba(0,0,0,0.33)"
4343 , borderRadius: var "--s-2"
4444 }
src/Yoga/Block/Atom/Tooltip/View.purs+11−3
@@ -45,9 +45,9 @@ rawComponent =
4545 { styles, attributes } <-
4646 usePopper referenceElement popperElement
4747 { modifiers:
48− [ modifierArrow arrowElement
49− , modifierOffset { x: 0.0, y: 12.0 }
50− ]
48+ [ modifierArrow arrowElement
49+ , modifierOffset { x: 0.0, y: 12.0 }
50+ ]
5151 }
5252 visible /\ setVisible <- React.useState' false
5353 touching /\ setTouching <- React.useState' false
@@ -68,8 +68,11 @@ rawComponent =
6868 -- Handlers
6969 let
7070 hoveredIn = setHovering true
71+
7172 hoveredOut = setHovering false
73+
7274 touchStarted = setTouching true
75+
7376 touchEnded = setTouching false
7477 -- Elements
7578 let
@@ -86,7 +89,9 @@ rawComponent =
8689 ]
8790 ]
8891 ]
92+
8993 animatePresence = Motion.animatePresence </ { initial: false }
94+
9095 content =
9196 Motion.div
9297 </* { className: "popper-element-content"
@@ -97,6 +102,7 @@ rawComponent =
97102 , transition: Motion.transition { duration: 0.2 }
98103 , key: "container"
99104 }
105+
100106 popperEl =
101107 div
102108 </* { className: "popper-element"
@@ -105,6 +111,7 @@ rawComponent =
105111 , style: styles.popper
106112 , _data: attributes.popper
107113 }
114+
108115 arrow =
109116 div
110117 </*> { className: "popper-arrow"
@@ -114,6 +121,7 @@ rawComponent =
114121 , style: styles.arrow
115122 , _data: attributes.arrow
116123 }
124+
117125 refElem =
118126 Motion.div
119127 </ { ref: unsafeCoerce (mkEffectFn1 setReferenceElement)
src/Yoga/Block/Container/Story.purs+33−2
@@ -3,10 +3,12 @@ module Yoga.Block.Container.Story where
33import Prelude
44import Effect (Effect)
55import React.Basic (JSX, element, fragment)
6+import React.Basic.DOM (css)
67import React.Basic.DOM as R
78import Yoga (el, styledLeaf)
89import Yoga.Block.Container as Container
9−import Yoga.Block.Container.Style (inputFocus)
10+import Yoga.Block.Container.Style (colour, inputFocus)
11+import Yoga.Block.Layout.Box as Box
1012import Yoga.Block.Layout.Cluster as Cluster
1113import Yoga.Block.Layout.Stack as Stack
1214
@@ -19,7 +21,17 @@ container =
1921 ( element Container.component
2022 { content:
2123 fragment
22− [ R.text "Content"
24+ [ el Box.component { style: css { background: colour.backgroundLayer1 } }
25+ [ el Box.component { style: css { background: colour.backgroundLayer2 } }
26+ [ el Box.component { style: css { background: colour.backgroundLayer3 } }
27+ [ el Box.component { style: css { background: colour.backgroundLayer4 } }
28+ [ el Box.component { style: css { background: colour.backgroundLayer5 } }
29+ []
30+ ]
31+ ]
32+ ]
33+ ]
34+ , R.text "Content"
2335 , el Stack.component {}
2436 [ el Cluster.component {}
2537 [ R.input { value: "Text" }
@@ -44,6 +56,25 @@ container =
4456 ]
4557 , R.input { type: "range" }
4658 ]
59+ , R.h1_ [ R.text "Largest heading (h1)" ]
60+ , psParagraph
61+ , R.h2_ [ R.text "Second largest heading (h2)" ]
62+ , psParagraph
63+ , R.h3_ [ R.text "Third largest heading (h3)" ]
64+ , psParagraph
65+ , R.p_ [ R.text "Make sure to have the following meta tag in your head" ]
66+ , R.code_
67+ [ R.text
68+ """<meta name="viewport" content="width=device-width, initial-scale=1.0">"""
69+ ]
70+ , R.h1_ [ R.text "Very long largest heading that can result in multiple lines" ]
4771 ]
4872 }
4973 )
74+
75+psParagraph ∷ JSX
76+psParagraph =
77+ R.p_
78+ [ R.text
79+ """PureScript is a strongly-typed, purely-functional programming language that compiles to JavaScript. It can be used to develop web applications, server side apps, and also desktop applications with use of Electron. Its syntax is mostly comparable to that of Haskell. In addition, it introduces row polymorphism and extensible records.[2] Also, contrary to Haskell, PureScript adheres to a strict evaluation strategy. """
80+ ]
src/Yoga/Block/Container/Style.purs+258−258
@@ -31,267 +31,264 @@ mkGlobal ∷ Maybe DarkOrLightMode -> Style
3131mkGlobal maybeMode =
3232 css
3333 { "body, html":
34− nested
35− $ css
36− { minHeight: 100.0 # vh
37− , minWidth: 100.0 # vw
38− , lineHeight: str "1.15"
39− , "WebkitTextSizeAdjust": _100percent
40− , transition: str "background,color 0.33s ease-in"
41− }
34+ nested
35+ $ css
36+ { minHeight: 100.0 # vh
37+ , minWidth: 100.0 # vw
38+ , lineHeight: str "1.15"
39+ , "WebkitTextSizeAdjust": _100percent
40+ , transition: str "background,color 0.33s ease-in"
41+ }
4242 , ":root":
43− nested $ variables
44− <> fontVariables { main: "Inter", mono: "Victor Mono, Menlo, Consolas, Monaco, Liberation Mono, Lucida Console" }
43+ nested $ variables
44+ <> fontVariables { main: "Inter", mono: "Victor Mono, Menlo, Consolas, Monaco, Liberation Mono, Lucida Console" }
4545 , html:
46− nested
47− $ css
48− { boxSizing: str "border-box"
49− }
46+ nested
47+ $ css
48+ { boxSizing: str "border-box"
49+ }
5050 , body:
51− nested
52− $ css
53− { fontFamily: str "var(--main-font)"
54− , background: str colour.background0
55− , color: str colour.text
56− , margin: str "0"
57− }
58− <> case maybeMode of
59− Nothing -> autoSwitchColourTheme
60− Just DarkMode -> darkModeStyle
61− Just LightMode -> lightModeStyle
51+ nested
52+ $ css
53+ { fontFamily: str "var(--main-font)"
54+ , background: str colour.background
55+ , color: str colour.text
56+ , margin: str "0"
57+ }
58+ <> case maybeMode of
59+ Nothing -> autoSwitchColourTheme
60+ Just DarkMode -> darkModeStyle
61+ Just LightMode -> lightModeStyle
6262 , "pre,code":
63− nest
64− { fontFamily: str "var(--mono-font)"
65− }
63+ nest
64+ { fontFamily: str "var(--mono-font)"
65+ }
66+ , "h1,h2,h3,h4":
67+ nest
68+ { lineHeight: var "--line-height-small"
69+ , fontWeight: str "700"
70+ , marginTop: str "var(--s-3)"
71+ }
6672 , h1:
67− nested
68− $ css
69− { fontSize: var "--s4"
70− , lineHeight: str "calc(var(--s4) * 1.4)"
71− , fontWeight: str "900"
72− , letterSpacing: str "calc(var(--s-5) * -1)"
73− }
73+ nested
74+ $ css
75+ { "--h1size": str "calc( min( var(--s2) + 2vw , var(--s4) ) )"
76+ , fontSize: var "--h1size"
77+ , letterSpacing: str "calc(var(--h1size) * -0.04)"
78+ }
7479 , h2:
75− nested
76− $ css
77− { fontSize: var "--s3"
78− , lineHeight: str "calc(var(--s3) * 1.4)"
79− , fontWeight: str "800"
80− , letterSpacing: str "calc(var(--s-5) * -0.9)"
81− }
80+ nested
81+ $ css
82+ { "--h2size": str "calc( min( var(--s1) + 2vw , var(--s3) ) )"
83+ , fontSize: var "--h2size"
84+ , letterSpacing: str "calc(var(--h2size) * -0.035)"
85+ }
8286 , h3:
83− nested
84− $ css
85− { fontSize: var "--s2"
86− , lineHeight: str "calc(var(--s2) * 1.4)"
87− , fontWeight: str "700"
88− , letterSpacing: str "calc(var(--s-5) * -0.8)"
89− }
87+ nested
88+ $ css
89+ { "--h3size": str "calc( min( var(--s0) + 2vw , var(--s2) ) )"
90+ , fontSize: var "--h3size"
91+ , letterSpacing: str "calc(var(--h3size) * -0.03)"
92+ }
93+ , p:
94+ nested
95+ $ css
96+ { "--psize": str "calc( min( var(--s-2) + 2.7vw , var(--s0)*1.1 ) )"
97+ , fontSize: var "--psize"
98+ , letterSpacing: str "calc(var(--psize) * -0.03)"
99+ }
100+ , a:
101+ nest
102+ { color: str colour.text
103+ , textDecorationColor: str colour.text
104+ , "&:hover":
105+ nest
106+ { color: str colour.text
107+ , textDecorationColor: str colour.highlight
108+ }
109+ , "&:visited":
110+ nest
111+ { color: str colour.backgroundLayer1
112+ , textDecorationColor: str colour.backgroundLayer1
113+ }
114+ }
90115 , "::selection":
91− nest
92− { color: str colour.highlightText
93− , background: str colour.highlight
94− }
116+ nest
117+ { color: str colour.highlightText
118+ , background: str colour.highlight
119+ }
95120 , "*, *:before, *:after":
96− nested
97− $ css
98− { boxSizing: str "inherit"
99− , fontFeatureSettings:
100− str
101− $ intercalate ","
102− $ show
103− <$> [ "ss03" -- curved r
104− , "cv03" -- open six
105− , "cv04" -- open nine
106− -- , "cv05" -- lower case l with tail
107− , "cv07" -- German double-s
108− , "cv09" -- Flat top three
109− ]
110− }
121+ nested
122+ $ css
123+ { boxSizing: str "inherit"
124+ , "::selection":
125+ nest
126+ { color: str colour.highlightText
127+ , background: str colour.highlight
128+ }
129+ , fontFeatureSettings:
130+ str
131+ $ intercalate ","
132+ $ show
133+ <$> [ "ss03" -- curved r
134+ , "cv03" -- open six
135+ , "cv04" -- open nine
136+ -- , "cv05" -- lower case l with tail
137+ , "cv07" -- German double-s
138+ , "cv09" -- Flat top three
139+ ]
140+ }
111141 }
112142
113143withAlpha ∷ Number -> Color -> Color
114144withAlpha alpha c1 = Color.rgba' r g b alpha
115145 where
116− { r, g, b } = Color.toRGBA' c1
146+ { r, g, b } = Color.toRGBA' c1
117147
118148defaultColours ∷ Colours
119149defaultColours =
120150 { light:
121− { background0: lightBg
122− , background02: darken 0.02 lightBg
123− , background05: darken 0.05 lightBg
124− , background07: darken 0.07 lightBg
125− , background10: darken 0.1 lightBg
126− , background12: darken 0.12 lightBg
127− , background15: darken 0.15 lightBg
128− , background20: darken 0.2 lightBg
129− , background25: darken 0.25 lightBg
130− , background30: darken 0.3 lightBg
131− , background40: darken 0.4 lightBg
132− , background50: darken 0.5 lightBg
133− , background60: darken 0.6 lightBg
134− , background70: darken 0.7 lightBg
135− , background80: darken 0.8 lightBg
136− , background90: darken 0.9 lightBg
137− , background100: darken 1.0 lightBg
138− , backgroundInverted: darken 0.85 lightBg
139− , textInverted: lightBg
140− , success
141− , successText
142− , invalid
143− , invalidText
144− , required
145− , interfaceBackground
146− , interfaceBackgroundDangerous
147− , interfaceDangerousText
148− , interfaceBackgroundDisabled: darken 0.03 lightBg
149− , interfaceTextDisabled: darken 0.30 lightBg
150− , interfaceBackgroundHighlight: lighten 0.05 lightBg
151− , highlightDisabled: (desaturate 0.80 >>> lighten 0.28) highlight
152− , interfaceBackgroundShadow: darken 0.04 lightBg
153− , inputBackground: lightBg
154− , inputBorder: darken 0.1 lightBg
155− , highlight
156− , highlightLighter: withAlpha 0.2 (Color.lighten 0.5 highlight)
157− , highlightDarker: withAlpha 0.15 (Color.darken 0.5 highlight)
158− , highlightRotatedForwards: highlight # rotateHue 30.0
159− , highlightRotatedBackwards: highlight # rotateHue (-30.0)
160− , highlightText
161− , text: textLightTheme
162− , placeholderText: lighten 0.4 darkBg
163− }
151+ { background: lightBg
152+ , backgroundLayer1: darken 0.20 >>> saturate 0.04 $ lightBg
153+ , backgroundLayer2: darken 0.15 >>> saturate 0.07 $ lightBg
154+ , backgroundLayer3: darken 0.10 >>> saturate 0.09 $ lightBg
155+ , backgroundLayer4: darken 0.05 >>> saturate 0.12 $ lightBg
156+ , backgroundLayer5: lightBg
157+ , backgroundInverted: darken 0.85 lightBg
158+ , textInverted: lightBg
159+ , success
160+ , successText
161+ , invalid
162+ , invalidText
163+ , required
164+ , interfaceBackground
165+ , interfaceBackgroundDangerous
166+ , interfaceDangerousText
167+ , interfaceBackgroundDisabled: darken 0.03 lightBg
168+ , interfaceTextDisabled: darken 0.30 lightBg
169+ , interfaceBackgroundHighlight: lighten 0.05 lightBg
170+ , highlightDisabled: (desaturate 0.80 >>> lighten 0.28) highlight
171+ , interfaceBackgroundShadow: darken 0.04 lightBg
172+ , inputBackground: lightBg
173+ , inputBorder: darken 0.1 lightBg
174+ , highlight
175+ , highlightLighter: withAlpha 0.2 (Color.lighten 0.5 highlight)
176+ , highlightDarker: withAlpha 0.15 (Color.darken 0.5 highlight)
177+ , highlightRotatedForwards: highlight # rotateHue 30.0
178+ , highlightRotatedBackwards: highlight # rotateHue (-30.0)
179+ , highlightText
180+ , text: textLightTheme
181+ , placeholderText: lighten 0.4 darkBg
182+ }
164183 , dark:
165− { background0: darkBg
166− , background02: lighten 0.02 darkBg
167− , background05: lighten 0.05 darkBg
168− , background07: lighten 0.07 darkBg
169− , background10: lighten 0.1 darkBg
170− , background12: lighten 0.12 darkBg
171− , background15: lighten 0.15 darkBg
172− , background20: lighten 0.2 darkBg
173− , background25: lighten 0.25 darkBg
174− , background30: lighten 0.3 darkBg
175− , background40: lighten 0.4 darkBg
176− , background50: lighten 0.5 darkBg
177− , background60: lighten 0.6 darkBg
178− , background70: lighten 0.7 darkBg
179− , background80: lighten 0.8 darkBg
180− , background90: lighten 0.9 darkBg
181− , background100: lighten 1.0 darkBg
182− , textInverted: darkBg
183− , backgroundInverted: lightBg
184− , interfaceBackground: interfaceBackgroundDark
185− , interfaceBackgroundDangerous: interfaceBackgroundDangerousDark
186− , interfaceDangerousText: interfaceDangerousTextDark
187− , interfaceBackgroundDisabled: darken 0.3 interfaceBackgroundDark
188− , interfaceTextDisabled: (desaturate 0.3 >>> lighten 0.25) interfaceBackgroundDark
189− , interfaceBackgroundHighlight: lighten 0.1 interfaceBackgroundDark
190− , interfaceBackgroundShadow: darken 0.1 interfaceBackgroundDark
191− , inputBackground: darkBg
192− , inputBorder: lighten 0.17 darkBg
193− , success: successDark
194− , successText
195− , required
196− , invalid
197− , invalidText
198− , highlight: highlightDark
199− , highlightDisabled: (desaturate 0.76 >>> darken 0.32) highlightDark
200− , highlightLighter: withAlpha 0.2 (Color.lighten 0.5 highlightDark)
201− , highlightDarker: withAlpha 0.4 (Color.darken 0.5 highlightDark)
202− , highlightRotatedForwards: highlightDark # rotateHue 30.0
203− , highlightRotatedBackwards: highlightDark # rotateHue (-30.0)
204− , highlightText
205− , text: lightBg
206− , placeholderText: darken 0.4 lightBg
207− }
184+ { background: darkBg
185+ , backgroundLayer1: lighten 0.30 >>> saturate 0.07 $ darkBg
186+ , backgroundLayer2: lighten 0.21 >>> saturate 0.08 $ darkBg
187+ , backgroundLayer3: lighten 0.14 >>> saturate 0.12 $ darkBg
188+ , backgroundLayer4: lighten 0.07 >>> saturate 0.18 $ darkBg
189+ , backgroundLayer5: darkBg
190+ , textInverted: darkBg
191+ , backgroundInverted: lightBg
192+ , interfaceBackground: interfaceBackgroundDark
193+ , interfaceBackgroundDangerous: interfaceBackgroundDangerousDark
194+ , interfaceDangerousText: interfaceDangerousTextDark
195+ , interfaceBackgroundDisabled: darken 0.3 interfaceBackgroundDark
196+ , interfaceTextDisabled: (desaturate 0.3 >>> lighten 0.25) interfaceBackgroundDark
197+ , interfaceBackgroundHighlight: lighten 0.1 interfaceBackgroundDark
198+ , interfaceBackgroundShadow: darken 0.1 interfaceBackgroundDark
199+ , inputBackground: darkBg
200+ , inputBorder: lighten 0.17 darkBg
201+ , success: successDark
202+ , successText
203+ , required
204+ , invalid
205+ , invalidText
206+ , highlight: highlightDark
207+ , highlightDisabled: (desaturate 0.76 >>> darken 0.32) highlightDark
208+ , highlightLighter: withAlpha 0.2 (Color.lighten 0.5 highlightDark)
209+ , highlightDarker: withAlpha 0.4 (Color.darken 0.5 highlightDark)
210+ , highlightRotatedForwards: highlightDark # rotateHue 30.0
211+ , highlightRotatedBackwards: highlightDark # rotateHue (-30.0)
212+ , highlightText
213+ , text: lightBg
214+ , placeholderText: darken 0.4 lightBg
215+ }
208216 }
209217 where
210− highlight = Color.hsl 270.0 0.90 0.62
211−
212− highlightDark = Color.rgb 0x88 0x33 0xFF
213−
214− interfaceBackgroundDark = Color.hsl 240.0 0.10 0.33
215−
216− interfaceBackground = lightBg
217−
218− interfaceBackgroundDangerous = interfaceBackground
219−
220− interfaceDangerousText = invalid
221−
222− interfaceBackgroundDangerousDark = Color.hsl 340.0 0.55 0.30
223−
224− interfaceDangerousTextDark = Color.hsl 340.0 1.0 0.90
225−
226− highlightText = Color.rgb 0xFF 0xFF 0xFF
227−
228− success = Color.rgb 10 150 25
229−
230− successDark = Color.rgb 20 200 60
231−
232− successText = Color.rgb 250 250 250
233−
234− invalid = Color.rgb 220 40 70
235−
236− invalidText = successText
237−
238− required = Color.rgb 200 50 80
239−
240− textLightTheme = Color.rgb 16 16 32
241−
242− darkBg = Color.rgb 0 0 0
243−
244− lightBg = Color.rgb 250 250 250
245−
246−type FlatTheme a =
247− { background0 ∷ a
248− , background02 ∷ a
249− , background05 ∷ a
250− , background07 ∷ a
251− , background10 ∷ a
252− , background12 ∷ a
253− , background15 ∷ a
254− , background20 ∷ a
255− , background25 ∷ a
256− , background30 ∷ a
257− , background40 ∷ a
258− , background50 ∷ a
259− , background60 ∷ a
260− , background70 ∷ a
261− , background80 ∷ a
262− , background90 ∷ a
263− , background100 ∷ a
264− , backgroundInverted ∷ a
265− , interfaceBackground ∷ a
266− , interfaceBackgroundDangerous ∷ a
267− , interfaceDangerousText ∷ a
268− , interfaceBackgroundDisabled ∷ a
269− , interfaceTextDisabled ∷ a
270− , interfaceBackgroundHighlight ∷ a
271− , interfaceBackgroundShadow ∷ a
272− , inputBackground ∷ a
273− , inputBorder ∷ a
274− , highlight ∷ a
275− , highlightRotatedBackwards ∷ a
276− , highlightRotatedForwards ∷ a
277− , highlightDarker ∷ a
278− , highlightLighter ∷ a
279− , highlightDisabled ∷ a
280− , highlightText ∷ a
281− , success ∷ a
282− , successText ∷ a
283− , invalid ∷ a
284− , invalidText ∷ a
285− , required ∷ a
286− , text ∷ a
287− , textInverted ∷ a
288− , placeholderText ∷ a
289− }
218+ highlight = Color.hsl 270.0 0.90 0.62
290219
291−type Colours =
292− { dark ∷ FlatTheme Color
293− , light ∷ FlatTheme Color
294− }
220+ highlightDark = Color.rgb 0x88 0x33 0xFF
221+
222+ interfaceBackgroundDark = Color.hsl 240.0 0.10 0.33
223+
224+ interfaceBackground = lightBg
225+
226+ interfaceBackgroundDangerous = interfaceBackground
227+
228+ interfaceDangerousText = invalid
229+
230+ interfaceBackgroundDangerousDark = Color.hsl 340.0 0.55 0.30
231+
232+ interfaceDangerousTextDark = Color.hsl 340.0 1.0 0.90
233+
234+ highlightText = Color.rgb 0xFF 0xFF 0xFF
235+
236+ success = Color.rgb 10 150 25
237+
238+ successDark = Color.rgb 20 200 60
239+
240+ successText = Color.rgb 250 250 250
241+
242+ invalid = Color.rgb 220 40 70
243+
244+ invalidText = successText
245+
246+ required = Color.rgb 200 50 80
247+
248+ textLightTheme = Color.rgb 16 16 32
249+
250+ darkBg = Color.hsl 240.0 0.07 0.14
251+
252+ lightBg = Color.hsl 240.0 0.05 0.97
253+
254+type FlatTheme a
255+ = { background ∷ a
256+ , backgroundLayer1 ∷ a
257+ , backgroundLayer2 ∷ a
258+ , backgroundLayer3 ∷ a
259+ , backgroundLayer4 ∷ a
260+ , backgroundLayer5 ∷ a
261+ , backgroundInverted ∷ a
262+ , interfaceBackground ∷ a
263+ , interfaceBackgroundDangerous ∷ a
264+ , interfaceDangerousText ∷ a
265+ , interfaceBackgroundDisabled ∷ a
266+ , interfaceTextDisabled ∷ a
267+ , interfaceBackgroundHighlight ∷ a
268+ , interfaceBackgroundShadow ∷ a
269+ , inputBackground ∷ a
270+ , inputBorder ∷ a
271+ , highlight ∷ a
272+ , highlightRotatedBackwards ∷ a
273+ , highlightRotatedForwards ∷ a
274+ , highlightDarker ∷ a
275+ , highlightLighter ∷ a
276+ , highlightDisabled ∷ a
277+ , highlightText ∷ a
278+ , success ∷ a
279+ , successText ∷ a
280+ , invalid ∷ a
281+ , invalidText ∷ a
282+ , required ∷ a
283+ , text ∷ a
284+ , textInverted ∷ a
285+ , placeholderText ∷ a
286+ }
287+
288+type Colours
289+ = { dark ∷ FlatTheme Color
290+ , light ∷ FlatTheme Color
291+ }
295292
296293data MakeCSSVarLabels
297294 = MakeCSSVarLabels
@@ -312,24 +309,25 @@ colour =
312309autoSwitchColourTheme ∷ Style
313310autoSwitchColourTheme = lightT
314311 where
315− darkT ∷ Style
316− darkT = unsafeCoerce darkObj
317−
318− darkObj ∷ Object StyleProperty
319− darkObj =
320− Object.fromHomogeneous defaultColours.dark
321− # Object.foldMap \k v ->
322− Object.singleton ("--" <> k) (str (Color.cssStringRGBA v))
323−
324− lightObj ∷ Object StyleProperty
325− lightObj =
326− Object.fromHomogeneous defaultColours.light
327− # Object.foldMap \k v ->
328− Object.singleton ("--" <> k) (str (Color.cssStringRGBA v))
329− # Object.insert "@media (prefers-color-scheme: dark)" (nested darkT)
330−
331− lightT ∷ Style
332− lightT = unsafeCoerce lightObj
312+ darkT ∷ Style
313+ darkT = unsafeCoerce darkObj
314+
315+ darkObj ∷ Object StyleProperty
316+ darkObj =
317+ Object.fromHomogeneous defaultColours.dark
318+ # Object.foldMap \k v ->
319+ Object.singleton ("--" <> k) (str (Color.cssStringRGBA v))
320+
321+ lightObj ∷ Object StyleProperty
322+ lightObj =
323+ Object.fromHomogeneous defaultColours.light
324+ # Object.foldMap \k v ->
325+ Object.singleton ("--" <> k) (str (Color.cssStringRGBA v))
326+ # Object.insert "@media (prefers-color-scheme: dark)" (nested darkT)
327+ # Object.insert "&:th" (nested darkT)
328+
329+ lightT ∷ Style
330+ lightT = unsafeCoerce lightObj
333331
334332lightModeVariables ∷ Object StyleProperty
335333lightModeVariables =
@@ -346,7 +344,9 @@ darkModeVariables =
346344variables ∷ Style
347345variables =
348346 css
349− { "--ratio": "1.5" # str
347+ { "--ratio": "1.61" # str
348+ , "--line-height": str "var(--ratio)"
349+ , "--line-height-small": str "calc(var(--ratio) * 0.8)"
350350 , "--s-5": str "calc(var(--s-4) / var(--ratio))"
351351 , "--s-4": str "calc(var(--s-3) / var(--ratio))"
352352 , "--s-3": str "calc(var(--s-2) / var(--ratio))"
src/Yoga/Block/Container/View.purs+2−2
@@ -14,7 +14,7 @@ import Yoga.Block.Container.Style as Styles
1414
1515type PropsF f =
1616 ( content ∷ JSX
17− , themeVariant ∷ f DarkOrLightMode
17+ , themeVariant ∷ f (Maybe DarkOrLightMode)
1818 )
1919
2020type Props =
@@ -33,7 +33,7 @@ rawComponent =
3333 $ Array.cons
3434 ( element E.global
3535 { styles:
36− case opToMaybe themeVariant of
36+ case opToMaybe themeVariant # join of
3737 Nothing -> Styles.global
3838 Just Styles.DarkMode -> Styles.darkMode
3939 Just Styles.LightMode -> Styles.lightMode
src/Yoga/Block/Icon/SVG/Icon.purs+4
@@ -8,6 +8,8 @@ module Yoga.Block.Icon.SVG
88 , module Yoga.Block.Icon.SVG.SimpleKey
99 , module Yoga.Block.Icon.SVG.QuestionMark
1010 , module Yoga.Block.Icon.SVG.Cross
11+ , module Yoga.Block.Icon.SVG.Sun
12+ , module Yoga.Block.Icon.SVG.Moon
1113 ) where
1214
1315import Yoga.Block.Icon.SVG.On (on)
@@ -19,3 +21,5 @@ import Yoga.Block.Icon.SVG.Key (key)
1921import Yoga.Block.Icon.SVG.SimpleKey (simpleKey)
2022import Yoga.Block.Icon.SVG.QuestionMark (questionMark)
2123import Yoga.Block.Icon.SVG.Cross (cross)
24+import Yoga.Block.Icon.SVG.Sun (sun)
25+import Yoga.Block.Icon.SVG.Moon (moon)
src/Yoga/Block/Icon/SVG/Moon.pursnew file+21
@@ -0,0 +1,21 @@
1+module Yoga.Block.Icon.SVG.Moon where
2+
3+import React.Basic (JSX)
4+import React.Basic.DOM.SVG as SVG
5+
6+moon ∷ JSX
7+moon =
8+ SVG.svg
9+ { viewBox: "0 0 100 100"
10+ , xmlns: "http://www.w3.org/2000/svg"
11+ , fillRule: "evenodd"
12+ , clipRule: "evenodd"
13+ , strokeLinejoin: "round"
14+ , strokeMiterlimit: "1.5"
15+ , children:
16+ [ SVG.path
17+ { d: "M53.984 14.646c1.707.195 3.42.519 5.128.977 18.733 5.019 29.867 24.303 24.847 43.036-5.019 18.732-24.303 29.866-43.036 24.846-13.577-3.638-23.163-14.769-25.499-27.753a28.518 28.518 0 008.408 3.788c15.237 4.082 30.921-4.973 35.004-20.21 2.376-8.867.302-17.887-4.852-24.684z"
18+ , fill: "var(--stroke-colour)"
19+ }
20+ ]
21+ }
src/Yoga/Block/Icon/SVG/Off.purs+3−8
@@ -1,7 +1,6 @@
11module Yoga.Block.Icon.SVG.Off where
22
33import React.Basic (JSX)
4−import React.Basic.DOM as R
54import React.Basic.DOM.SVG as SVG
65
76off ∷ JSX
@@ -14,17 +13,13 @@ off =
1413 , strokeLinejoin: "round"
1514 , strokeMiterlimit: "1.5"
1615 , children:
17− [ SVG.path
18− { fill: "none"
19− , d: "M0 0h100v100H0z"
20− }
21− , SVG.circle
16+ [ SVG.circle
2217 { cx: "50"
2318 , cy: "50"
24− , r: "37.808"
19+ , r: "32"
2520 , fill: "none"
2621 , stroke: "var(--stroke-colour)"
27− , strokeWidth: "20"
22+ , strokeWidth: "17"
2823 }
2924 ]
3025 }
src/Yoga/Block/Icon/SVG/On.purs+4−21
@@ -15,27 +15,10 @@ on =
1515 , strokeMiterlimit: "1.5"
1616 , children:
1717 [ SVG.path
18− { fill: "none"
19− , d: "M0 0h100v100H0z"
20− }
21− , SVG.clipPath
22− { id: "a"
23− , children:
24− [ SVG.path
25− { d: "M0 0h100v100H0z"
26− }
27− ]
28− }
29− , SVG.g
30− { clipPath: "url(#a)"
31− , children:
32− [ SVG.path
33− { d: "M50 1.921v96.261"
34− , fill: "none"
35− , stroke: "var(--stroke-colour)"
36− , strokeWidth: "20"
37− }
38− ]
18+ { d: "M50 10v80"
19+ , fill: "none"
20+ , stroke: "var(--stroke-colour)"
21+ , strokeWidth: "17"
3922 }
4023 ]
4124 }
src/Yoga/Block/Icon/SVG/Sun.pursnew file+27
@@ -0,0 +1,27 @@
1+module Yoga.Block.Icon.SVG.Sun where
2+
3+import React.Basic (JSX)
4+import React.Basic.DOM.SVG as SVG
5+
6+sun ∷ JSX
7+sun =
8+ SVG.svg
9+ { viewBox: "0 0 100 100"
10+ , xmlns: "http://www.w3.org/2000/svg"
11+ , fillRule: "evenodd"
12+ , clipRule: "evenodd"
13+ , strokeLinejoin: "round"
14+ , strokeMiterlimit: "2"
15+ , children:
16+ [ SVG.circle
17+ { cx: "50"
18+ , cy: "49.997"
19+ , r: "24.82"
20+ , fill: "var(--stroke-colour)"
21+ }
22+ , SVG.path
23+ { d: "M2.239 51.966c0 1.64 1.33 2.971 2.971 2.971h13.417a2.971 2.971 0 002.971-2.971v-3.823a2.97 2.97 0 00-2.971-2.971H5.21a2.97 2.97 0 00-2.971 2.971v3.823zM78.415 51.966a2.972 2.972 0 002.971 2.971h13.418a2.971 2.971 0 002.971-2.971v-3.823a2.97 2.97 0 00-2.971-2.971H81.386a2.971 2.971 0 00-2.971 2.971v3.823zM17.581 85.183a2.972 2.972 0 004.202 0l9.487-9.488a2.97 2.97 0 000-4.201l-2.703-2.703a2.97 2.97 0 00-4.202 0l-9.487 9.487a2.972 2.972 0 000 4.202l2.703 2.703zM71.446 31.318a2.972 2.972 0 004.202 0l9.487-9.488a2.969 2.969 0 000-4.201l-2.703-2.704a2.97 2.97 0 00-4.201 0l-9.488 9.488a2.972 2.972 0 000 4.202l2.703 2.703zM14.878 17.629a2.97 2.97 0 000 4.201l9.487 9.488a2.972 2.972 0 004.202 0l2.703-2.703a2.972 2.972 0 000-4.202l-9.487-9.488a2.972 2.972 0 00-4.202 0l-2.703 2.704zM68.743 71.494a2.97 2.97 0 000 4.201l9.488 9.488a2.97 2.97 0 004.201 0l2.703-2.703a2.97 2.97 0 000-4.202l-9.487-9.487a2.97 2.97 0 00-4.202 0l-2.703 2.703zM48.095 2.286a2.97 2.97 0 00-2.971 2.971v13.417a2.97 2.97 0 002.971 2.971h3.823a2.97 2.97 0 002.971-2.971V5.257a2.97 2.97 0 00-2.971-2.971h-3.823zM48.095 78.463a2.97 2.97 0 00-2.971 2.971v13.417a2.97 2.97 0 002.971 2.971h3.823a2.97 2.97 0 002.971-2.971V81.434a2.97 2.97 0 00-2.971-2.971h-3.823z"
24+ , fill: "var(--stroke-colour)"
25+ }
26+ ]
27+ }
src/Yoga/Block/Icon/SVG/moon.afdesignnew file

Binary file not shown.

src/Yoga/Block/Icon/SVG/moon.svgnew file+1
@@ -0,0 +1 @@
1+<svg viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.5"><path fill="none" d="M0 0h100v100H0z"/><path d="M53.984 14.646c1.707.195 3.42.519 5.128.977 18.733 5.019 29.867 24.303 24.847 43.036-5.019 18.732-24.303 29.866-43.036 24.846-13.577-3.638-23.163-14.769-25.499-27.753a28.518 28.518 0 008.408 3.788c15.237 4.082 30.921-4.973 35.004-20.21 2.376-8.867.302-17.887-4.852-24.684z" fill="#fff" stroke="#333" stroke-width="10"/></svg>
src/Yoga/Block/Icon/SVG/sun.svgnew file+1
@@ -0,0 +1 @@
1+<svg viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="2"><path fill="none" d="M0 0h100v100H0z"/><circle cx="50" cy="49.997" r="24.82" fill="#333"/><path d="M2.239 51.966c0 1.64 1.33 2.971 2.971 2.971h13.417a2.971 2.971 0 002.971-2.971v-3.823a2.97 2.97 0 00-2.971-2.971H5.21a2.97 2.97 0 00-2.971 2.971v3.823zM78.415 51.966a2.972 2.972 0 002.971 2.971h13.418a2.971 2.971 0 002.971-2.971v-3.823a2.97 2.97 0 00-2.971-2.971H81.386a2.971 2.971 0 00-2.971 2.971v3.823zM17.581 85.183a2.972 2.972 0 004.202 0l9.487-9.488a2.97 2.97 0 000-4.201l-2.703-2.703a2.97 2.97 0 00-4.202 0l-9.487 9.487a2.972 2.972 0 000 4.202l2.703 2.703zM71.446 31.318a2.972 2.972 0 004.202 0l9.487-9.488a2.969 2.969 0 000-4.201l-2.703-2.704a2.97 2.97 0 00-4.201 0l-9.488 9.488a2.972 2.972 0 000 4.202l2.703 2.703zM14.878 17.629a2.97 2.97 0 000 4.201l9.487 9.488a2.972 2.972 0 004.202 0l2.703-2.703a2.972 2.972 0 000-4.202l-9.487-9.488a2.972 2.972 0 00-4.202 0l-2.703 2.704zM68.743 71.494a2.97 2.97 0 000 4.201l9.488 9.488a2.97 2.97 0 004.201 0l2.703-2.703a2.97 2.97 0 000-4.202l-9.487-9.487a2.97 2.97 0 00-4.202 0l-2.703 2.703zM48.095 2.286a2.97 2.97 0 00-2.971 2.971v13.417a2.97 2.97 0 002.971 2.971h3.823a2.97 2.97 0 002.971-2.971V5.257a2.97 2.97 0 00-2.971-2.971h-3.823zM48.095 78.463a2.97 2.97 0 00-2.971 2.971v13.417a2.97 2.97 0 002.971 2.971h3.823a2.97 2.97 0 002.971-2.971V81.434a2.97 2.97 0 00-2.971-2.971h-3.823z" fill="#333"/></svg>
src/Yoga/Block/Layout/Box/Style.purs+1
@@ -18,4 +18,5 @@ box props = styles <>? props.css
1818 css
1919 { padding: props.padding ?|| (1.0 # em)
2020 , border: str $ i ((props.borderWidth) ?|| "0") " solid"
21+ , margin: _0
2122 }
src/Yoga/Block/Layout/Centre/Style.purs+1−1
@@ -16,7 +16,7 @@ centre props = styles <>? props.css
1616 where
1717 styles =
1818 css
19− { padding: 1.0 # em
19+ { padding: props.padding ?|| (1.0 # em)
2020 , boxSizing: contentBox
2121 , marginLeft: auto
2222 , marginRight: auto
src/Yoga/Block/Layout/Sidebar/Story.purs+8−16
@@ -35,20 +35,16 @@ sidebar =
3535 [ R.h2_ [ R.text "No Options" ]
3636 , element Sidebar.component
3737 { children:
38− [ R.div_
39− [ R.div { children: [ R.text "Sidebar" ], style: css { backgroundColor: "teal" } }
40− , R.div { children: [ R.text $ power "Content " 10 ], style: css { backgroundColor: "darkslateblue" } }
41− ]
38+ [ R.div { children: [ R.text "Sidebar" ], style: css { backgroundColor: "teal" } }
39+ , R.div { children: [ R.text $ power "Content " 10 ], style: css { backgroundColor: "darkslateblue" } }
4240 ]
4341 , style: css { backgroundColor: "oldlace" }
4442 }
4543 , R.h2_ [ R.text "Zero Space" ]
4644 , element Sidebar.component
4745 { children:
48− [ R.div_
49− [ R.div { children: [ R.text "Child 1" ], style: css { backgroundColor: "teal" } }
50− , R.div { children: [ R.text "Child 2" ], style: css { backgroundColor: "darkslateblue" } }
51− ]
46+ [ R.div { children: [ R.text "Child 1" ], style: css { backgroundColor: "teal" } }
47+ , R.div { children: [ R.text "Child 2" ], style: css { backgroundColor: "darkslateblue" } }
5248 ]
5349 , style: css { backgroundColor: "oldlace" }
5450 , space: "0"
@@ -56,10 +52,8 @@ sidebar =
5652 , R.h2_ [ R.text "Sidebar Right" ]
5753 , element Sidebar.component
5854 { children:
59− [ R.div_
60− [ R.div { children: [ R.text $ power "Content " 50 ], style: css { backgroundColor: "darkslateblue" } }
61− , R.div { children: [ R.text "Sidebar" ], style: css { backgroundColor: "teal" } }
62− ]
55+ [ R.div { children: [ R.text $ power "Content " 50 ], style: css { backgroundColor: "darkslateblue" } }
56+ , R.div { children: [ R.text "Sidebar" ], style: css { backgroundColor: "teal" } }
6357 ]
6458 , style: css { backgroundColor: "oldlace" }
6559 , sideWidth: "40px"
@@ -70,10 +64,8 @@ sidebar =
7064 , R.h2_ [ R.text "No Stretch" ]
7165 , element Sidebar.component
7266 { children:
73− [ R.div_
74− [ R.div { children: [ R.text $ power "Content " 50 ], style: css { backgroundColor: "darkslateblue" } }
75− , R.div { children: [ R.text "Sidebar" ], style: css { backgroundColor: "teal" } }
76− ]
67+ [ R.div { children: [ R.text $ power "Content " 50 ], style: css { backgroundColor: "darkslateblue" } }
68+ , R.div { children: [ R.text "Sidebar" ], style: css { backgroundColor: "teal" } }
7769 ]
7870 , style: css { backgroundColor: "oldlace" }
7971 , noStretch: true
src/Yoga/Block/Layout/Sidebar/View.purs+1
@@ -25,4 +25,5 @@ rawComponent =
2525 $ emotionDiv ref props
2626 { className: "ry-sidebar " <>? props.className
2727 , css: Style.sidebar props
28+ , children: [ div </ {} /> props.children ]
2829 }
src/Yoga/Block/Layout/Stack/Style.purs+1−1
@@ -35,6 +35,6 @@ stack props = splitStyles <> styles <>? props.css
3535 { "&:only-child": nest { height: 100.0 # percent }
3636 }
3737
38− nthChild n = "& > :nth-child(" <> show n <> ")"
38+ nthChild n = "& > div:nth-of-type(" <> show n <> ")"
3939
4040 nthChildStyle n = (nthChild n) ~: { marginBottom: auto }
src/Yoga/Block/Layout/Stack/View.purs+4
@@ -21,8 +21,12 @@ rawComponent ∷ ∀ p. ReactComponent { | p }
2121rawComponent =
2222 mkForwardRefComponent "Stack" do
2323 \(props ∷ { | PropsOptional }) ref -> React.do
24+ -- Wrapping children to use `:nth-of-type` instead of `:nth-child`
25+ -- in CSS because the latter is problematic in SSR
26+ let wrappedChildren = props.children <#> \c -> div </ {} /> [ c ]
2427 pure
2528 $ emotionDiv ref props
2629 { className: "ry-stack " <>? props.className
2730 , css: Style.stack props
31+ , children: wrappedChildren
2832 }
src/Yoga/Block/Modal/View.purs+9−9
@@ -61,15 +61,15 @@ window =
6161 , css: Style.modal
6262 , key: "ry-modal-window"
6363 , children:
64− [ Motion.div
65− </* { className: "ry-modal"
66− , css: Style.modal
67− , drag: Motion.prop true
68− , dragMomentum: Motion.prop false
69− , dragConstraints: Motion.prop clickAwayRef
70− }
71− /> [ content ]
72− ]
64+ [ Motion.div
65+ </* { className: "ry-modal"
66+ , css: Style.modal
67+ , drag: Motion.prop true
68+ , dragMomentum: Motion.prop false
69+ , dragConstraints: Motion.prop clickAwayRef
70+ }
71+ /> [ content ]
72+ ]
7373 }
7474 `withMotion`
7575 { initial: css { transform: "translate(-50%, -50%) scale3d(0.1,0.1,0.1)", opacity: 0 }
src/Yoga/Block/Motion/Story.purs+176−174
@@ -32,12 +32,12 @@ default ∷
3232default =
3333 { title: "Motion"
3434 , decorators:
35− [ \storyFn ->
36− R.div_
37− [ element E.global { styles: Styles.global }
38− , unsafePerformEffect storyFn
39− ]
40− ]
35+ [ \storyFn ->
36+ R.div_
37+ [ element E.global { styles: Styles.global }
38+ , unsafePerformEffect storyFn
39+ ]
40+ ]
4141 }
4242
4343motion ∷ Effect JSX
@@ -45,16 +45,16 @@ motion = do
4545 mc <- mkMc
4646 pure $ element mc {}
4747 where
48− mkMc = do
49− motionCentre <- M.custom Centre.component
50− reactComponent "MotionTest" \{} -> React.do
51− Tuple isOpen setIsOpen <- React.useState false
52− pure
53− $ fragment
54− [ E.element R.div'
55− { className: "bg"
56− , css: backgroundStyle
57− , children:
48+ mkMc = do
49+ motionCentre <- M.custom Centre.component
50+ reactComponent "MotionTest" \{} -> React.do
51+ Tuple isOpen setIsOpen <- React.useState false
52+ pure
53+ $ fragment
54+ [ E.element R.div'
55+ { className: "bg"
56+ , css: backgroundStyle
57+ , children:
5858 [ E.element motionCentre
5959 ( { className: "parent"
6060 , css: parentStyle <> if isOpen then parentStyleOpen else mempty
@@ -66,71 +66,71 @@ motion = do
6666 }
6767 )
6868 ]
69− }
70− ]
69+ }
70+ ]
7171
72− backgroundStyle ∷ E.Style
73− backgroundStyle =
74− E.css
75− { background: E.str "#da36dd"
76− , height: E.vh 88.0
77− , borderRadius: E.px 8
78− , display: flex
79− , alignItems: center
80− , justifyContent: center
81− }
72+ backgroundStyle ∷ E.Style
73+ backgroundStyle =
74+ E.css
75+ { background: E.str "#da36dd"
76+ , height: E.vh 88.0
77+ , borderRadius: E.px 8
78+ , display: flex
79+ , alignItems: center
80+ , justifyContent: center
81+ }
8282
83− parentStyle ∷ E.Style
84− parentStyle =
85− E.css
86− { width: E.px 100
87− , height: E.px 100
88− , padding: _0
89− , margin: _0
90− , display: flex
91− , alignItems: center
92− , justifyContent: center
93− , boxShadow: E.str "30px 30px 60px #b92ebc, -30px -30px 60px #fb3efe"
94− , background: E.str "linear-gradient(145deg, #e93aec, #c431c7)"
95− }
83+ parentStyle ∷ E.Style
84+ parentStyle =
85+ E.css
86+ { width: E.px 100
87+ , height: E.px 100
88+ , padding: _0
89+ , margin: _0
90+ , display: flex
91+ , alignItems: center
92+ , justifyContent: center
93+ , boxShadow: E.str "30px 30px 60px #b92ebc, -30px -30px 60px #fb3efe"
94+ , background: E.str "linear-gradient(145deg, #e93aec, #c431c7)"
95+ }
9696
97− childStyle ∷ E.Style
98− childStyle =
99− E.css
100− { background: E.str "hotpink"
101− , width: E.px 40
102− , height: E.px 40
103− , borderRadius: E.percent 50.0
104− , padding: _0
105− , margin: _0
106− }
97+ childStyle ∷ E.Style
98+ childStyle =
99+ E.css
100+ { background: E.str "hotpink"
101+ , width: E.px 40
102+ , height: E.px 40
103+ , borderRadius: E.percent 50.0
104+ , padding: _0
105+ , margin: _0
106+ }
107107
108− parentStyleOpen ∷ E.Style
109− parentStyleOpen =
110− E.css
111− { width: E.px 300
112− , height: E.px 300
113− , boxShadow: E.str "50px 50px 60px #b92ebc, -50px -50px 60px #fb3efe"
114− , background: E.str "linear-gradient(145deg, #e93aec, #c431c7)"
115− }
108+ parentStyleOpen ∷ E.Style
109+ parentStyleOpen =
110+ E.css
111+ { width: E.px 300
112+ , height: E.px 300
113+ , boxShadow: E.str "50px 50px 60px #b92ebc, -50px -50px 60px #fb3efe"
114+ , background: E.str "linear-gradient(145deg, #e93aec, #c431c7)"
115+ }
116116
117117layoutTrans ∷ Effect JSX
118118layoutTrans = do
119119 mc <- mkMc
120120 pure $ element mc {}
121121 where
122− mkMc =
123− reactComponent "MotionTest" \{} -> React.do
124− sidebarOpen /\ setSidebarOpen <- useState true
125− let
126− ava1 =
127− el M.div
128− { layout: cast true
129− , layoutId: cast "ava"
130− , key: "ava"
131− , onClick: handler_ (setSidebarOpen not)
132− , transition: M.transition { delay: 0.2, type: "spring", damping: 30, stiffness: 200 }
133− , style:
122+ mkMc =
123+ reactComponent "MotionTest" \{} -> React.do
124+ sidebarOpen /\ setSidebarOpen <- useState true
125+ let
126+ ava1 =
127+ el M.div
128+ { layout: cast true
129+ , layoutId: cast "ava"
130+ , key: "ava"
131+ , onClick: handler_ (setSidebarOpen not)
132+ , transition: M.transition { delay: 0.2, type: "spring", damping: 30, stiffness: 200 }
133+ , style:
134134 css
135135 { height: "200px"
136136 , width: "200px"
@@ -139,15 +139,16 @@ layoutTrans = do
139139 , backgroundImage: "url('https://pbs.twimg.com/profile_images/1166763324723404801/nAUqF6tX.jpg')"
140140 , backgroundSize: "cover"
141141 }
142− }
143− []
144− ava2 =
145− el M.div
146− { layout: cast true
147− , layoutId: cast "ava"
148− , key: "ava"
149− , onClick: handler_ (setSidebarOpen not)
150− , style:
142+ }
143+ []
144+
145+ ava2 =
146+ el M.div
147+ { layout: cast true
148+ , layoutId: cast "ava"
149+ , key: "ava"
150+ , onClick: handler_ (setSidebarOpen not)
151+ , style:
151152 css
152153 { height: "100px"
153154 , width: "100px"
@@ -156,14 +157,15 @@ layoutTrans = do
156157 , borderRadius: "50%"
157158 , border: "2px solid darkslateblue"
158159 }
159− }
160− []
161− ava3 =
162− el M.div
163− { onClick: handler_ (setSidebarOpen not)
164− , exit: M.exit (css { scale: 1.4, opacity: 0 })
165− , transition: M.transition { duration: 0.19 }
166− , style:
160+ }
161+ []
162+
163+ ava3 =
164+ el M.div
165+ { onClick: handler_ (setSidebarOpen not)
166+ , exit: M.exit (css { scale: 1.4, opacity: 0 })
167+ , transition: M.transition { duration: 0.19 }
168+ , style:
167169 css
168170 { height: "100px"
169171 , width: "100px"
@@ -171,102 +173,102 @@ layoutTrans = do
171173 , borderRadius: "50%"
172174 , border: "4px solid darkslateblue"
173175 }
174− }
175− []
176− pure
177− $ el animateSharedLayout {}
178− [ el M.animatePresence {}
179− [ if sidebarOpen then
180− ava1
181− else
182− el Stack.component {} [ ava2, ava3 ]
183− ]
184− ]
176+ }
177+ []
178+ pure
179+ $ el animateSharedLayout {}
180+ [ el M.animatePresence {}
181+ [ if sidebarOpen then
182+ ava1
183+ else
184+ el Stack.component {} [ ava2, ava3 ]
185+ ]
186+ ]
185187
186188animatedSidebar ∷ Effect JSX
187189animatedSidebar = do
188190 mc <- mkMc
189191 pure $ element mc {}
190192 where
191− mkMc =
192− reactComponent "MotionTest" \{} -> React.do
193− sidebarOpen /\ setSidebarOpen <- useState true
194− let
195− sb =
196− styled M.div
197− { className: "sidebar"
198− , css: if sidebarOpen then sidebarStyleOpen else sidebarStyleHidden
199− , onClick: handler_ (setSidebarOpen not)
200− , initial: M.initial $ css { opacity: 0 }
201− , animate: M.animate $ css { opacity: 1, width: "200px" }
202− , exit: M.exit $ css { opacity: 0 }
203− , key: "sidebar"
204− }
205− [ R.text $ if sidebarOpen then "Sidebar" else "|||" ]
206− pure
207− $ styled R.div'
208− { className: "bg"
209− , css: backgroundStyle
210− }
211− [ el Sidebar.component
212− { className: "parent"
213− , css: sidebarContainerStyle
214− }
215− [ styled R.div'
216− { css: sidebarStyle
217− , className: "sidebarContainer"
218− }
219− [ element M.animatePresence
220− { children: [ guard sidebarOpen sb ]
221− }
222− , R.div_
223− [ el M.h1
224− { initial: M.initial (css { x: -10, opacity: 0 })
225− , animate: M.animate $ css { x: [ -10, -3, 0 ], opacity: [ 0.1, 0.2, 1.0 ] }
226− , transition: M.transition { duration: 0.6, times: [ 0.1, 0.4, 1.0 ] }
227− , key: "non-sidebar-heading"
228− }
229− [ R.text "Non-sidebar" ]
230− ]
231− ]
232− ]
233− ]
193+ mkMc =
194+ reactComponent "MotionTest" \{} -> React.do
195+ sidebarOpen /\ setSidebarOpen <- useState true
196+ let
197+ sb =
198+ styled M.div
199+ { className: "sidebar"
200+ , css: if sidebarOpen then sidebarStyleOpen else sidebarStyleHidden
201+ , onClick: handler_ (setSidebarOpen not)
202+ , initial: M.initial $ css { opacity: 0 }
203+ , animate: M.animate $ css { opacity: 1, width: "200px" }
204+ , exit: M.exit $ css { opacity: 0 }
205+ , key: "sidebar"
206+ }
207+ [ R.text $ if sidebarOpen then "Sidebar" else "|||" ]
208+ pure
209+ $ styled R.div'
210+ { className: "bg"
211+ , css: backgroundStyle
212+ }
213+ [ el Sidebar.component
214+ { className: "parent"
215+ , css: sidebarContainerStyle
216+ }
217+ [ styled R.div'
218+ { css: sidebarStyle
219+ , className: "sidebarContainer"
220+ }
221+ [ element M.animatePresence
222+ { children: [ guard sidebarOpen sb ]
223+ }
224+ , R.div_
225+ [ el M.h1
226+ { initial: M.initial (css { x: -10, opacity: 0 })
227+ , animate: M.animate $ css { x: [ -10, -3, 0 ], opacity: [ 0.1, 0.2, 1.0 ] }
228+ , transition: M.transition { duration: 0.6, times: [ 0.1, 0.4, 1.0 ] }
229+ , key: "non-sidebar-heading"
230+ }
231+ [ R.text "Non-sidebar" ]
232+ ]
233+ ]
234+ ]
235+ ]
234236
235− variantLabels = makeVariantLabels variants
237+ variantLabels = makeVariantLabels variants
236238
237− variants =
238− { hidden: { width: 30, height: 30, borderRadius: "50%" }
239− , show: { width: "inherit", height: "100%" }
240− }
239+ variants =
240+ { hidden: { width: 30, height: 30, borderRadius: "50%" }
241+ , show: { width: "inherit", height: "100%" }
242+ }
241243
242− sidebarContainerStyle ∷ E.Style
243− sidebarContainerStyle =
244− E.css
245− { height: _100percent
246− , zIndex: E.str "40"
247− }
244+ sidebarContainerStyle ∷ E.Style
245+ sidebarContainerStyle =
246+ E.css
247+ { height: _100percent
248+ , zIndex: E.str "40"
249+ }
248250
249− sidebarStyle ∷ E.Style
250− sidebarStyle =
251− E.css
252− { height: _100percent
253− }
251+ sidebarStyle ∷ E.Style
252+ sidebarStyle =
253+ E.css
254+ { height: _100percent
255+ }
254256
255− sidebarStyleOpen ∷ E.Style
256− sidebarStyleOpen =
257− E.css
258− { background: E.str "teal"
259− }
257+ sidebarStyleOpen ∷ E.Style
258+ sidebarStyleOpen =
259+ E.css
260+ { background: E.str "teal"
261+ }
260262
261− sidebarStyleHidden ∷ E.Style
262− sidebarStyleHidden =
263− E.css
264− { background: E.str "darkslate"
265− }
263+ sidebarStyleHidden ∷ E.Style
264+ sidebarStyleHidden =
265+ E.css
266+ { background: E.str "darkslate"
267+ }
266268
267− backgroundStyle ∷ E.Style
268− backgroundStyle =
269− E.css
270− { background: E.str "darkslateblue"
271− , height: E.vh 80.0
272− }
269+ backgroundStyle ∷ E.Style
270+ backgroundStyle =
271+ E.css
272+ { background: E.str "darkslateblue"
273+ , height: E.vh 80.0
274+ }