Dynamically build calendar
This commit is contained in:
@@ -7,6 +7,10 @@ defmodule MihainatorWeb.ResultComponent do
|
||||
def update(assigns, socket) do
|
||||
socket = assign(socket, assigns)
|
||||
|
||||
months = get_months(assigns.calendar_dates)
|
||||
|
||||
socket = assign(socket, months: months)
|
||||
|
||||
{:ok, socket}
|
||||
end
|
||||
|
||||
@@ -14,4 +18,18 @@ defmodule MihainatorWeb.ResultComponent do
|
||||
def mount(socket) do
|
||||
{:ok, socket}
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user