mirror of
https://github.com/rowtype-yoga/ry-blocks.git
synced 2024-09-11 21:38:06 +03:00
Coercible -> Castable
This commit is contained in:
parent
2be32a8168
commit
006d5b0c4e
@ -63,7 +63,7 @@ import React.Basic.Events (EventHandler)
|
||||
import React.Basic.Hooks (Ref)
|
||||
import Record (disjointUnion)
|
||||
import Type.Row (type (+))
|
||||
import Untagged.Coercible (class Coercible, coerce)
|
||||
import Untagged.Castable (class Castable, cast)
|
||||
import Untagged.Union (type (|+|))
|
||||
import Web.DOM (Node)
|
||||
import Web.Event.Internal.Types (Event)
|
||||
@ -92,8 +92,8 @@ type Exit =
|
||||
|
||||
foreign import data AnimationControls ∷ Type
|
||||
|
||||
prop ∷ ∀ a b. Coercible a b => a -> b
|
||||
prop = coerce
|
||||
prop ∷ ∀ a b. Castable a b => a -> b
|
||||
prop = cast
|
||||
|
||||
type Animate =
|
||||
CSS
|
||||
@ -139,8 +139,8 @@ type PanInfo =
|
||||
type OnDragEnd =
|
||||
EffectFn2 Event PanInfo Unit
|
||||
|
||||
onDragEnd ∷ ∀ coercible. Coercible OnDragEnd coercible => (Event -> PanInfo -> Effect Unit) -> coercible
|
||||
onDragEnd fn2 = coerce ((mkEffectFn2 fn2) ∷ OnDragEnd)
|
||||
onDragEnd ∷ ∀ coercible. Castable OnDragEnd coercible => (Event -> PanInfo -> Effect Unit) -> coercible
|
||||
onDragEnd fn2 = cast ((mkEffectFn2 fn2) ∷ OnDragEnd)
|
||||
|
||||
type MotionPropsF f r =
|
||||
( initial ∷ f Initial
|
||||
@ -160,23 +160,23 @@ type MotionPropsF f r =
|
||||
type MotionProps r =
|
||||
MotionPropsF Id r
|
||||
|
||||
animate ∷ ∀ a. Coercible a Animate => a -> Animate
|
||||
animate = coerce
|
||||
animate ∷ ∀ a. Castable a Animate => a -> Animate
|
||||
animate = cast
|
||||
|
||||
initial ∷ ∀ a. Coercible a Initial => a -> Initial
|
||||
initial = coerce
|
||||
initial ∷ ∀ a. Castable a Initial => a -> Initial
|
||||
initial = cast
|
||||
|
||||
transition ∷ ∀ r. { | r } -> Transition
|
||||
transition = coerce <<< css
|
||||
transition = cast <<< css
|
||||
|
||||
exit ∷ ∀ a. Coercible a Exit => a -> Exit
|
||||
exit = coerce
|
||||
exit ∷ ∀ a. Castable a Exit => a -> Exit
|
||||
exit = cast
|
||||
|
||||
variants ∷ ∀ r. { | r } -> Variants
|
||||
variants = coerce <<< css
|
||||
variants = cast <<< css
|
||||
|
||||
layout ∷ ∀ a. Coercible a Layout => a -> Layout
|
||||
layout = coerce
|
||||
layout ∷ ∀ a. Castable a Layout => a -> Layout
|
||||
layout = cast
|
||||
|
||||
data MakeVariantLabel
|
||||
= MakeVariantLabel
|
||||
@ -206,12 +206,12 @@ h1 = h1Impl
|
||||
|
||||
withMotion ∷
|
||||
∀ result baseProps motionSubset.
|
||||
Union baseProps (MotionProps ()) result => Nub result result => Coercible motionSubset { | MotionProps () } => Record baseProps -> motionSubset -> Record result
|
||||
withMotion old new = disjointUnion old ((coerce new) ∷ { | MotionProps () })
|
||||
Union baseProps (MotionProps ()) result => Nub result result => Castable motionSubset { | MotionProps () } => Record baseProps -> motionSubset -> Record result
|
||||
withMotion old new = disjointUnion old ((cast new) ∷ { | MotionProps () })
|
||||
|
||||
motion ∷
|
||||
∀ result baseProps motionSubset.
|
||||
Union baseProps (MotionProps ()) result => Nub result result => Coercible motionSubset { | MotionProps () } => motionSubset -> Record baseProps -> Record result
|
||||
Union baseProps (MotionProps ()) result => Nub result result => Castable motionSubset { | MotionProps () } => motionSubset -> Record baseProps -> Record result
|
||||
motion = flip withMotion
|
||||
|
||||
infixr 7 withMotion as >>
|
||||
|
@ -6,10 +6,10 @@ import React.Basic.Emotion as Emotion
|
||||
import React.Basic.Hooks (JSX, ReactComponent)
|
||||
import React.Basic.Hooks as Hooks
|
||||
import Record as Record
|
||||
import Untagged.Coercible (class Coercible, coerce)
|
||||
import Untagged.Castable (class Castable, cast)
|
||||
|
||||
yogaElement ∷ ∀ allProps givenProps. Coercible givenProps (Record allProps) => ReactComponent (Record allProps) -> givenProps -> JSX
|
||||
yogaElement el' props = Hooks.element el' (coerce props)
|
||||
yogaElement ∷ ∀ allProps givenProps. Castable givenProps (Record allProps) => ReactComponent (Record allProps) -> givenProps -> JSX
|
||||
yogaElement el' props = Hooks.element el' (cast props)
|
||||
|
||||
el ∷
|
||||
∀ props.
|
||||
|
@ -2,7 +2,7 @@ module Yoga.Block.Atom.CodeInput.Style where
|
||||
|
||||
import Yoga.Prelude.Style
|
||||
import Data.Interpolate (i)
|
||||
import Untagged.Coercible (coerce)
|
||||
import Untagged.Castable (cast)
|
||||
import Yoga.Block.Container.Style (colour)
|
||||
|
||||
type Props f r =
|
||||
@ -11,7 +11,7 @@ type Props f r =
|
||||
)
|
||||
|
||||
codeInput ∷ ∀ p. { maxLength ∷ Int | Props Id p } -> Style
|
||||
codeInput props = styles <>? coerce props.css
|
||||
codeInput props = styles <>? cast props.css
|
||||
where
|
||||
styles =
|
||||
css
|
||||
@ -24,7 +24,7 @@ codeInput props = styles <>? coerce props.css
|
||||
, fontFamily: str "var(--monoFont)"
|
||||
, fontSize: str "var(--s0)"
|
||||
, lineHeight: str "var(--s0)"
|
||||
, width: str $ i "calc(" (coerce props.maxLength ?|| 10) "ch + 4.3 * var(--s-5))"
|
||||
, width: str $ i "calc(" (cast props.maxLength ?|| 10) "ch + 4.3 * var(--s-5))"
|
||||
, padding: str "calc(var(--s-5) - 1px)"
|
||||
, color: str colour.text
|
||||
, "&:focus":
|
||||
|
@ -6,7 +6,7 @@ import Data.Foldable (class Foldable, foldMap, foldl, foldr)
|
||||
import Data.Maybe (Maybe, maybe)
|
||||
import Data.Newtype (class Newtype)
|
||||
import Unsafe.Coerce (unsafeCoerce)
|
||||
import Untagged.Coercible (class Coercible)
|
||||
import Untagged.Castable (class Castable)
|
||||
import Untagged.Union (UndefinedOr, defined, fromUndefinedOr, maybeToUor, uorToMaybe)
|
||||
|
||||
type Id a =
|
||||
@ -44,7 +44,7 @@ instance functorOptionalProp ∷ Functor OptionalProp where
|
||||
instance altOptionalProp ∷ Alt OptionalProp where
|
||||
alt op1 op2 = maybeToOp $ (opToMaybe op1) <|> (opToMaybe op2)
|
||||
|
||||
instance coercibleOptionalProp ∷ Coercible a (OptionalProp a)
|
||||
instance coercibleOptionalProp ∷ Castable a (OptionalProp a)
|
||||
|
||||
getOr ∷ ∀ a. a -> OptionalProp a -> a
|
||||
getOr default (OptionalProp o) = fromUndefinedOr default o
|
||||
|
@ -16,7 +16,7 @@ import React.Basic.Emotion as E
|
||||
import React.Basic.Events (handler_)
|
||||
import React.Basic.Hooks (reactComponent, useState)
|
||||
import React.Basic.Hooks as React
|
||||
import Untagged.Coercible (coerce)
|
||||
import Untagged.Castable (cast)
|
||||
import Yoga (el, styled)
|
||||
import Yoga.Block.Container.Style as Styles
|
||||
import Yoga.Block.Internal (_0)
|
||||
@ -125,8 +125,8 @@ layoutTrans = do
|
||||
let
|
||||
ava1 =
|
||||
el M.div
|
||||
{ layout: coerce true
|
||||
, layoutId: coerce "ava"
|
||||
{ layout: cast true
|
||||
, layoutId: cast "ava"
|
||||
, key: "ava"
|
||||
, onClick: handler_ (setSidebarOpen not)
|
||||
, transition: M.transition { delay: 0.2, type: "spring", damping: 30, stiffness: 200 }
|
||||
@ -143,8 +143,8 @@ layoutTrans = do
|
||||
[]
|
||||
ava2 =
|
||||
el M.div
|
||||
{ layout: coerce true
|
||||
, layoutId: coerce "ava"
|
||||
{ layout: cast true
|
||||
, layoutId: cast "ava"
|
||||
, key: "ava"
|
||||
, onClick: handler_ (setSidebarOpen not)
|
||||
, style:
|
||||
|
Loading…
Reference in New Issue
Block a user