Skip to content

Commit 86ab327

Browse files
refactor: photo_uploader.ex
Co-authored-by: Afonso Martins <145707571+AfonsoMartins26@users.noreply.github.com>
1 parent 9abb18d commit 86ab327

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

lib/yearbook_web/components/photo_uploader.ex

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,25 @@ defmodule YearbookWeb.Components.PhotoUploader do
1414
attr :capture, :string, default: nil
1515
attr :accept, :string, default: nil
1616

17+
attr :phx_target, :any, default: nil
18+
attr :phx_change, :string, default: nil
19+
attr :phx_drop_target, :any, default: nil
20+
1721
slot :placeholder, required: false, doc: "Slot for the placeholder content."
1822

1923
def photo_uploader(assigns) do
2024
~H"""
21-
<.live_file_input upload={@upload} class="sr-only" capture={@capture} accept={@accept} />
25+
<.live_file_input
26+
upload={@upload}
27+
class="sr-only"
28+
capture={@capture}
29+
accept={@accept}
30+
phx-change={@phx_change}
31+
phx-target={@phx_target}
32+
/>
2233
<label for={@upload.ref} class="block">
2334
<section
24-
phx-drop-target={@upload.ref}
35+
phx-drop-target={@phx_drop_target || @upload.ref}
2536
class={[
2637
"transition-colors hover:cursor-pointer border-2 border-dashed",
2738
@rounded && "rounded-full overflow-hidden",

0 commit comments

Comments
 (0)