<% if view_templates.many? %>

  <%= render Spina::UserInterface::DropdownComponent.new do |dropdown| %>
    <% dropdown.with_button(classes: "btn btn-primary w-full") do %>
      <%= helpers.heroicon("document-plus", style: :solid, class: "w-5 h-5 -ml-1 mr-1") %>
      <%=t 'spina.pages.new' %>
    <% end %>
    
    <% dropdown.with_menu do %>
      <% view_templates.each do |template| %>
        <%= link_to helpers.spina.new_admin_page_path(view_template: template.name, resource_id: @resource&.id), class: "block px-4 py-2 text-sm leading-5 text-gray-700 hover:bg-gray-100 hover:text-gray-900 focus:outline-none focus:bg-gray-100 focus:text-gray-900", data: {turbo_frame: "modal", action: "reveal#hide"} do %>
          <div class="font-medium text-gray-700">
            <%= template.title %>
            
            <% if template.recommended %>
              <span class="text-emerald-500 text-xs"><%=t 'spina.pages.recommended' %></span>
            <% end %>
          </div>
          <div class="text-gray-400"><%= template.description %></div>
        <% end %>
      <% end %>
    <% end %>
  <% end %>
  
<% else %>

  <%= link_to helpers.spina.new_admin_page_path(view_template: view_template.name, resource_id: resource&.id), class: "btn btn-primary w-full", data: {turbo_frame: "modal"} do %>
    <%= helpers.heroicon("document-plus", style: :solid, class: "w-5 h-5 -ml-1 mr-1") %>
    <%=t 'spina.pages.new' %>
  <% end %>
  
<% end %>