-
Notifications
You must be signed in to change notification settings - Fork 0
/
Box.purs
55 lines (49 loc) · 1.4 KB
/
Box.purs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
module Example.Box where
import Prelude
import Data.Record.Builder as Record
import Example.Theme.Color (Color) as Theme
import Example.Theme.Color as Color
import Example.Theme.FontSize (FontSize) as Theme
import Example.Theme.FontSize as FontSize
import Example.Theme.Space (Space) as Theme
import Example.Theme.Space as Space
import Halogen.HTML as HH
import Styled.Components as Styled
import Styled.System (ColorState, FontSizeState, SpaceState, WidthState)
import Styled.System as System
import Type.Row (type (+))
type State s =
( ColorState Theme.Color
+ FontSizeState Theme.FontSize
+ SpaceState Theme.Space
+ WidthState
+ s
)
defaultState :: { | State () }
defaultState = Record.build builder {}
where
builder :: Record.Builder {} { | State () }
builder =
Record.merge System.defaultColorState
<<< Record.merge System.defaultFontSizeState
<<< Record.merge System.defaultSpaceState
<<< Record.merge System.defaultWidthState
box
:: forall p i
. ({ | State () } -> { | State () })
-> Array (HH.IProp _ i)
-> Array (HH.HTML p i)
-> HH.HTML p i
box mkArgs = mkArgs defaultState #
Styled.element HH.div
[ System.color Color.toValue
, System.fontSize FontSize.toValue
, System.space Space.toValue
, System.width
]
box_
:: forall p i
. ({ | State () } -> { | State () })
-> Array (HH.HTML p i)
-> HH.HTML p i
box_ mkArgs = box mkArgs []