Dynamically build calendar

This commit is contained in:
2024-10-20 23:31:02 +02:00
parent 102a526109
commit b8f4c31bb7
2 changed files with 42 additions and 1341 deletions

View File

@@ -7,6 +7,10 @@ defmodule MihainatorWeb.ResultComponent do
def update(assigns, socket) do def update(assigns, socket) do
socket = assign(socket, assigns) socket = assign(socket, assigns)
months = get_months(assigns.calendar_dates)
socket = assign(socket, months: months)
{:ok, socket} {:ok, socket}
end end
@@ -14,4 +18,18 @@ defmodule MihainatorWeb.ResultComponent do
def mount(socket) do def mount(socket) do
{:ok, socket} {:ok, socket}
end end
def time_button(assigns) do
~H"""
<button>
<time><%= @day %></time>
</button>
"""
end
defp get_months(%{first_date: first_date}) do
start = Date.beginning_of_month(first_date)
for month_difference <- 0..11, do: Date.shift(start, month: month_difference)
end
end end

File diff suppressed because it is too large Load Diff