From cd3b37adebca99138fad1acca37908183036ace9 Mon Sep 17 00:00:00 2001 From: Joris Guyonvarch Date: Mon, 16 Mar 2015 00:15:05 +0100 Subject: Initial commit, can create and name 5 minute timers, can toggle running state --- src/View/Timer.elm | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 src/View/Timer.elm (limited to 'src/View/Timer.elm') diff --git a/src/View/Timer.elm b/src/View/Timer.elm new file mode 100644 index 0000000..668bf08 --- /dev/null +++ b/src/View/Timer.elm @@ -0,0 +1,37 @@ +module View.Timer + ( timerView + ) where + +import Html (..) +import Html.Attributes (..) +import Html.Events (..) +import String +import Time (Time) +import Signal + +import Model.Timer (..) +import Model.Id (..) + +import Update.Update (..) +import Update.UpdateTimer (..) + +timerView : (Id, Timer) -> Html +timerView (id, timer) = + div + [ class "timer" ] + [ div + [ class "block" ] + [ text timer.name ] + , div + [ class <| "timerTime block" ++ (if timer.isRunning then " isRunning" else "") + , onClick (Signal.send updates (UpdateTimer id ToggleRunning)) + ] + [ text (timeView timer.time) ] + ] + +timeView : Time -> String +timeView time = + let totalSeconds = truncate (time / 1000) + totalMinutes = totalSeconds // 60 + restSeconds = totalSeconds `rem` 60 + in (toString totalMinutes) ++ ":" ++ (String.padLeft 2 '0' (toString restSeconds)) -- cgit v1.2.3