docbrown/app/views/users/_comments_section.html.erb
Marcy Sutton b04b5bcb57
Headings and alt text roundup (#11721)
* Adjust heading order

No skipping levels, adding an h1 for the homepage

* Add missing image alt text

* Update after PR review

* Update test snapshot

Co-authored-by: rhymes <rhymes@hey.com>
2020-12-04 09:41:45 -05:00

58 lines
2.2 KiB
Text

<% cache("user-profile-comments-#{@user.last_comment_at}-#{@user.id}-#{@comments.size}", expires_in: 2.days) do %>
<div class="profile-comment-card crayons-card mt-2 m:mt-0 mb-2">
<% if @comments.present? %>
<% if params[:view] == "comments" %>
<div class="crayons-card__header">
<h3 class="crayons-subtitle-2">
<% if @user.comments_count > 250 %>
Last 250 comments
<% else %>
All <%= @user.comments_count %> comments
<% end %>
</h3>
<div class="crayons-card__actions">
<a href="<%= @user.path %>" class="crayons-link--branded fs-base">
View all activity
</a>
</div>
</div>
<% else %>
<div class="crayons-card__header">
<h3 class="crayons-subtitle-2">
Recent comments
</h3>
</div>
<% end %>
<% end %>
<% @comments.each do |comment| %>
<% if comment.commentable.present? && comment.commentable.published && !comment.deleted %>
<a href="<%= comment.path %>" class="profile-comment-row ">
<h4 class="fw-bold fs-base m-0 mb-1">
<%= comment.commentable.title %>
</h4>
<div class="inline-flex items-center fs-s gap-2">
<p class="color-base-80">
<%= truncate(strip_tags(comment.processed_html), length: 64).html_safe %>
<p>
<small class="color-base-60 fs-s comment-date whitespace-nowrap">
<time datetime="<%= comment.decorate.published_timestamp %>"><%= comment.readable_publish_date %></time>
</small>
</div>
</a>
<% end %>
<% end %>
<% if params[:view] != "comments" && @user.comments_count > 250 %>
<div class="pt-3 pl-4 pb-3 pr-4">
<a href="<%= @user.path %>/comments" class="fs-base">
View last 250 Comments
</a>
</div>
<% elsif params[:view] != "comments" && @user.comments_count > 8 %>
<div class="py-3 px-4">
<a href="<%= @user.path %>/comments" class="fs-base">
View all <%= @user.comments_count %> comments
</a>
</div>
<% end %>
</div>
<% end %>