use hooks for datetime, remove alpinejs

This commit is contained in:
2023-03-18 21:36:30 -04:00
parent a54cf8b87d
commit f5f72b53e6
9 changed files with 37 additions and 74 deletions

View File

@ -127,7 +127,7 @@ defmodule CanneryWeb.CoreComponents do
@doc """
Phoenix.Component for a <date> element that renders the Date in the user's
local timezone with Alpine.js
local timezone
"""
def date(assigns)
@ -136,7 +136,7 @@ defmodule CanneryWeb.CoreComponents do
@doc """
Phoenix.Component for a <time> element that renders the naivedatetime in the
user's local timezone with Alpine.js
user's local timezone
"""
def datetime(assigns)

View File

@ -1,7 +1,3 @@
<time :if={@date} id={@id} datetime={@date |> Date.to_iso8601(:extended)} x-data={~s<{
date:
Intl.DateTimeFormat([], {timeZone: 'Etc/UTC', dateStyle: 'short'})
.format(new Date("#{Date.to_iso8601(@date, :extended)}"))
}>} x-text="date">
<%= @date |> Date.to_iso8601(:extended) %>
<time :if={@date} id={@id} datetime={Date.to_iso8601(@date, :extended)} phx-hook="Date">
<%= Date.to_iso8601(@date, :extended) %>
</time>

View File

@ -1,7 +1,3 @@
<time :if={@datetime} id={@id} datetime={cast_datetime(@datetime)} x-data={~s/{
datetime:
Intl.DateTimeFormat([], {dateStyle: 'short', timeStyle: 'long'})
.format(new Date("#{cast_datetime(@datetime)}"))
}/} x-text="datetime">
<time :if={@datetime} id={@id} datetime={cast_datetime(@datetime)} phx-hook="DateTime">
<%= cast_datetime(@datetime) %>
</time>