aboutsummaryrefslogtreecommitdiff
path: root/src/View
diff options
context:
space:
mode:
authorJoris2016-09-04 21:21:11 +0200
committerJoris2016-09-04 21:21:31 +0200
commit973a039b54327df74396605410ea9abe19c8a4e7 (patch)
treec702564d17e0a490d56845027238eb4f231be785 /src/View
parent62fee9133f36f655c1ed83e0c2e85394f9948bf5 (diff)
Upgrade to elm 0.17.1
Diffstat (limited to 'src/View')
-rw-r--r--src/View/ActivatedClasses.elm15
-rw-r--r--src/View/Timer.elm171
-rw-r--r--src/View/View.elm67
3 files changed, 0 insertions, 253 deletions
diff --git a/src/View/ActivatedClasses.elm b/src/View/ActivatedClasses.elm
deleted file mode 100644
index 85b0841..0000000
--- a/src/View/ActivatedClasses.elm
+++ /dev/null
@@ -1,15 +0,0 @@
-module View.ActivatedClasses
- ( activatedClasses
- ) where
-
-import Html
-import Html.Attributes exposing (..)
-import List
-import String
-
-activatedClasses : List (Bool, String) -> Html.Attribute
-activatedClasses =
- class
- << String.concat
- << List.intersperse " "
- << List.filterMap (\(activated, str) -> if activated then Just str else Nothing)
diff --git a/src/View/Timer.elm b/src/View/Timer.elm
deleted file mode 100644
index 4672594..0000000
--- a/src/View/Timer.elm
+++ /dev/null
@@ -1,171 +0,0 @@
-module View.Timer
- ( timerView
- ) where
-
-import Html exposing (..)
-import Html.Attributes exposing (..)
-import Html.Events exposing (..)
-import Time exposing (Time)
-import Signal
-import Maybe
-import List
-import String
-
-import Model.Model exposing (..)
-import Model.Timer exposing (..)
-import Model.Edition.Edition exposing (..)
-import Model.Edition.NameEdition exposing (..)
-import Model.Edition.TimeEdition exposing (..)
-import Model.TimerState exposing (..)
-import Model.Id exposing (..)
-
-import Update.Update exposing (..)
-import Update.UpdateTimer exposing (..)
-
-import View.ActivatedClasses exposing (..)
-
-import Utils.Maybe exposing (..)
-
-timerView : Model -> (Id, Timer) -> Html
-timerView model (id, timer) =
- div
- [ [ (True, "timer")
- , (timer.state == Ringing, "isRinging")
- , (timer.state == Running, "isRunning")
- ]
- |> activatedClasses
- ]
- [ renderMaybeEdition model id Name (nameBlockReadOnly id timer) (nameBlockEdition id timer)
- , renderMaybeEdition model id Time (timeBlockReadOnly (id, timer)) (timeBlockEdition (id, timer))
- , playPauseTimer (id, timer)
- , stopTimer (id, timer)
- , removeTimer (id, timer)
- ]
-
-nameBlockReadOnly : Id -> Timer -> Html
-nameBlockReadOnly id timer =
- div
- [ class "name"
- , onClick actions.address (Edit id Name)
- ]
- [ text (timerName id timer) ]
-
-nameBlockEdition : Id -> Timer -> Edition -> Html
-nameBlockEdition id timer edition =
- div
- [ [ (True, "name edition")
- , (isEmpty edition, "empty")
- ]
- |> activatedClasses
- , onClick actions.address NoOp
- ]
- [ if isEmpty edition
- then
- text (timerName id timer)
- else
- edition.chars
- |> renderNameEdition
- |> flip String.append "_"
- |> text
- ]
-
-timerName : Id -> Timer -> String
-timerName id = Maybe.withDefault ("Timer " ++ toString id) << .name
-
-timeBlockReadOnly : (Id, Timer) -> Html
-timeBlockReadOnly (id, timer) =
- div
- [ class "time"
- , onClick actions.address (Edit id Time)
- ]
- [ timeWithProgressBar (id, timer) ]
-
-timeBlockEdition : (Id, Timer) -> Edition -> Html
-timeBlockEdition (id, timer) edition =
- div
- [ [ (True, "time edition")
- , (isEmpty edition, "empty")
- ]
- |> activatedClasses
- , onClick actions.address NoOp
- ]
- [ if isEmpty edition
- then
- timeWithProgressBar (id, timer)
- else
- text (editionView edition.chars)
- ]
-
-editionView : List Char -> String
-editionView numbers =
- let (minutes, seconds) = toMinutesAndSeconds numbers
- in minutes ++ " : " ++ seconds
-
-timeView : Time -> String
-timeView time =
- let totalSeconds = ceiling (time / 1000)
- totalMinutes = totalSeconds // 60
- restSeconds = totalSeconds `rem` 60
- in (String.padLeft 2 '0' (toString totalMinutes)) ++ " : " ++ (String.padLeft 2 '0' (toString restSeconds))
-
-timeWithProgressBar : (Id, Timer) -> Html
-timeWithProgressBar (id, timer) =
- div
- []
- [ span
- [ class "progressBar"
- , let width =
- 1 - timer.currentTime / timer.initialTime
- |> (*) 1020
- |> round
- |> toString
- |> flip String.append "px"
- in style [ ("width", width) ]
- , onClick actions.address (UpdateTimer id Stop)
- ]
- []
- , span
- [ class "text" ]
- [ text (timeView timer.currentTime) ]
- ]
-
-playPauseTimer : (Id, Timer) -> Html
-playPauseTimer (id, timer) =
- button
- [ class <| "playPause"
- , onClick actions.address (UpdateTimer id ToggleRunning)
- ]
- [ let icon = if timer.state == Running then "fa-pause" else "fa-play"
- in i
- [ class <| "fa fa-fw " ++ icon ]
- []
- ]
-
-stopTimer : (Id, Timer) -> Html
-stopTimer (id, timer) =
- button
- [ class <| "stop"
- , onClick actions.address (UpdateTimer id Stop)
- ]
- [ i [ class "fa fa-fw fa-stop" ] [] ]
-
-removeTimer : (Id, Timer) -> Html
-removeTimer (id, timer) =
- button
- [ class <| "remove"
- , onClick actions.address (RemoveTimer id)
- ]
- [ i [ class "fa fa-fw fa-remove" ] [] ]
-
-renderMaybeEdition : Model -> Id -> Kind -> Html -> (Edition -> Html) -> Html
-renderMaybeEdition model id kind readOnlyView editionView =
- let maybeEdition = filterMaybe (\edition -> edition.id == id) model.edition
- in case maybeEdition of
- Just edition ->
- if edition.kind == kind
- then
- editionView edition
- else
- readOnlyView
- Nothing ->
- readOnlyView
diff --git a/src/View/View.elm b/src/View/View.elm
deleted file mode 100644
index a69d662..0000000
--- a/src/View/View.elm
+++ /dev/null
@@ -1,67 +0,0 @@
-module View.View
- ( view
- ) where
-
-import Html exposing (..)
-import Html.Attributes exposing (..)
-import Html.Events exposing (..)
-import Signal
-import List
-import Dict
-import Json.Decode as Json
-
-import Model.Model exposing (..)
-import Model.Timer exposing (..)
-import Model.Id exposing (..)
-
-import Update.Update exposing (..)
-
-import View.Timer exposing (timerView)
-
-view : Model -> Html
-view model =
- div
- []
- [ title
- , model.timers
- |> Dict.toList
- |> List.sortBy (.creationTime << snd)
- |> timers model
- ]
-
-title : Html
-title =
- div
- [ class "headerBar" ]
- [ button
- [ onClick actions.address Initialize
- , class "title"
- ]
- [ text "Timer" ]
- , button
- [ onClick actions.address AddNewTimer
- , class "addTimer"
- ]
- [ i
- [ class "fa fa-fw fa-plus" ]
- []
- ]
- ]
-
-onEnter : Signal.Message -> Attribute
-onEnter message =
- on "keydown"
- (Json.customDecoder keyCode is13)
- (always message)
-
-is13 : Int -> Result String ()
-is13 code =
- if code == 13
- then Ok()
- else Err "Not the right key code"
-
-timers : Model -> List (Id, Timer) -> Html
-timers model timers =
- div
- [ class "timers" ]
- (List.map (timerView model) timers)