diff options
author | Yorhel <git@yorhel.nl> | 2019-11-04 11:52:45 +0100 |
---|---|---|
committer | Yorhel <git@yorhel.nl> | 2019-11-10 12:44:55 +0100 |
commit | de6df4ab815a4f4447122d7f19888afd1b3e50ec (patch) | |
tree | 2eb3ce6ba9ebaf0d6c5fa588b7d2e4c4f87bc684 /elm/Lib | |
parent | 6821b9ab3f3b24e4d635a0763122d0ed2b1c0b72 (diff) |
ulist: Add (nonfunctional) releases + options UI; More consistent naming
Diffstat (limited to 'elm/Lib')
-rw-r--r-- | elm/Lib/Html.elm | 10 | ||||
-rw-r--r-- | elm/Lib/Util.elm | 5 |
2 files changed, 15 insertions, 0 deletions
diff --git a/elm/Lib/Html.elm b/elm/Lib/Html.elm index 770e9142..6e67cefb 100644 --- a/elm/Lib/Html.elm +++ b/elm/Lib/Html.elm @@ -6,6 +6,8 @@ import Html.Events exposing (..) import Json.Decode as JD import List import Lib.Api as Api +import Lib.Util exposing (..) +import Gen.Types as T -- onClick with stopPropagation & preventDefault @@ -165,3 +167,11 @@ formField lbl cont = txt -> genlbl (String.concat txt) , td (class "field" :: if lbl == "none" then [ colspan 2 ] else []) cont ] + + + +langIcon : String -> Html m +langIcon l = abbr [ class "icons lang", class l, title (Maybe.withDefault "" <| lookup l T.languages) ] [ text " " ] + +releaseTypeIcon : String -> Html m +releaseTypeIcon t = abbr [ class ("icons rt"++t), title (Maybe.withDefault "" <| lookup t T.releaseTypes) ] [ text " " ] diff --git a/elm/Lib/Util.elm b/elm/Lib/Util.elm index 186cf365..b86fcbad 100644 --- a/elm/Lib/Util.elm +++ b/elm/Lib/Util.elm @@ -30,3 +30,8 @@ hasDuplicates l = case List.foldr step (Just Dict.empty) l of Nothing -> True Just _ -> False + + +-- Haskell's 'lookup' - find an entry in an association list +lookup : a -> List (a,b) -> Maybe b +lookup n l = List.filter (\(a,_) -> a == n) l |> List.head |> Maybe.map Tuple.second |