docbrown/app/views/notifications/_aggregated_reactions.html.erb
yheuhtozr ffd8c9ed1b
actions and reactions i18n (#15058)
* actions and reactions i18n

* remove ja.yml

* Update en.yml

* Update fr.yml

* Update _actions.html.erb
2021-10-25 12:35:05 -06:00

47 lines
2.9 KiB
Text

<%# TODO: change to map of IDs %>
<% actors = siblings.map { |n| n["user"] }.uniq %>
<% reactable_data = notification.json_data["reaction"]["reactable"] %>
<div class="relative shrink-0 self-start">
<% if actors.size == 1 %>
<a href="<%= actors.first["path"] %>" class="crayons-avatar crayons-avatar--l m:crayons-avatar--xl" aria-hidden="true" tabindex="-1">
<img src="<%= actors.first["profile_image_90"] %>" class="crayons-avatar__image" alt="link to <%= actors.first["username"] %>'s profile" width="48" height="48">
</a>
<% else %>
<a href="<%= actors.first["path"] %>" class="crayons-avatar crayons-avatar--l mr-4" aria-hidden="true" tabindex="-1">
<img src="<%= actors.first["profile_image_90"] %>" class="crayons-avatar__image" alt="link to <%= actors.first["username"] %>'s profile" width="48" height="48">
</a>
<a href="<%= actors.first["path"] %>" class="crayons-avatar crayons-avatar--l absolute -right-1 -bottom-3 border-solid border-2 border-base-inverted" aria-hidden="true" tabindex="-1">
<img src="<%= actors.last["profile_image_90"] %>" class="crayons-avatar__image" alt="link to <%= actors.last["username"] %>'s profile" width="48" height="48">
</a>
<% end %>
</div>
<div class="notification__content pt-2">
<% reaction_categories = siblings.map { |n| n["category"] } %>
<%= t("views.notifications.reacted.verb_html",
count: actors.size,
start: tag("span", { class: %w[inline-block py-1] }, true), # rubocop:disable Rails/ContentTag
actors: if actors.size == 1
link_to actors.first["name"], actors.first["path"], class: "crayons-link fw-bold"
elsif actors.size == 2
t("views.notifications.reacted.and_html",
first: link_to(actors.first["name"], actors.first["path"], class: "crayons-link fw-bold"),
last: link_to(actors.last["name"], actors.last["path"], class: "crayons-link fw-bold"))
elsif actors.size > 1
t("views.notifications.reacted.and_other_html",
first: link_to(actors.first["name"], actors.first["path"], class: "crayons-link fw-bold"),
count: actors.size - 1)
end,
# your article/comment or the actual title of the article/comment
title: link_to(reactable_data["title"].blank? ? t("views.notifications.reacted.your.#{reactable_data['class']['name'].downcase}") : h(reactable_data["title"]), reactable_data["path"], class: "crayons-link fw-bold"),
end: "</span>".html_safe,
reactions: safe_join(
reaction_categories.filter_map do |cat|
image_path = reaction_image(cat)
if image_path.present?
inline_svg_tag(image_path, aria: true, class: "crayons-icon reaction-image mx-1 my-1 reaction-icon--#{cat}", title: t("views.reactions.category.#{cat}"))
end
end, "\n"
)) %>
</div>