mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-09-29 16:18:22 +00:00
Using elm-format for all files
This commit is contained in:
@@ -1,10 +1,17 @@
|
||||
module Util.Html exposing (..)
|
||||
module Util.Html exposing
|
||||
( KeyCode(..)
|
||||
, classActive
|
||||
, intToKeyCode
|
||||
, onClickk
|
||||
, onKeyUp
|
||||
)
|
||||
|
||||
import Html exposing (Attribute)
|
||||
import Html.Attributes exposing (class)
|
||||
import Html.Events exposing (on, keyCode)
|
||||
import Html.Events exposing (keyCode, on)
|
||||
import Json.Decode as Decode
|
||||
|
||||
|
||||
type KeyCode
|
||||
= Up
|
||||
| Down
|
||||
@@ -12,29 +19,52 @@ type KeyCode
|
||||
| Right
|
||||
| Enter
|
||||
|
||||
intToKeyCode: Int -> Maybe KeyCode
|
||||
|
||||
intToKeyCode : Int -> Maybe KeyCode
|
||||
intToKeyCode code =
|
||||
case code of
|
||||
38 -> Just Up
|
||||
40 -> Just Down
|
||||
39 -> Just Right
|
||||
37 -> Just Left
|
||||
13 -> Just Enter
|
||||
_ -> Nothing
|
||||
38 ->
|
||||
Just Up
|
||||
|
||||
40 ->
|
||||
Just Down
|
||||
|
||||
39 ->
|
||||
Just Right
|
||||
|
||||
37 ->
|
||||
Just Left
|
||||
|
||||
13 ->
|
||||
Just Enter
|
||||
|
||||
_ ->
|
||||
Nothing
|
||||
|
||||
|
||||
onKeyUp : (Int -> msg) -> Attribute msg
|
||||
onKeyUp tagger =
|
||||
on "keyup" (Decode.map tagger keyCode)
|
||||
on "keyup" (Decode.map tagger keyCode)
|
||||
|
||||
|
||||
onClickk : msg -> Attribute msg
|
||||
onClickk msg =
|
||||
Html.Events.preventDefaultOn "click" (Decode.map alwaysPreventDefault (Decode.succeed msg))
|
||||
Html.Events.preventDefaultOn "click" (Decode.map alwaysPreventDefault (Decode.succeed msg))
|
||||
|
||||
|
||||
alwaysPreventDefault : msg -> ( msg, Bool )
|
||||
alwaysPreventDefault msg =
|
||||
( msg, True )
|
||||
( msg, True )
|
||||
|
||||
classActive: Bool -> String -> Attribute msg
|
||||
|
||||
classActive : Bool -> String -> Attribute msg
|
||||
classActive active classes =
|
||||
class (classes ++ (if active then " active" else ""))
|
||||
class
|
||||
(classes
|
||||
++ (if active then
|
||||
" active"
|
||||
|
||||
else
|
||||
""
|
||||
)
|
||||
)
|
||||
|
Reference in New Issue
Block a user