Added link to external profile in account view (#125)

* Added link to external profile in account view

* Used helpers

* Added boolean parameter for accountLink / accountAvatarLink
This commit is contained in:
Nicolas Lœuillet 2017-05-03 15:08:10 +02:00 committed by GitHub
parent 3b67a20909
commit ab5e7bfbaf
5 changed files with 45 additions and 25 deletions

View File

@ -77,7 +77,7 @@ followButton currentUser relationship account =
followView : CurrentUser -> Maybe Relationship -> Account -> Html Msg
followView currentUser relationship account =
div [ class "follow-entry" ]
[ Common.accountAvatarLink account
[ Common.accountAvatarLink False account
, div [ class "userinfo" ]
[ strong []
[ a
@ -152,9 +152,9 @@ accountView currentUser account relationship panelContent =
]
[ div [ class "opacity-layer" ]
[ followButton currentUser relationship account
, img [ src account.avatar ] []
, Common.accountAvatarLink True account
, span [ class "account-display-name" ] [ text account.display_name ]
, span [ class "account-username" ] [ text ("@" ++ account.username) ]
, span [ class "account-username" ] [ Common.accountLink True account ]
, span [ class "account-note" ] (formatContent account.note [])
]
]

View File

@ -14,23 +14,43 @@ import Types exposing (..)
import View.Events exposing (..)
accountLink : Account -> Html Msg
accountLink account =
a
[ href account.url
, onClickWithPreventAndStop (LoadAccount account.id)
]
[ text <| "@" ++ account.username ]
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 ]
accountAvatarLink : Account -> Html Msg
accountAvatarLink account =
a
[ href account.url
, onClickWithPreventAndStop (LoadAccount account.id)
, title <| "@" ++ account.username
]
[ img [ class "avatar", src account.avatar ] [] ]
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 ] [] ]
closeablePanelheading : String -> String -> String -> Msg -> Html Msg

View File

@ -78,8 +78,8 @@ currentUserView currentUser =
case currentUser of
Just currentUser ->
div [ class "current-user" ]
[ Common.accountAvatarLink currentUser
, div [ class "username" ] [ Common.accountLink currentUser ]
[ Common.accountAvatarLink False currentUser
, div [ class "username" ] [ Common.accountLink False currentUser ]
, p [ class "status-text" ] <| formatContent currentUser.note []
]

View File

@ -46,11 +46,11 @@ filterNotifications filter notifications =
notificationHeading : List Account -> String -> String -> Html Msg
notificationHeading accounts str iconType =
div [ class "status-info" ]
[ div [ class "avatars" ] <| List.map Common.accountAvatarLink accounts
[ div [ class "avatars" ] <| List.map (Common.accountAvatarLink False) accounts
, p [ class "status-info-text" ] <|
List.intersperse (text " ")
[ Common.icon iconType
, span [] <| List.intersperse (text ", ") (List.map Common.accountLink accounts)
, span [] <| List.intersperse (text ", ") (List.map (Common.accountLink False) accounts)
, text str
]
]
@ -78,8 +78,8 @@ notificationFollowView currentUser { accounts } =
let
profileView account =
div [ class "status follow-profile" ]
[ Common.accountAvatarLink account
, div [ class "username" ] [ Common.accountLink account ]
[ Common.accountAvatarLink False account
, div [ class "username" ] [ Common.accountLink False account ]
, p
[ class "status-text"
, onClick <| LoadAccount account.id

View File

@ -217,7 +217,7 @@ statusView context ({ account, content, media_attachments, reblog, mentions } as
Nothing ->
div [ class "status" ]
[ Common.accountAvatarLink account
[ Common.accountAvatarLink False account
, div [ class "username" ]
[ a accountLinkAttributes
[ text account.display_name