diff --git a/app/views/answerbox/_header.html.haml b/app/views/answerbox/_header.html.haml index 65db63a1..88c1485f 100644 --- a/app/views/answerbox/_header.html.haml +++ b/app/views/answerbox/_header.html.haml @@ -13,8 +13,11 @@ · %a{ href: question_path(a.question.user.screen_name, a.question.id) } = t(".answers", count: a.question.answer_count) - .answerbox__question-text - = question_markdown a.question.content + .answerbox__question-body{ data: { controller: "collapse" } } + .answerbox__question-text{ class: a.question.long? ? "collapsed" : "", data: { collapse_target: "content" } } + = question_markdown a.question.content + - if a.question.long? + = render "shared/collapse", type: "question" - if user_signed_in? .flex-shrink-0.ms-auto .btn-group diff --git a/app/views/application/_answerbox.html.haml b/app/views/application/_answerbox.html.haml index 6808daf4..16128606 100644 --- a/app/views/application/_answerbox.html.haml +++ b/app/views/application/_answerbox.html.haml @@ -3,16 +3,11 @@ - if @question.nil? = render "answerbox/header", a: a .card-body - - if display_all.nil? - .answerbox__answer-text - = markdown a.content.truncate(640, omission: " [...]", separator: /\s/) - - if a.content.length > 640 - %p - %a.btn.btn-primary{ href: answer_path(a.user.screen_name, a.id) } - = t(".read") - - else - .answerbox__answer-text + .answerbox__answer-body{ data: { controller: "collapse" } } + .answerbox__answer-text{ class: a.long? ? "collapsed" : "", data: { collapse_target: "content" } } = markdown a.content + - if a.long? + = render "shared/collapse", type: "answer" - if @user.nil? .row .col-sm-6.text-start.text-muted diff --git a/app/views/inbox/_entry.html.haml b/app/views/inbox/_entry.html.haml index bab43c53..fb9aaf3c 100644 --- a/app/views/inbox/_entry.html.haml +++ b/app/views/inbox/_entry.html.haml @@ -14,7 +14,11 @@ · %a{ href: question_path(i.question.user.screen_name, i.question.id) } = t(".answers", count: i.question.answer_count) - .answerbox__question-text= question_markdown i.question.content + .answerbox__question-body{ data: { controller: "collapse" } } + .answerbox__question-text{ class: i.question.long? ? "collapsed" : "", data: { collapse_target: "content" } } + = question_markdown i.question.content + - if i.question.long? + = render "shared/collapse", type: "question" - if i.question.user_id != current_user.id || current_user.has_cached_role?(:administrator) .flex-shrink-0.ms-auto .btn-group diff --git a/app/views/question/_question.html.haml b/app/views/question/_question.html.haml index 8015015a..44060561 100644 --- a/app/views/question/_question.html.haml +++ b/app/views/question/_question.html.haml @@ -13,7 +13,11 @@ = user_screen_name question.user, author_identifier: identifier, url: false - else = t("answerbox.header.asked_html", user: user_screen_name(question.user, author_identifier: identifier), time: time_tooltip(question)) - .answerbox__question-text= question_markdown question.content + .answerbox__question-body{ data: { controller: "collapse" } } + .answerbox__question-text{ class: question.long? ? "collapsed" : "", data: { collapse_target: "content" } } + = question_markdown question.content + - if question.long? + = render "shared/collapse", type: "question" - if user_signed_in? .flex-shrink-0.ms-auto .btn-group