<% @page_title = "Home" %>

<% content_for :header do %>
  <nav class="align-start">
    <header class="flex flex-inline flex-column center flex-shrink">
      <%= render "events/filter", filter: @filter %>
    </header>
  </nav>
<% end %>

<header>
  <h1 class="txt-large overflow-ellipsis margin-block-start-none margin-block-end-half font-black">
    <div class="overflow-ellipsis">
      <% if @filter.collections.any? %>
        <%= filter_selected_collections_label(@filter) %>
      <% else %>
        <%= Account.sole.name %> / Latest activity
        <% if @filter.creators.any? %>
          by <%= @filter.creators.each_with_object([]) { |creator, names| names << creator.familiar_name }.to_sentence %>
        <% end %>
      <% end %>
    </div>
    <% if @filter.creators.any? %>
      <%= link_to events_path(@filter.as_params.except(:creator_ids)), class: "btn btn--remove txt-xx-small margin-inline-start" do %>
        <%= icon_tag "close" %>
        <span class="for-screen-reader">Clear all</span>
      <% end %>
    <% end %>
  </h1>
  <% if collection = @filter.single_collection || Current.user.collections.first %>
    <%= button_to collection_cards_path(collection), method: :post, class: "btn btn--link txt-x-small margin-block-end-double", form_class: "center" do %>
      <%= icon_tag "add" %>
      <span>Add a card</span>
    <% end %>
  <% end %>
</header>
<div class="events" id="activity">
  <%= render "events/day", day_timeline: @day_timeline %>
  <%= event_next_page_link(@day_timeline.next_day) %>
</div>
