From 21ccfe7e52e446fab5fea0078f56e95889a1caba Mon Sep 17 00:00:00 2001 From: Ryan Fox Date: Sat, 30 Jan 2021 02:13:25 +0000 Subject: [PATCH] Make whole status clickable This makes it possible to open statuses without status text. --- src/View/Status.elm | 71 +++++++++++++++++++++++---------------------- 1 file changed, 36 insertions(+), 35 deletions(-) diff --git a/src/View/Status.elm b/src/View/Status.elm index e87ca66..b44d070 100644 --- a/src/View/Status.elm +++ b/src/View/Status.elm @@ -150,41 +150,34 @@ statusActionsView status currentUser showApp = ] -statusContentView : String -> Status -> Bool -> Html Msg -statusContentView context status clickOpen = - let - statusTextEvents = - if clickOpen then - [ onClickWithStop <| OpenThread status ] - else - [] - in - case status.spoiler_text of - "" -> - div [ class "status-text" ] - [ div statusTextEvents <| formatContent status.content status.mentions - , attachmentListView context status - ] +statusContentView : String -> Status -> Html Msg +statusContentView context status = + case status.spoiler_text of + "" -> + div [ class "status-text" ] + [ div [] <| formatContent status.content status.mentions + , attachmentListView context status + ] - spoiler -> - -- Note: Spoilers are dealt with using pure CSS. - let - statusId = - "spoiler" ++ extractStatusId status.id ++ context - in - div [ class "status-text spoiled" ] - [ div - [ class "spoiler" - , onClickWithStop <| OpenThread status - ] - [ text status.spoiler_text ] - , input [ type_ "checkbox", id statusId, class "spoiler-toggler" ] [] - , label [ for statusId ] [ text "Reveal content" ] - , div [ class "spoiled-content" ] - [ div [] <| formatContent status.content status.mentions - , attachmentListView context status - ] + spoiler -> + -- Note: Spoilers are dealt with using pure CSS. + let + statusId = + "spoiler" ++ extractStatusId status.id ++ context + in + div [ class "status-text spoiled" ] + [ div + [ class "spoiler" + , onClickWithStop <| OpenThread status ] + [ text status.spoiler_text ] + , input [ type_ "checkbox", id statusId, class "spoiler-toggler" ] [] + , label [ for statusId ] [ text "Reveal content" ] + , div [ class "spoiled-content" ] + [ div [] <| formatContent status.content status.mentions + , attachmentListView context status + ] + ] statusEntryView : String -> String -> CurrentUser -> Status -> Html Msg @@ -214,6 +207,14 @@ statusEntryView context className currentUser status = statusView : String -> Status -> Bool -> Html Msg statusView context ({ account, content, media_attachments, reblog, mentions, pinned } as status) clickOpen = let + statusAttribs = + if clickOpen then + [ class "status" + , onClickWithStop <| OpenThread status + ] + else + [ class "status" ] + accountLinkAttributes = [ href <| "#account/" ++ account.id ] @@ -242,7 +243,7 @@ statusView context ({ account, content, media_attachments, reblog, mentions, pin ] Nothing -> - div [ class "status" ] + div statusAttribs [ pin , Common.accountAvatarLink False account , div [ class "username" ] @@ -251,5 +252,5 @@ statusView context ({ account, content, media_attachments, reblog, mentions, pin , span [ class "acct" ] [ text <| " @" ++ account.acct ] ] ] - , Lazy.lazy3 statusContentView context status clickOpen + , Lazy.lazy2 statusContentView context status ]