Last active
October 2, 2015 21:49
-
-
Save ggb/c17de825a30293e05e5a to your computer and use it in GitHub Desktop.
Some simple slides using Elm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Slides where | |
import Markdown | |
import Keyboard | |
import Html exposing (Html) | |
-- Data | |
type alias Slide = String | |
type alias SlideZipper = ( List Slide, List Slide ) | |
slide1 : Slide | |
slide1 = """ | |
# First Slide | |
Text text text | |
""" | |
slide2 : Slide | |
slide2 = """ | |
# Second Slide | |
More text | |
![Eichhörnchen](http://tinyurl.com/oahq83h) | |
""" | |
slide3 : Slide | |
slide3 = """ | |
# Third Slide | |
Etc. etc. | |
""" | |
slides : List Slide | |
slides = [ slide1, slide2, slide3 ] | |
init : SlideZipper | |
init = ( [], slides ) | |
-- View | |
view : SlideZipper -> Html | |
view ( old, current ) = | |
let slide = Maybe.withDefault "" (List.head current) | |
in | |
Markdown.toHtml slide | |
-- Update | |
oldCase : SlideZipper -> SlideZipper | |
oldCase ( old, current ) = | |
case old of | |
(x::xs) -> | |
( xs, x::current ) | |
[] -> | |
( old, current ) | |
currentCase : SlideZipper -> SlideZipper | |
currentCase ( old, current ) = | |
case current of | |
(x::xs) -> | |
( x::old, xs ) | |
[] -> | |
( old, current ) | |
zipUpdate : { x : Int, y : Int } -> SlideZipper -> SlideZipper | |
zipUpdate keys zipper = | |
if | keys.x == -1 -> oldCase zipper | |
| keys.x == 1 -> currentCase zipper | |
| otherwise -> zipper | |
update : Signal SlideZipper | |
update = | |
Signal.foldp zipUpdate init Keyboard.arrows | |
main : Signal Html | |
main = | |
Signal.map view update |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment