Skip to content

Commit 95a9796

Browse files
committed
Back to css prop api
1 parent 5c88c0e commit 95a9796

File tree

2 files changed

+18
-20
lines changed

2 files changed

+18
-20
lines changed

examples/basic/src/Basic.purs

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ type SlatProps
4646
, borderColor :: String
4747
, className :: String
4848
, content :: Array JSX
49+
, css :: E.Style
4950
}
5051

5152
slatDefaults :: SlatProps
@@ -54,6 +55,7 @@ slatDefaults =
5455
, borderColor: "grey"
5556
, className: ""
5657
, content: mempty
58+
, css: mempty
5759
}
5860

5961
mkSlat :: Effect (ReactComponent SlatProps)
@@ -62,15 +64,15 @@ mkSlat = do
6264
component "Slat" \props ->
6365
pure
6466
$ E.element
65-
( E.merge
67+
box
68+
{ className: props.className
69+
, css:
70+
E.merge
6671
[ border props
6772
, text L
6873
, E.css { flexDirection: E.str "row" }
6974
, spaceChildrenEvenly
7075
]
71-
)
72-
box
73-
{ className: props.className
7476
, content: props.content
7577
}
7678

@@ -85,17 +87,17 @@ mkEx = do
8587
{ content = map (R.span_ <<< pure <<< R.text) [ "Hello", "World" ]
8688
}
8789
, E.element
88-
( E.merge
89-
[ E.css
90-
{ padding: E.int 4
91-
, maxWidth: E.int 200
92-
}
93-
, text S
94-
]
95-
)
9690
slat
9791
slatDefaults
9892
{ content = map (R.span_ <<< pure <<< R.text) [ "Hello", "World" ]
93+
, css =
94+
E.merge
95+
[ E.css
96+
{ padding: E.int 4
97+
, maxWidth: E.int 200
98+
}
99+
, text S
100+
]
99101
}
100102
]
101103

@@ -123,8 +125,9 @@ mkBox :: Effect (ReactComponent BoxProps)
123125
mkBox = do
124126
component "Box" \props ->
125127
pure
126-
$ E.element boxStyle R.div'
128+
$ E.element R.div'
127129
{ className: props.className
130+
, css: boxStyle
128131
, children: props.content
129132
}
130133

src/React/Basic/Emotion.purs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,8 @@ import Control.Monad.Except (runExcept)
2626
import Data.Array as Array
2727
import Data.Either (Either(..))
2828
import Data.Function.Uncurried (Fn2, runFn2)
29-
import Data.Symbol (SProxy(..))
3029
import Foreign as F
31-
import Prim.Row (class Lacks)
3230
import React.Basic (JSX, ReactComponent)
33-
import Record as Record
3431
import Type.Row.Homogeneous (class Homogeneous)
3532
import Unsafe.Coerce (unsafeCoerce)
3633
import Web.HTML.History (URL(..))
@@ -87,12 +84,10 @@ class IsStyleProperty a where
8784
-- | `css` prop.
8885
element ::
8986
forall props.
90-
Lacks "css" props =>
91-
Style ->
9287
ReactComponent { className :: String | props } ->
93-
{ className :: String | props } ->
88+
{ className :: String, css :: Style | props } ->
9489
JSX
95-
element s c p = runFn2 element_ c (Record.insert (SProxy :: _ "css") s p)
90+
element = runFn2 element_
9691

9792
foreign import element_ ::
9893
forall props.

0 commit comments

Comments
 (0)