exmr/lib/exmr_web/live/exam_live/index.html.heex

122 lines
3.9 KiB
Text
Raw Normal View History

2024-11-14 23:33:29 +02:00
<.header>
{gettext("Listing Exams")}
<div>
<button
phx-click="sort"
phx-value-by="subject"
class="font-light text-xs md:text-sm lg:text-base"
>
{gettext("Sort by Subject")}
2024-12-11 22:22:40 +02:00
</button>
<a class="invisible lg:visible">|</a>
<button
phx-click="sort"
phx-value-by="date"
class="font-light text-xs md:text-sm lg:text-base"
>
{gettext("Sort by Date")}
2024-12-11 22:22:40 +02:00
</button>
</div>
2024-11-14 23:33:29 +02:00
<:actions>
<.link patch={~p"/exams/new"}>
2024-12-01 18:31:23 +02:00
<.button class="dark:bg-sky-300 text-white dark:text-black/80 dark:hover:bg-sky-400">
{gettext("New Exam")}
2024-12-01 18:31:23 +02:00
</.button>
2024-11-14 23:33:29 +02:00
</.link>
</:actions>
</.header>
<div class="divide-y">
<div :for={exam <- @exams} class="py-2 flex gap-2">
<div class="grow">
<div class="font-bold text-xs md:text-sm lg:text-base">{exam.subject}</div>
<div class="text-xs md:text-sm lg:text-base">
{exam.date} |
<b class="text-xs md:text-sm lg:text-base">
{case Date.diff(exam.date, Date.utc_today()) do
2024-12-23 00:10:10 +02:00
0 -> gettext("Today")
1 -> gettext("Tommorow")
x when x > 1 -> ngettext("Tomorrow", "%{count} days left", x)
x when x < 0 -> ngettext("Yesterday", "%{count} days passed", x * -1)
end}
</b>
2024-12-09 21:05:13 +02:00
</div>
2024-11-14 23:33:29 +02:00
</div>
2024-12-23 00:10:10 +02:00
<button
phx-click="edit"
phx-value-id={exam.id}
class="bg-blue-500 hover:bg-blue-700 text-white font-bold p-1 text-xs md:text-sm lg:py-2 lg:px-3 rounded-md"
2024-12-23 00:10:10 +02:00
>
{gettext("Edit")}
2024-11-27 18:02:28 +02:00
</button>
2024-12-23 00:10:10 +02:00
<button
phx-click="remove"
phx-value-id={exam.id}
class="bg-red-500 hover:bg-red-700 text-white font-bold p-1 text-xs md:text-sm lg:py-2 lg:px-3 rounded-md"
2024-12-23 00:10:10 +02:00
>
{gettext("Remove")}
</button>
</div>
</div>
2024-11-14 23:33:29 +02:00
<.modal :if={@live_action in [:new, :edit]} id="exam-modal" show on_cancel={JS.patch(~p"/exams")}>
2024-12-23 00:10:10 +02:00
<.live_component
module={ExmrWeb.ExamLive.FormComponent}
id={@exam.id || :new}
title={@page_title}
action={@live_action}
exam={@exam}
patch={~p"/exams"}
/>
2024-11-14 23:33:29 +02:00
</.modal>
2024-12-22 22:52:30 +02:00
<div>
<!-- Navigation -->
<!-- <div class="flex justify-between mb-4"> -->
<!-- <button phx-click="previous_month" class="px-2 py-1 bg-blue-200">Previous</button> -->
<!-- <h2>{@current_month |> Date.to_string() |> String.replace("-", " ")}</h2> -->
<!-- <button phx-click="next_month" class="px-2 py-1 bg-blue-200">Next</button> -->
<!-- </div> -->
<!-- Calendar -->
<div class="grid grid-cols-7 gap-1" id="calendar-container" phx-update="replace">
2024-12-22 22:52:30 +02:00
<!-- Weekdays -->
<%= for weekday <- ~w(#{gettext("Sun")} #{gettext("Mon")} #{gettext("Tue")} #{gettext("Wed")} #{gettext("Thu")}
#{gettext("Fri")} #{gettext("Sat")}) do %>
<div class="font-bold text-center">{weekday}</div>
2024-12-23 00:10:10 +02:00
<% end %>
<!-- Empty spaces for previous month -->
<%= for _ <- 1..(Date.day_of_week(Date.new!(@current_month.year, @current_month.month, 1))) do %>
2024-12-23 00:10:10 +02:00
<div></div>
<% end %>
<!-- Days of the month -->
<%= for day <- 1..Date.days_in_month(@current_month) do %>
<% {:ok, date} = Date.new(@current_month.year, @current_month.month, day) %>
2024-12-22 22:52:30 +02:00
<div
id={"day-#{Date.to_string(date)}"}
class={[
"border rounded p-0.5 md:p-2 lg:p-3 w-full h-12 md:h-20 hover:scale-125 transition-transform ease-in-out duration-100",
@current_month == date &&
"bg-zinc-200 dark:bg-zinc-800 border-green-500 dark:border-green-300",
@current_month != date &&
"bg-white dark:bg-zinc-950 dark:border-zinc-400 "
]}
>
<div class="text-xs md:text-sm lg:text-base font-bold">{day}</div>
<!-- Render events for the current day -->
2024-12-22 22:52:30 +02:00
<%= if Map.has_key?(@events, date) do %>
<ul class="text-xs">
<%= for event <- @events[date] do %>
<li id={"event-#{event.id}"}>{event.subject}</li>
<% end %>
</ul>
2024-12-23 00:10:10 +02:00
<% end %>
</div>
<% end %>
2024-12-22 22:52:30 +02:00
</div>
</div>