This is an alternative site for discovering Elm packages. You may be looking for the official Elm package site instead.
1.0.0 1.0.1
README

President

President turns a List (Signal Element) into a presentation that you can navigate with arrow keys. That's about it.

present: List (Signal Element) -> Signal Element

A signal that displays each of the signals in the list as a slide. This may be navigated with the arrow keys.

voidSlide: Element

A default almost-empty slide that is needed as workaround for a bug in Elm.

module President(present,voidSlide) where

{-| 

President turns a `List (Signal Element)` into a presentation
that you can navigate with arrow keys. That's about it.

@docs present, voidSlide

-}

import Text
import Text exposing (..)
import List exposing (..)
import Signal exposing (Signal, constant, foldp)
import Graphics.Element exposing (..)
import Graphics.Collage exposing (..)
import Keyboard
import Debug
import Signal.Extra exposing (applyMany)
import Window exposing (dimensions)

type Control = Top | Bottom | Previous | Next | None

-- primary state update function
updateSlide: Int -> Control -> Int -> Int
updateSlide lastSlide control current = 
  let nextSlide = case control of
        Top -> 0
        Previous -> current - 1
        Next -> current + 1
        Bottom -> lastSlide
        None -> current
  in clamp 0 lastSlide nextSlide 

controlAction {x,y} = case (x,y) of
  (-1, _) -> Previous
  (1, _) -> Next
  (_, 1) -> Top
  (_, -1) -> Bottom
  _ -> None

chooseSlide: a -> Int -> List a -> a
chooseSlide default page slides = case drop page slides of
  [] -> default
  slide :: _ -> slide

positioning (w,h) slide = container w h middle slide 

{-| A default almost-empty slide that is needed as workaround for a bug in Elm. -}
voidSlide: Element
voidSlide = fromString "..." |> Text.height 180 |> centered

-- signals

--displaySlide: Int -> Signal Element
displaySlide slides page = 
  case slides of
    [] -> voidSlide
    s :: t -> s

{-|
A signal that displays each of the signals in the list
as a slide. This may be navigated with the arrow keys.
-}
present: List (Signal Element) -> Signal Element
present slides = 
  let lastSlide = length slides - 1
      controls = Signal.map controlAction Keyboard.arrows
      currentSlide = foldp (updateSlide lastSlide) 0 controls
      theActualSlideSignal = applyMany (Signal.map (chooseSlide voidSlide) currentSlide) slides
  in Signal.map2 positioning dimensions theActualSlideSignal