on master help sign in
Update Examples/elm-yesod to better match online interactive examples
346ff6bngunn
Examples/elm-yesod/elm_source/clock.elm+2−4
@@ -1,8 +1,6 @@
1
1
2−import Signal.Time (every)
3−
4hand clr len time =
2hand clr len time =
5− let t = pi * time / 30 - pi / 2 in
3+ let t = pi * inSeconds time / 30 - pi / 2 in
6 solid clr $ line [(200,200), (200 + len * cos t, 200 + len * sin t)]
4 solid clr $ line [(200,200), (200 + len * cos t, 200 + len * sin t)]
7
5
8clock t = collage 400 400 [ filled (rgb 96 176 224) $ ngon 12 110 (200, 200)
6clock t = collage 400 400 [ filled (rgb 96 176 224) $ ngon 12 110 (200, 200)
@@ -10,4 +8,4 @@ clock t = collage 400 400 [ filled (rgb 96 176 224) $ ngon 12 110 (200, 200)
10 , hand black 100 (t/60)
8 , hand black 100 (t/60)
11 , hand black 60 (t/720) ]
9 , hand black 60 (t/720) ]
12
10
13−main = lift clock (every 1)
11+main = lift clock (every second)
Examples/elm-yesod/elm_source/index.elm+12−12
@@ -1,11 +1,11 @@
1−title w = size w 60 . box 4 . text . header . toText $ "Elm-Yesod"
1+title w = size w 60 . text . header . toText $ "Elm-Yesod"
2
2
3lightGrey = rgb 240 241 244
3lightGrey = rgb 240 241 244
4mediumGrey = rgb 216 221 225
4mediumGrey = rgb 216 221 225
5heading outer inner =
5heading outer inner =
6− color mediumGrey . size outer 61 . box 1 .
6+ color mediumGrey . size outer 61 .
7− color lightGrey . size outer 60 . box 5 .
7+ color lightGrey . size outer 60 .
8− size inner 60 . box 5 $ title inner
8+ size inner 60 $ title inner
9
9
10skeleton body outer =
10skeleton body outer =
11 let inner = if outer < 820 then outer - 20 else 800 in
11 let inner = if outer < 820 then outer - 20 else 800 in
@@ -19,17 +19,17 @@ section = text . bold . Text.height (5/4) . toText
19
19
20info w = List.map (\f -> f ()) . List.intersperse (\x -> plainText "&nbsp;") . List.map ((\e x -> e) . width w) $
20info w = List.map (\f -> f ()) . List.intersperse (\x -> plainText "&nbsp;") . List.map ((\e x -> e) . width w) $
21 [ section "Written in Elm, served with Yesod"
21 [ section "Written in Elm, served with Yesod"
22− , text $ toText "This page is written in " ++ link "http://elm-lang.org/" (toText "Elm") ++
22+ , text $ toText "This page is written in " ++ Text.link "http://elm-lang.org/" (toText "Elm") ++
23− toText " and served using the " ++
23+ toText " and served using the " ++
24− link "http://yesodweb.com/" (toText "Yesod Web Framework") ++
24+ Text.link "http://yesodweb.com/" (toText "Yesod Web Framework") ++
25 toText ". Since you are looking at this page it is safe to assume that you already have the example code. "
25 toText ". Since you are looking at this page it is safe to assume that you already have the example code. "
26 , text $ toText "Type-safe URLs are rendered using simple QuasiQuoter variable interpolation."
26 , text $ toText "Type-safe URLs are rendered using simple QuasiQuoter variable interpolation."
27 , section "More examples:"
27 , section "More examples:"
28− , text $ toText "- " ++ link "@{MouseR}" (toText "A simple mouse input example")
28+ , text $ toText "- " ++ Text.link "@{MouseR}" (toText "A simple mouse input example")
29− , text $ toText "- " ++ link "@{ClockR}" (toText "An animated analog clock")
29+ , text $ toText "- " ++ Text.link "@{ClockR}" (toText "An animated analog clock")
30− , text $ toText "- " ++ link "@{ShapesR}" (toText "Some simple rendered shapes")
30+ , text $ toText "- " ++ Text.link "@{ShapesR}" (toText "Some simple rendered shapes")
31 ]
31 ]
32−
32+
33−body outer inner = width outer . box 2 . flow down . (:) (plainText "&nbsp;") $ info inner
33+body outer inner = width outer . flow down . (:) (plainText "&nbsp;") $ info inner
34
34
35main = lift (skeleton body) Window.width
35main = lift (skeleton body) Window.width
Examples/elm-yesod/elm_source/mouse.elm+6−8
@@ -1,15 +1,13 @@
1
1
2-- Move your mouse around above the canvas!
2-- Move your mouse around above the canvas!
3
3
4−import Signal.Mouse (position)
5−import Signal.Window (dimensions)
6−
7myBlue = rgb 0 85 170
4myBlue = rgb 0 85 170
8−myGreen = rgba 28 267 85 (1/2)
5+myGreen = rgba 28 267 85 0.5
9
6
10scene (x,y) (w,h) =
7scene (x,y) (w,h) =
8+ collage w h
11− collage w h [ filled myBlue . rotate ((x+y)/1000) $ ngon 4 100 (200,200)
9+ [ rotate (toFloat (x+y) / 1000) (filled myBlue (ngon 4 100 (200,200)))
12− , filled myGreen $ ngon 5 30 (x,y)
10+ , filled myGreen (ngon 5 30 (x,y))
13− ]
11+ ]
14
12
15−main = lift2 scene position dimensions
13+main = lift2 scene Mouse.position Window.dimensions