Extract component to render notifications item

This commit is contained in:
Javi Martín
2021-02-15 23:36:58 +01:00
parent b6c269008f
commit f11f2cd3dd
6 changed files with 64 additions and 56 deletions

View File

@@ -0,0 +1,30 @@
<% if user %>
<li id="notifications">
<%= link_to notifications_path, rel: "nofollow",
class: "notifications" do %>
<span class="show-for-sr">
<%= t("layouts.header.notification_item.notifications") %>
</span>
<% if user.notifications.unread.count > 0 %>
<span class="icon-circle" aria-hidden="true"></span>
<span class="icon-notification" aria-hidden="true"
title="<%= t("layouts.header.notification_item.new_notifications",
count: user.notifications_count) %>">
</span>
<span class="show-for-small-only">
<%= t("layouts.header.notification_item.new_notifications",
count: user.notifications_count) %>
</span>
<% else %>
<span class="icon-no-notification" aria-hidden="true"
title="<%= t("layouts.header.notification_item.no_notifications") %>">
</span>
<span class="show-for-small-only">
<%= t("layouts.header.notification_item.no_notifications") %>
</span>
<% end %>
<% end %>
</li>
<% end %>

View File

@@ -0,0 +1,7 @@
class Layout::NotificationItemComponent < ApplicationComponent
attr_reader :user
def initialize(user)
@user = user
end
end