<% if user_signed_in? %>
  <%= render partial: 'layouts/navbar/recent_content_dropdown' %>
  <%= render partial: 'layouts/modals/search' %>
<% end %>

<div class="navbar-fixed">
  <nav class="navbar nav-extended <%= 'logged-in' if user_signed_in? %>" style="background-color: <%= @navbar_color.presence || '#2196F3' %>">
    <div class="nav-wrapper">
      <ul class="right">
        <% if user_signed_in? %>
          <% if current_user.recent_content_list.any? %>
            <li>
              <a class="dropdown-trigger tooltipped" href="#!" data-target="recent-content-dropdown" data-position="bottom" data-delay="100" data-tooltip="Your recently-edited pages">
                <i class="material-icons">recent_actors</i>
              </a>
            </li>
          <% end %>
          <li>
            <a class="waves-effect waves-light modal-trigger tooltipped" href="#search-modal" data-tooltip="Search your notebook">
              <i class="material-icons">search</i>
            </a>
          </li>
        <% else %>
          <li>
            <%= link_to 'Sign in', main_app.new_user_session_path %>
          </li>
          <li>
            <%= link_to 'Sign up', main_app.new_user_registration_path %>
          </li>
        <% end %>
      </ul>
      <ul class="left">
        <% if user_signed_in? %>
          <li>
            <a class="sidenav-trigger" href="#" data-target="sidenav-left">
              <i class="material-icons">menu</i>
            </a>
          </li>
          <li class="hide-on-large-only">
            <%= link_to main_app.root_path, class: 'tooltipped', data: { tooltip: 'Your dashboard' } do %>
              <i class="material-icons">dashboard</i>
            <% end %>
          </li>
        <% else %>
          <li>
            <%= link_to 'Notebook.ai', main_app.root_path %>
          </li>
        <% end %>
      </ul>
    </div>

    <% if @navbar_actions.present? && @navbar_actions.any? %>
      <style>
        main {
          padding-top: 50px;
        }
      </style>
      <div class="nav-content">
        <ul class="tabs tabs-transparent">
          <% @navbar_actions.each do |action| %>
            <li class="tab <%= action[:class] %>">
              <a class="white-text <%= 'active' if action[:href] == request.env['REQUEST_PATH'] %>" href="<%= action[:href] %>" target="<%= action[:target] || '_self' %>">
                <%= action[:label] %>
              </a>
            </li>
          <% end %>
        </ul>
      </div>
    <% end %>
  </nav>
</div>
