2017-05-02 02:27:01 -04:00
|
|
|
module View.Common
|
|
|
|
exposing
|
|
|
|
( accountAvatarLink
|
|
|
|
, accountLink
|
|
|
|
, closeablePanelheading
|
|
|
|
, icon
|
|
|
|
, justifiedButtonGroup
|
2017-05-05 11:26:49 -04:00
|
|
|
, loadMoreBtn
|
2017-05-02 02:27:01 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
import Html exposing (..)
|
|
|
|
import Html.Attributes exposing (..)
|
|
|
|
import Mastodon.Model exposing (..)
|
|
|
|
import Types exposing (..)
|
|
|
|
import View.Events exposing (..)
|
|
|
|
|
|
|
|
|
2017-05-03 09:08:10 -04:00
|
|
|
accountLink : Bool -> Account -> Html Msg
|
|
|
|
accountLink external account =
|
|
|
|
let
|
|
|
|
accountHref =
|
|
|
|
if external then
|
|
|
|
target "_blank"
|
|
|
|
else
|
|
|
|
onClickWithPreventAndStop (LoadAccount account.id)
|
|
|
|
in
|
|
|
|
a
|
|
|
|
[ href account.url
|
|
|
|
, accountHref
|
|
|
|
]
|
|
|
|
[ text <| "@" ++ account.username ]
|
2017-05-02 02:27:01 -04:00
|
|
|
|
|
|
|
|
2017-05-03 09:08:10 -04:00
|
|
|
accountAvatarLink : Bool -> Account -> Html Msg
|
|
|
|
accountAvatarLink external account =
|
|
|
|
let
|
|
|
|
accountHref =
|
|
|
|
if external then
|
|
|
|
target "_blank"
|
|
|
|
else
|
|
|
|
onClickWithPreventAndStop (LoadAccount account.id)
|
|
|
|
|
|
|
|
avatarClass =
|
|
|
|
if external then
|
|
|
|
""
|
|
|
|
else
|
|
|
|
"avatar"
|
|
|
|
in
|
|
|
|
a
|
|
|
|
[ href account.url
|
|
|
|
, accountHref
|
|
|
|
, title <| "@" ++ account.username
|
|
|
|
]
|
|
|
|
[ img [ class avatarClass, src account.avatar ] [] ]
|
2017-05-02 02:27:01 -04:00
|
|
|
|
|
|
|
|
|
|
|
closeablePanelheading : String -> String -> String -> Msg -> Html Msg
|
|
|
|
closeablePanelheading context iconName label onClose =
|
|
|
|
div [ class "panel-heading" ]
|
|
|
|
[ div [ class "row" ]
|
|
|
|
[ a
|
|
|
|
[ href "", onClickWithPreventAndStop <| ScrollColumn ScrollTop context ]
|
|
|
|
[ div [ class "col-xs-9 heading" ] [ icon iconName, text label ] ]
|
|
|
|
, div [ class "col-xs-3 text-right" ]
|
|
|
|
[ a
|
|
|
|
[ href "", onClickWithPreventAndStop onClose ]
|
|
|
|
[ icon "remove" ]
|
|
|
|
]
|
|
|
|
]
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
icon : String -> Html Msg
|
|
|
|
icon name =
|
|
|
|
i [ class <| "glyphicon glyphicon-" ++ name ] []
|
|
|
|
|
|
|
|
|
2017-05-03 11:24:31 -04:00
|
|
|
justifiedButtonGroup : String -> List (Html Msg) -> Html Msg
|
|
|
|
justifiedButtonGroup cls buttons =
|
|
|
|
div [ class <| "btn-group btn-group-justified " ++ cls ] <|
|
2017-05-02 02:27:01 -04:00
|
|
|
List.map (\b -> div [ class "btn-group" ] [ b ]) buttons
|
2017-05-05 11:26:49 -04:00
|
|
|
|
|
|
|
|
|
|
|
loadMoreBtn : Timeline -> Html Msg
|
|
|
|
loadMoreBtn timeline =
|
|
|
|
case timeline.links.next of
|
|
|
|
Just next ->
|
|
|
|
li [ class "list-group-item load-more text-center" ]
|
|
|
|
[ a
|
|
|
|
[ href next
|
|
|
|
, onClickWithPreventAndStop <| LoadNext timeline
|
|
|
|
]
|
|
|
|
[ text "Load more" ]
|
|
|
|
]
|
|
|
|
|
|
|
|
Nothing ->
|
|
|
|
text ""
|