mirror of
https://github.com/fly-apps/live_beats.git
synced 2024-11-22 08:01:00 +00:00
Rename link attrs
This commit is contained in:
parent
7f9b7c5f9a
commit
a325b385b3
7 changed files with 29 additions and 29 deletions
|
@ -19,7 +19,7 @@ defmodule LiveBeatsWeb.Presence do
|
||||||
<ul role="list" class="grid grid-cols-1 gap-4 sm:gap-4 sm:grid-cols-2 xl:grid-cols-5 mt-3" x-max="1">
|
<ul role="list" class="grid grid-cols-1 gap-4 sm:gap-4 sm:grid-cols-2 xl:grid-cols-5 mt-3" x-max="1">
|
||||||
<%= for presence <- @presences do %>
|
<%= for presence <- @presences do %>
|
||||||
<li class="relative col-span-1 flex shadow-sm rounded-md overflow-hidden">
|
<li class="relative col-span-1 flex shadow-sm rounded-md overflow-hidden">
|
||||||
<.link redirect_to={profile_path(presence)} class="flex-1 flex items-center justify-between border-t border-r border-b border-gray-200 bg-white rounded-r-md truncate">
|
<.link navigate={profile_path(presence)} class="flex-1 flex items-center justify-between border-t border-r border-b border-gray-200 bg-white rounded-r-md truncate">
|
||||||
<img class="w-10 h-10 flex-shrink-0 flex items-center justify-center rounded-l-md bg-purple-600" src={presence.avatar_url} alt="">
|
<img class="w-10 h-10 flex-shrink-0 flex items-center justify-center rounded-l-md bg-purple-600" src={presence.avatar_url} alt="">
|
||||||
<div class="flex-1 flex items-center justify-between text-gray-900 text-sm font-medium hover:text-gray-600 pl-3">
|
<div class="flex-1 flex items-center justify-between text-gray-900 text-sm font-medium hover:text-gray-600 pl-3">
|
||||||
<%= render_slot(@title, presence) %>
|
<%= render_slot(@title, presence) %>
|
||||||
|
|
|
@ -17,8 +17,8 @@ defmodule LiveBeatsWeb.LayoutComponent do
|
||||||
case assigns[:show] do
|
case assigns[:show] do
|
||||||
%{module: _module, confirm: {text, attrs}} = show ->
|
%{module: _module, confirm: {text, attrs}} = show ->
|
||||||
show
|
show
|
||||||
|> Map.put_new(:patch_to, nil)
|
|> Map.put_new(:patch, nil)
|
||||||
|> Map.put_new(:redirect_to, nil)
|
|> Map.put_new(:navigate, nil)
|
||||||
|> Map.merge(%{confirm_text: text, confirm_attrs: attrs})
|
|> Map.merge(%{confirm_text: text, confirm_attrs: attrs})
|
||||||
|
|
||||||
nil ->
|
nil ->
|
||||||
|
@ -32,7 +32,7 @@ defmodule LiveBeatsWeb.LayoutComponent do
|
||||||
~H"""
|
~H"""
|
||||||
<div class={unless @show, do: "hidden"}>
|
<div class={unless @show, do: "hidden"}>
|
||||||
<%= if @show do %>
|
<%= if @show do %>
|
||||||
<.modal show id={@id} redirect_to={@show.redirect_to} patch_to={@show.patch_to}>
|
<.modal show id={@id} navigate={@show.navigate} patch={@show.patch}>
|
||||||
<.live_component module={@show.module} {@show} />
|
<.live_component module={@show.module} {@show} />
|
||||||
<:cancel>Cancel</:cancel>
|
<:cancel>Cancel</:cancel>
|
||||||
<:confirm {@show.confirm_attrs}><%= @show.confirm_text %></:confirm>
|
<:confirm {@show.confirm_attrs}><%= @show.confirm_text %></:confirm>
|
||||||
|
|
|
@ -134,7 +134,7 @@ defmodule LiveBeatsWeb.LiveHelpers do
|
||||||
"""
|
"""
|
||||||
end
|
end
|
||||||
|
|
||||||
def link(%{redirect_to: to} = assigns) do
|
def link(%{navigate: to} = assigns) do
|
||||||
opts = assigns |> assigns_to_attributes() |> Keyword.put(:to, to)
|
opts = assigns |> assigns_to_attributes() |> Keyword.put(:to, to)
|
||||||
assigns = assign(assigns, :opts, opts)
|
assigns = assign(assigns, :opts, opts)
|
||||||
|
|
||||||
|
@ -143,7 +143,7 @@ defmodule LiveBeatsWeb.LiveHelpers do
|
||||||
"""
|
"""
|
||||||
end
|
end
|
||||||
|
|
||||||
def link(%{patch_to: to} = assigns) do
|
def link(%{patch: to} = assigns) do
|
||||||
opts = assigns |> assigns_to_attributes() |> Keyword.put(:to, to)
|
opts = assigns |> assigns_to_attributes() |> Keyword.put(:to, to)
|
||||||
assigns = assign(assigns, :opts, opts)
|
assigns = assign(assigns, :opts, opts)
|
||||||
|
|
||||||
|
@ -178,8 +178,8 @@ defmodule LiveBeatsWeb.LiveHelpers do
|
||||||
<:title><%= @current_user.name %></:title>
|
<:title><%= @current_user.name %></:title>
|
||||||
<:subtitle>@<%= @current_user.username %></:subtitle>
|
<:subtitle>@<%= @current_user.username %></:subtitle>
|
||||||
|
|
||||||
<:link redirect_to={profile_path(@current_user)}>View Profile</:link>
|
<:link navigate={profile_path(@current_user)}>View Profile</:link>
|
||||||
<:link redirect_to={Routes.settings_path(LiveBeatsWeb.Endpoint, :edit)}Settings</:link>
|
<:link navigate={Routes.settings_path(LiveBeatsWeb.Endpoint, :edit)}Settings</:link>
|
||||||
</.dropdown>
|
</.dropdown>
|
||||||
"""
|
"""
|
||||||
def dropdown(assigns) do
|
def dropdown(assigns) do
|
||||||
|
@ -344,15 +344,15 @@ defmodule LiveBeatsWeb.LiveHelpers do
|
||||||
assigns =
|
assigns =
|
||||||
assigns
|
assigns
|
||||||
|> assign_new(:show, fn -> false end)
|
|> assign_new(:show, fn -> false end)
|
||||||
|> assign_new(:patch_to, fn -> nil end)
|
|> assign_new(:patch, fn -> nil end)
|
||||||
|> assign_new(:redirect_to, fn -> nil end)
|
|> assign_new(:navigate, fn -> nil end)
|
||||||
|> assign_new(:on_cancel, fn -> %JS{} end)
|
|> assign_new(:on_cancel, fn -> %JS{} end)
|
||||||
|> assign_new(:on_confirm, fn -> %JS{} end)
|
|> assign_new(:on_confirm, fn -> %JS{} end)
|
||||||
# slots
|
# slots
|
||||||
|> assign_new(:title, fn -> [] end)
|
|> assign_new(:title, fn -> [] end)
|
||||||
|> assign_new(:confirm, fn -> [] end)
|
|> assign_new(:confirm, fn -> [] end)
|
||||||
|> assign_new(:cancel, fn -> [] end)
|
|> assign_new(:cancel, fn -> [] end)
|
||||||
|> assign_rest(~w(id show patch_to redirect_to on_cancel on_confirm title confirm cancel)a)
|
|> assign_rest(~w(id show patch navigate on_cancel on_confirm title confirm cancel)a)
|
||||||
|
|
||||||
~H"""
|
~H"""
|
||||||
<div id={@id} class={"fixed z-10 inset-0 overflow-y-auto #{if @show, do: "fade-in", else: "hidden"}"} aria-labelledby="modal-title" role="dialog" aria-modal="true" {@rest}>
|
<div id={@id} class={"fixed z-10 inset-0 overflow-y-auto #{if @show, do: "fade-in", else: "hidden"}"} aria-labelledby="modal-title" role="dialog" aria-modal="true" {@rest}>
|
||||||
|
@ -365,11 +365,11 @@ defmodule LiveBeatsWeb.LiveHelpers do
|
||||||
phx-window-keydown={hide_modal(@on_cancel, @id)} phx-key="escape"
|
phx-window-keydown={hide_modal(@on_cancel, @id)} phx-key="escape"
|
||||||
phx-click-away={hide_modal(@on_cancel, @id)}
|
phx-click-away={hide_modal(@on_cancel, @id)}
|
||||||
>
|
>
|
||||||
<%= if @patch_to do %>
|
<%= if @patch do %>
|
||||||
<.link patch_to={@patch_to} data-modal-return class="hidden"></.link>
|
<.link patch={@patch} data-modal-return class="hidden"></.link>
|
||||||
<% end %>
|
<% end %>
|
||||||
<%= if @redirect_to do %>
|
<%= if @navigate do %>
|
||||||
<.link redirect_to={@redirect_to} data-modal-return class="hidden"></.link>
|
<.link navigate={@navigate} data-modal-return class="hidden"></.link>
|
||||||
<% end %>
|
<% end %>
|
||||||
<div class="sm:flex sm:items-start">
|
<div class="sm:flex sm:items-start">
|
||||||
<div class={"mx-auto flex-shrink-0 flex items-center justify-center h-8 w-8 rounded-full bg-purple-100 sm:mx-0"}>
|
<div class={"mx-auto flex-shrink-0 flex items-center justify-center h-8 w-8 rounded-full bg-purple-100 sm:mx-0"}>
|
||||||
|
@ -455,16 +455,16 @@ defmodule LiveBeatsWeb.LiveHelpers do
|
||||||
"""
|
"""
|
||||||
end
|
end
|
||||||
|
|
||||||
def button(%{patch_to: _} = assigns) do
|
def button(%{patch: _} = assigns) do
|
||||||
assigns = assign_new(assigns, :primary, fn -> false end)
|
assigns = assign_new(assigns, :primary, fn -> false end)
|
||||||
|
|
||||||
~H"""
|
~H"""
|
||||||
<%= if @primary do %>
|
<%= if @primary do %>
|
||||||
<%= live_patch to: @patch_to, class: "order-0 inline-flex items-center px-4 py-2 border border-transparent shadow-sm text-sm font-medium rounded-md text-white bg-purple-600 hover:bg-purple-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-purple-500 sm:order-1 sm:ml-3" do %>
|
<%= live_patch to: @patch, class: "order-0 inline-flex items-center px-4 py-2 border border-transparent shadow-sm text-sm font-medium rounded-md text-white bg-purple-600 hover:bg-purple-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-purple-500 sm:order-1 sm:ml-3" do %>
|
||||||
<%= render_slot(@inner_block) %>
|
<%= render_slot(@inner_block) %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% else %>
|
<% else %>
|
||||||
<%= live_patch to: @patch_to, class: "order-1 inline-flex items-center px-4 py-2 border border-gray-300 shadow-sm text-sm font-medium rounded-md text-gray-700 bg-white hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-purple-500 sm:order-0 sm:ml-0 lg:ml-3" do %>
|
<%= live_patch to: @patch, class: "order-1 inline-flex items-center px-4 py-2 border border-gray-300 shadow-sm text-sm font-medium rounded-md text-gray-700 bg-white hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-purple-500 sm:order-0 sm:ml-0 lg:ml-3" do %>
|
||||||
<%= render_slot(@inner_block) %>
|
<%= render_slot(@inner_block) %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
|
@ -38,7 +38,7 @@ defmodule LiveBeatsWeb.PlayerLive do
|
||||||
<div class="bg-gray-50 text-black dark:bg-gray-900 dark:text-white px-1 sm:px-3 lg:px-1 xl:px-3 grid grid-cols-5 items-center">
|
<div class="bg-gray-50 text-black dark:bg-gray-900 dark:text-white px-1 sm:px-3 lg:px-1 xl:px-3 grid grid-cols-5 items-center">
|
||||||
<%= if @profile do %>
|
<%= if @profile do %>
|
||||||
<.link
|
<.link
|
||||||
redirect_to={profile_path(@profile)}
|
navigate={profile_path(@profile)}
|
||||||
class="mx-auto flex outline border-2 border-white border-opacity-20 rounded-md p-1 pr-2"
|
class="mx-auto flex outline border-2 border-white border-opacity-20 rounded-md p-1 pr-2"
|
||||||
>
|
>
|
||||||
<span class="mt-1"><.icon name={:user_circle} class="w-4 h-4 block"/></span>
|
<span class="mt-1"><.icon name={:user_circle} class="w-4 h-4 block"/></span>
|
||||||
|
|
|
@ -32,7 +32,7 @@ defmodule LiveBeatsWeb.ProfileLive do
|
||||||
</.button>
|
</.button>
|
||||||
<% end %>
|
<% end %>
|
||||||
<%= if @owns_profile? do %>
|
<%= if @owns_profile? do %>
|
||||||
<.button primary patch_to={profile_path(@current_user, :new)}>
|
<.button primary patch={profile_path(@current_user, :new)}>
|
||||||
<.icon name={:upload}/><span class="ml-2">Upload Songs</span>
|
<.icon name={:upload}/><span class="ml-2">Upload Songs</span>
|
||||||
</.button>
|
</.button>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
@ -220,7 +220,7 @@ defmodule LiveBeatsWeb.ProfileLive do
|
||||||
LayoutComponent.show_modal(UploadFormComponent, %{
|
LayoutComponent.show_modal(UploadFormComponent, %{
|
||||||
id: :new,
|
id: :new,
|
||||||
confirm: {"Save", type: "submit", form: "song-form"},
|
confirm: {"Save", type: "submit", form: "song-form"},
|
||||||
patch_to: profile_path(socket.assigns.current_user),
|
patch: profile_path(socket.assigns.current_user),
|
||||||
song: socket.assigns.song,
|
song: socket.assigns.song,
|
||||||
title: socket.assigns.page_title,
|
title: socket.assigns.page_title,
|
||||||
current_user: socket.assigns.current_user
|
current_user: socket.assigns.current_user
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="flex-shrink-0 flex items-center px-4">
|
<div class="flex-shrink-0 flex items-center px-4">
|
||||||
<.link redirect_to={home_path(@current_user)}>
|
<.link navigate={home_path(@current_user)}>
|
||||||
<.icon name={:status_online} class="w-8 h-8 text-purple-600 -mt-2 inline-block" outlined/>
|
<.icon name={:status_online} class="w-8 h-8 text-purple-600 -mt-2 inline-block" outlined/>
|
||||||
<span class="h-8 w-auto text-2xl ml-1 font-bold">
|
<span class="h-8 w-auto text-2xl ml-1 font-bold">
|
||||||
LiveBeats
|
LiveBeats
|
||||||
|
@ -49,7 +49,7 @@
|
||||||
<div class="hidden lg:flex lg:flex-shrink-0">
|
<div class="hidden lg:flex lg:flex-shrink-0">
|
||||||
<div class="flex flex-col w-64 border-r border-gray-200 pt-5 pb-4 bg-gray-100">
|
<div class="flex flex-col w-64 border-r border-gray-200 pt-5 pb-4 bg-gray-100">
|
||||||
<div class="flex items-center flex-shrink-0 px-6">
|
<div class="flex items-center flex-shrink-0 px-6">
|
||||||
<.link redirect_to={home_path(@current_user)}>
|
<.link navigate={home_path(@current_user)}>
|
||||||
<.icon name={:status_online} class="w-8 h-8 text-purple-600 -mt-2 inline-block" outlined/>
|
<.icon name={:status_online} class="w-8 h-8 text-purple-600 -mt-2 inline-block" outlined/>
|
||||||
<span class="h-8 w-auto text-2xl ml-1 font-bold">
|
<span class="h-8 w-auto text-2xl ml-1 font-bold">
|
||||||
LiveBeats
|
LiveBeats
|
||||||
|
|
|
@ -15,7 +15,7 @@ defmodule LiveBeatsWeb.LayoutView do
|
||||||
</h3>
|
</h3>
|
||||||
<div class="mt-1 space-y-1" role="group" aria-labelledby={@id}>
|
<div class="mt-1 space-y-1" role="group" aria-labelledby={@id}>
|
||||||
<%= for user <- @users do %>
|
<%= for user <- @users do %>
|
||||||
<.link redirect_to={profile_path(user)}
|
<.link navigate={profile_path(user)}
|
||||||
class="group flex items-center px-3 py-2 text-base leading-5 font-medium text-gray-600 rounded-md hover:text-gray-900 hover:bg-gray-50"
|
class="group flex items-center px-3 py-2 text-base leading-5 font-medium text-gray-600 rounded-md hover:text-gray-900 hover:bg-gray-50"
|
||||||
>
|
>
|
||||||
<span class="w-2.5 h-2.5 mr-4 bg-indigo-500 rounded-full" aria-hidden="true"></span>
|
<span class="w-2.5 h-2.5 mr-4 bg-indigo-500 rounded-full" aria-hidden="true"></span>
|
||||||
|
@ -34,7 +34,7 @@ defmodule LiveBeatsWeb.LayoutView do
|
||||||
<div class="space-y-1">
|
<div class="space-y-1">
|
||||||
<%= if @current_user do %>
|
<%= if @current_user do %>
|
||||||
<.link
|
<.link
|
||||||
redirect_to={profile_path(@current_user)}
|
navigate={profile_path(@current_user)}
|
||||||
class={"text-gray-700 hover:text-gray-900 group flex items-center px-2 py-2 text-sm font-medium rounded-md #{if @active_tab == :profile, do: "bg-gray-200", else: "hover:bg-gray-50"}"}
|
class={"text-gray-700 hover:text-gray-900 group flex items-center px-2 py-2 text-sm font-medium rounded-md #{if @active_tab == :profile, do: "bg-gray-200", else: "hover:bg-gray-50"}"}
|
||||||
>
|
>
|
||||||
<.icon name={:music_note} outlined class="text-gray-400 group-hover:text-gray-500 mr-3 flex-shrink-0 h-6 w-6"/>
|
<.icon name={:music_note} outlined class="text-gray-400 group-hover:text-gray-500 mr-3 flex-shrink-0 h-6 w-6"/>
|
||||||
|
@ -42,14 +42,14 @@ defmodule LiveBeatsWeb.LayoutView do
|
||||||
</.link>
|
</.link>
|
||||||
|
|
||||||
<.link
|
<.link
|
||||||
redirect_to={Routes.settings_path(Endpoint, :edit)}
|
navigate={Routes.settings_path(Endpoint, :edit)}
|
||||||
class={"text-gray-700 hover:text-gray-900 group flex items-center px-2 py-2 text-sm font-medium rounded-md #{if @active_tab == :settings, do: "bg-gray-200", else: "hover:bg-gray-50"}"}
|
class={"text-gray-700 hover:text-gray-900 group flex items-center px-2 py-2 text-sm font-medium rounded-md #{if @active_tab == :settings, do: "bg-gray-200", else: "hover:bg-gray-50"}"}
|
||||||
>
|
>
|
||||||
<.icon name={:adjustments} outlined class="text-gray-400 group-hover:text-gray-500 mr-3 flex-shrink-0 h-6 w-6"/>
|
<.icon name={:adjustments} outlined class="text-gray-400 group-hover:text-gray-500 mr-3 flex-shrink-0 h-6 w-6"/>
|
||||||
Settings
|
Settings
|
||||||
</.link>
|
</.link>
|
||||||
<% else %>
|
<% else %>
|
||||||
<.link redirect_to={Routes.sign_in_path(Endpoint, :index)}
|
<.link navigate={Routes.sign_in_path(Endpoint, :index)}
|
||||||
class="text-gray-700 hover:text-gray-900 hover:bg-gray-50 group flex items-center px-2 py-2 text-sm font-medium rounded-md"
|
class="text-gray-700 hover:text-gray-900 hover:bg-gray-50 group flex items-center px-2 py-2 text-sm font-medium rounded-md"
|
||||||
>
|
>
|
||||||
<svg class="text-gray-400 group-hover:text-gray-500 mr-3 flex-shrink-0 h-6 w-6"
|
<svg class="text-gray-400 group-hover:text-gray-500 mr-3 flex-shrink-0 h-6 w-6"
|
||||||
|
@ -72,8 +72,8 @@ defmodule LiveBeatsWeb.LayoutView do
|
||||||
<:title><%= @current_user.name %></:title>
|
<:title><%= @current_user.name %></:title>
|
||||||
<:subtitle>@<%= @current_user.username %></:subtitle>
|
<:subtitle>@<%= @current_user.username %></:subtitle>
|
||||||
|
|
||||||
<:link redirect_to={profile_path(@current_user)}>View Profile</:link>
|
<:link navigate={profile_path(@current_user)}>View Profile</:link>
|
||||||
<:link redirect_to={Routes.settings_path(Endpoint, :edit)}>Settings</:link>
|
<:link navigate={Routes.settings_path(Endpoint, :edit)}>Settings</:link>
|
||||||
<:link href={Routes.o_auth_callback_path(Endpoint, :sign_out)} method={:delete}>Sign out</:link>
|
<:link href={Routes.o_auth_callback_path(Endpoint, :sign_out)} method={:delete}>Sign out</:link>
|
||||||
</.dropdown>
|
</.dropdown>
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in a new issue