mirror of
https://github.com/fly-apps/live_beats.git
synced 2024-12-22 15:16:28 +00:00
Fix 'navigate' link to use live_redirect and support keyboard navigation
This commit is contained in:
parent
f1908151f9
commit
597df89b41
1 changed files with 9 additions and 5 deletions
|
@ -122,13 +122,17 @@ defmodule LiveBeatsWeb.LiveHelpers do
|
|||
"""
|
||||
end
|
||||
|
||||
def link(%{navigate: _to} = assigns) do
|
||||
assigns = assign_new(assigns, :class, fn -> nil end)
|
||||
def link(%{navigate: to} = assigns) do
|
||||
opts =
|
||||
assigns
|
||||
|> assign_new(:class, fn -> nil end)
|
||||
|> assigns_to_attributes([:navigate])
|
||||
|> Keyword.put(:to, to)
|
||||
|
||||
assigns = assign(assigns, :opts, opts)
|
||||
|
||||
~H"""
|
||||
<a href={@navigate} data-phx-link="redirect" data-phx-link-state="push" class={@class}>
|
||||
<%= render_slot(@inner_block) %>
|
||||
</a>
|
||||
<%= live_redirect @opts do %><%= render_slot(@inner_block) %><% end %>
|
||||
"""
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue