add ids to dynamic date and datetime elements
This commit is contained in:
parent
56956f37fb
commit
98bb99881d
@ -136,6 +136,7 @@ defmodule MemexWeb.CoreComponents do
|
|||||||
"""
|
"""
|
||||||
end
|
end
|
||||||
|
|
||||||
|
attr :id, :string, required: true
|
||||||
attr :datetime, :any, required: true, doc: "A `DateTime` struct or nil"
|
attr :datetime, :any, required: true, doc: "A `DateTime` struct or nil"
|
||||||
|
|
||||||
@doc """
|
@doc """
|
||||||
@ -151,6 +152,7 @@ defmodule MemexWeb.CoreComponents do
|
|||||||
|
|
||||||
defp cast_datetime(_datetime), do: ""
|
defp cast_datetime(_datetime), do: ""
|
||||||
|
|
||||||
|
attr :id, :string, required: true
|
||||||
attr :date, :any, required: true, doc: "A `Date` struct or nil"
|
attr :date, :any, required: true, doc: "A `Date` struct or nil"
|
||||||
|
|
||||||
@doc """
|
@doc """
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<time :if={@date} datetime={@date |> Date.to_iso8601(:extended)} x-data={~s<{
|
<time :if={@date} id={@id} datetime={@date |> Date.to_iso8601(:extended)} x-data={~s<{
|
||||||
date:
|
date:
|
||||||
Intl.DateTimeFormat([], {timeZone: 'Etc/UTC', dateStyle: 'short'})
|
Intl.DateTimeFormat([], {timeZone: 'Etc/UTC', dateStyle: 'short'})
|
||||||
.format(new Date("#{Date.to_iso8601(@date, :extended)}"))
|
.format(new Date("#{Date.to_iso8601(@date, :extended)}"))
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<time :if={@datetime} datetime={cast_datetime(@datetime)} x-data={~s/{
|
<time :if={@datetime} id={@id} datetime={cast_datetime(@datetime)} x-data={~s/{
|
||||||
datetime:
|
datetime:
|
||||||
Intl.DateTimeFormat([], {dateStyle: 'short', timeStyle: 'long'})
|
Intl.DateTimeFormat([], {dateStyle: 'short', timeStyle: 'long'})
|
||||||
.format(new Date("#{cast_datetime(@datetime)}"))
|
.format(new Date("#{cast_datetime(@datetime)}"))
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
"user confirmed on%{confirmed_datetime}",
|
"user confirmed on%{confirmed_datetime}",
|
||||||
confirmed_datetime: ""
|
confirmed_datetime: ""
|
||||||
) %>
|
) %>
|
||||||
<.datetime datetime={@user.confirmed_at} />
|
<.datetime id={"#{@user.id}-confirmed-at"} datetime={@user.confirmed_at} />
|
||||||
<% else %>
|
<% else %>
|
||||||
<%= gettext("email unconfirmed") %>
|
<%= gettext("email unconfirmed") %>
|
||||||
<% end %>
|
<% end %>
|
||||||
@ -27,7 +27,7 @@
|
|||||||
"user registered on%{registered_datetime}",
|
"user registered on%{registered_datetime}",
|
||||||
registered_datetime: ""
|
registered_datetime: ""
|
||||||
) %>
|
) %>
|
||||||
<.datetime datetime={@user.inserted_at} />
|
<.datetime id={"#{@user.id}-inserted-at"} datetime={@user.inserted_at} />
|
||||||
</p>
|
</p>
|
||||||
</h3>
|
</h3>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user