-
Notifications
You must be signed in to change notification settings - Fork 6
/
Transitions.hs
46 lines (31 loc) · 961 Bytes
/
Transitions.hs
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
module Example.Transitions where
import Effectful
import Example.Style as Style
import Web.Hyperbole
page :: (Hyperbole :> es) => Page es Contents
page = do
handle content $ do
pure $ row (pad 20) $ do
hyper Contents viewSmall
data Contents = Contents
deriving (Show, Read, ViewId)
data ContentsAction
= Expand
| Collapse
deriving (Show, Read, ViewAction)
instance HyperView Contents where
type Action Contents = ContentsAction
content :: (Hyperbole :> es) => Contents -> ContentsAction -> Eff es (View Contents ())
content _ Expand = do
pure viewBig
content _ Collapse = do
pure viewSmall
viewSmall :: View Contents ()
viewSmall = do
col (gap 10 . border 1 . pad 20 . transition 300 (Width 200)) $ do
el id "Small"
button Expand Style.btn "Expand"
viewBig :: View Contents ()
viewBig = col (gap 10 . border 1 . pad 20 . transition 300 (Width 400)) $ do
el_ "Expanded"
button Collapse Style.btn "Collapse"