|
| 1 | +<div class="p-4 md:p-10 w-full min-h-screen bg-app-bg"> |
| 2 | + <div class="max-w-7xl mx-auto"> |
| 3 | + <div class="mb-12"> |
| 4 | + <div class="flex items-center gap-4"> |
| 5 | + <h1 class="text-4xl md:text-5xl font-bold text-[#1A1A1A] tracking-tight"> |
| 6 | + Yearbook |
| 7 | + </h1> |
| 8 | + |
| 9 | + <div class="relative inline-block text-left mt-2" id="year-menu-container"> |
| 10 | + <button |
| 11 | + type="button" |
| 12 | + phx-click={ |
| 13 | + Phoenix.LiveView.JS.toggle( |
| 14 | + to: "#year-dropdown", |
| 15 | + in: "fade-in-scale", |
| 16 | + out: "fade-out-scale" |
| 17 | + ) |
| 18 | + } |
| 19 | + phx-click-away={Phoenix.LiveView.JS.hide(to: "#year-dropdown")} |
| 20 | + class="flex items-center gap-2 bg-orange-50 text-orange-600 border border-orange-100 px-4 py-1.5 rounded-full text-sm font-bold focus:outline-none hover:bg-orange-100 transition-all shadow-sm" |
| 21 | + > |
| 22 | + <%= case @filters["year"] do %> |
| 23 | + <% "" -> %> |
| 24 | + <span>Ano Letivo</span> |
| 25 | + <% year -> %> |
| 26 | + <span>{format_academic_year(String.to_integer(year))}</span> |
| 27 | + <% end %> |
| 28 | + <.icon name="hero-chevron-down" class="size-4" /> |
| 29 | + </button> |
| 30 | + |
| 31 | + <div |
| 32 | + id="year-dropdown" |
| 33 | + class="hidden absolute left-0 mt-2 w-48 origin-top-left rounded-2xl bg-white shadow-xl ring-1 ring-black ring-opacity-5 z-50 overflow-hidden border border-gray-100" |
| 34 | + > |
| 35 | + <div class="py-2"> |
| 36 | + <%= for {label, value} <- list_academic_years() do %> |
| 37 | + <button |
| 38 | + phx-click={ |
| 39 | + Phoenix.LiveView.JS.push("filter_changed", |
| 40 | + value: %{year: value, masters: @filters["masters"]} |
| 41 | + ) |
| 42 | + |> Phoenix.LiveView.JS.hide(to: "#year-dropdown") |
| 43 | + } |
| 44 | + class={"block w-full text-left px-5 py-2.5 text-sm transition-all #{if @filters["year"] == value, do: "bg-orange-50 text-orange-600 font-bold", else: "text-gray-600 hover:bg-gray-50 hover:text-orange-500"}"} |
| 45 | + > |
| 46 | + <div class="flex items-center justify-between"> |
| 47 | + <span>{label}</span> |
| 48 | + <%= if @filters["year"] == value do %> |
| 49 | + <div class="size-1.5 rounded-full bg-orange-500"></div> |
| 50 | + <% end %> |
| 51 | + </div> |
| 52 | + </button> |
| 53 | + <% end %> |
| 54 | + </div> |
| 55 | + </div> |
| 56 | + </div> |
| 57 | + </div> |
| 58 | + |
| 59 | + <div class="flex items-center gap-8 mt-8"> |
| 60 | + <div class="flex gap-8"> |
| 61 | + <button |
| 62 | + phx-click="filter_changed" |
| 63 | + phx-value-masters="" |
| 64 | + phx-value-year={@filters["year"]} |
| 65 | + class="pb-2 relative group focus:outline-none" |
| 66 | + > |
| 67 | + <span class={"text-sm font-bold tracking-wide uppercase #{if @filters["masters"] == "", do: "text-orange-600", else: "text-gray-400 hover:text-gray-600"}"}> |
| 68 | + Todos |
| 69 | + </span> |
| 70 | + <%= if @filters["masters"] == "" do %> |
| 71 | + <div class="absolute bottom-0 left-0 w-full h-0.5 bg-orange-600"></div> |
| 72 | + <% end %> |
| 73 | + </button> |
| 74 | + |
| 75 | + <button |
| 76 | + phx-click="filter_changed" |
| 77 | + phx-value-masters="false" |
| 78 | + phx-value-year={@filters["year"]} |
| 79 | + class="pb-2 relative group focus:outline-none" |
| 80 | + > |
| 81 | + <span class={"text-sm font-bold tracking-wide uppercase #{if @filters["masters"] == "false", do: "text-orange-600", else: "text-gray-400 hover:text-gray-600"}"}> |
| 82 | + Licenciatura |
| 83 | + </span> |
| 84 | + <%= if @filters["masters"] == "false" do %> |
| 85 | + <div class="absolute bottom-0 left-0 w-full h-0.5 bg-orange-600"></div> |
| 86 | + <% end %> |
| 87 | + </button> |
| 88 | + |
| 89 | + <button |
| 90 | + phx-click="filter_changed" |
| 91 | + phx-value-masters="true" |
| 92 | + phx-value-year={@filters["year"]} |
| 93 | + class="pb-2 relative group focus:outline-none" |
| 94 | + > |
| 95 | + <span class={"text-sm font-bold tracking-wide uppercase #{if @filters["masters"] == "true", do: "text-orange-600", else: "text-gray-400 hover:text-gray-600"}"}> |
| 96 | + Mestrado |
| 97 | + </span> |
| 98 | + <%= if @filters["masters"] == "true" do %> |
| 99 | + <div class="absolute bottom-0 left-0 w-full h-0.5 bg-orange-600"></div> |
| 100 | + <% end %> |
| 101 | + </button> |
| 102 | + </div> |
| 103 | + |
| 104 | + <%= if assigns[:current_scope] && @current_scope.user do %> |
| 105 | + <.link |
| 106 | + patch={~p"/entries/new"} |
| 107 | + class="flex items-center justify-center gap-2 px-3 py-1.5 bg-white border border-gray-200 rounded-lg text-xs font-bold uppercase tracking-wider text-gray-600 hover:bg-gray-50 hover:border-orange-200 hover:text-orange-600 transition-all shadow-sm min-w-[40px]" |
| 108 | + > |
| 109 | + <.icon name="hero-plus" class="size-4 " /> |
| 110 | + |
| 111 | + <span class="hidden md:inline">Adicionar</span> |
| 112 | + </.link> |
| 113 | + <% end %> |
| 114 | + </div> |
| 115 | + |
| 116 | + <p class="mt-6 text-gray-500 max-w-2xl text-sm leading-relaxed"> |
| 117 | + <%= case {@filters["masters"], @filters["year"]} do %> |
| 118 | + <% {"", ""} -> %> |
| 119 | + Todos os alunos registados no Yearbook. |
| 120 | + <% {"true", ""} -> %> |
| 121 | + Alunos do Mestrado de todos os anos letivos. |
| 122 | + <% {"false", ""} -> %> |
| 123 | + Alunos da Licenciatura de todos os anos letivos. |
| 124 | + <% {masters, year} -> %> |
| 125 | + Alunos {if masters == "true", do: "do Mestrado", else: "da Licenciatura"} do Ano Letivo {format_academic_year( |
| 126 | + String.to_integer(year) |
| 127 | + )}. |
| 128 | + <% end %> |
| 129 | + </p> |
| 130 | + </div> |
| 131 | + |
| 132 | + <div class="grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 gap-x-8 gap-y-12"> |
| 133 | + <%= for entry <- @entries do %> |
| 134 | + <.entry_card name={entry.name} text={entry.text} src={entry.photo} /> |
| 135 | + <% end %> |
| 136 | + </div> |
| 137 | + </div> |
| 138 | +</div> |
0 commit comments