1
0
Fork 0
tooty/src/View/Viewer.elm

50 lines
1.5 KiB
Elm
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

module View.Viewer exposing (viewerView)
import Html exposing (..)
import Html.Attributes exposing (..)
import Types exposing (..)
import Update.Viewer exposing (getPrevNext)
import View.Events exposing (..)
viewerView : Viewer -> Html Msg
viewerView ({ attachments, attachment } as viewer) =
let
( prev, next ) =
getPrevNext viewer
navLink label className target event =
case target of
Nothing ->
text ""
Just target ->
a
[ href ""
, class className
, onClickWithPreventAndStop event
]
[ text label ]
in
div
[ class "viewer"
, tabindex -1
, onClickWithPreventAndStop <| ViewerEvent CloseViewer
]
[ span [ class "close" ] [ text "×" ]
, navLink "" "prev" prev <| ViewerEvent NextAttachment
, case attachment.type_ of
"image" ->
img [ class "viewer-content", src attachment.url ] []
_ ->
video
[ class "viewer-content"
, preload "auto"
, autoplay True
, loop True
]
[ source [ src attachment.url ] [] ]
, navLink "" "next" next <| ViewerEvent NextAttachment
]