<!doctype html>
<html class="h-full bg-gray-100">
<head>
  <title>Swoosh Gallery</title>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">

  <style>
      <%= @styles %>
  </style>
</head>

<body class="h-full">
  <div>
    <div class="hidden md:flex md:w-64 md:flex-col md:fixed md:inset-y-0">
      <div class="flex flex-col flex-grow pt-5 bg-indigo-700 overflow-y-auto">
        <div class="flex-shrink-0 px-4">
          <a href="<%= to_absolute_url(@base_path, "/") %>" class="font-medium text-white text-2xl">Swoosh Gallery</a>
        </div>
        <div class="mt-5 flex-1 flex flex-col">
          <nav class="flex-1 px-2 pb-4 space-y-1">
            <%= for %{path: path, title: title, previews: previews} <- @groups do %>
              <details <%= if (@preview && @preview.group == path), do: "open" %>>
                <summary class="px-2 py-2 text-m font-bold text-indigo-100 hover:bg-indigo-600 rounded-md cursor-pointer"><%= title %></summary>
                <%= for preview <- previews do %>
                  <a href="<%= preview_path(preview, @base_path, format: @format) %>" class="<%= if(@preview && @preview.path == preview.path, do: "bg-indigo-800 text-white", else: "text-indigo-100 hover:bg-indigo-600") %>
                      block px-4 py-2 text-sm font-medium rounded-md">
                    <%= preview.preview_details.title %>
                  </a>
                <% end %>
            </details>
            <% end %>

              <%= for preview <- @ungrouped_previews do %>
                <a href="<%= preview_path(preview, @base_path, format: @format) %>" class="<%= if(@preview && @preview.path == preview.path, do: "bg-indigo-800 text-white", else: "text-indigo-100 hover:bg-indigo-600") %>
                    block px-2 py-2 text-sm font-medium rounded-md">
                  <%= preview.preview_details.title %>
                </a>
              <% end %>
          </nav>
        </div>
      </div>
    </div>

    <div class="md:pl-64 flex flex-col flex-1">
      <!-- <div class="sticky top-0 z-10 flex-shrink-0 flex h-16 bg-white shadow">
        <button type="button"
          class="px-4 border-r border-gray-200 text-gray-500 focus:outline-none focus:ring-2 focus:ring-inset focus:ring-indigo-500 md:hidden">
          <span class="sr-only">Open sidebar</span>
          Heroicon name: outline/menu-alt-2
          <svg class="h-6 w-6" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor"
            aria-hidden="true">
            <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 6h16M4 12h16M4 18h7" />
          </svg>
        </button>
        <div class="flex-1 px-4 flex justify-between">
          <div class="flex-1 flex">
            <form class="w-full flex md:ml-0" action="#" method="GET">
              <label for="search-field" class="sr-only">Search</label>
              <div class="relative w-full text-gray-400 focus-within:text-gray-600">
                <div class="absolute inset-y-0 left-0 flex items-center pointer-events-none">
                  Heroicon name: solid/search
                  <svg class="h-5 w-5" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor"
                    aria-hidden="true">
                    <path fill-rule="evenodd"
                      d="M8 4a4 4 0 100 8 4 4 0 000-8zM2 8a6 6 0 1110.89 3.476l4.817 4.817a1 1 0 01-1.414 1.414l-4.816-4.816A6 6 0 012 8z"
                      clip-rule="evenodd" />
                  </svg>
                </div>
                <input id="search-field"
                  class="block w-full h-full pl-8 pr-3 py-2 border-transparent text-gray-900 placeholder-gray-500 focus:outline-none focus:placeholder-gray-400 focus:ring-0 focus:border-transparent sm:text-sm"
                  placeholder="Search" type="search" name="search">
              </div>
            </form>
          </div>
        </div>
      </div> -->

      <main>
        <div class="py-6 px-4 sm:px-6 md:px-8">
          <div class="max-w-7xl mx-auto">
            <%= if @preview do %>
              <%= render_preview preview: @preview, base_path: @base_path %>
            <% else %>
              <%= for %{title: title, previews: previews} <- @groups do %>
              <%= render_table title: "#{title}", previews: previews, base_path: @base_path, format: @format %>
              <% end %>

              <%= render_table title: "Email Previews", previews: @ungrouped_previews, base_path: @base_path, format: @format %>
          <% end %>
        </div>
      </main>
    </div>
  </div>
</body>
</html>
