Skip to content

Commit 8140d63

Browse files
committed
refactor: alias Phoenix.LiveView.JS in layout components
1 parent 0215393 commit 8140d63

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

lib/lightning_web/components/layout_components.ex

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ defmodule LightningWeb.LayoutComponents do
55
import PetalComponents.Avatar
66

77
alias LightningWeb.Components.Menu
8+
alias Phoenix.LiveView.JS
89

910
attr :current_user, Lightning.Accounts.User, required: true
1011
attr :collapsed, :boolean, default: false
@@ -23,8 +24,8 @@ defmodule LightningWeb.LayoutComponents do
2324
~H"""
2425
<div
2526
class={["relative", !@collapsed && "w-full"]}
26-
phx-click-away={Phoenix.LiveView.JS.hide(to: "##{@menu_id}")}
27-
phx-window-keydown={Phoenix.LiveView.JS.hide(to: "##{@menu_id}")}
27+
phx-click-away={JS.hide(to: "##{@menu_id}")}
28+
phx-window-keydown={JS.hide(to: "##{@menu_id}")}
2829
phx-key="Escape"
2930
>
3031
<button
@@ -34,7 +35,7 @@ defmodule LightningWeb.LayoutComponents do
3435
@collapsed && "p-2"
3536
]}
3637
phx-click={
37-
Phoenix.LiveView.JS.toggle(
38+
JS.toggle(
3839
to: "##{@menu_id}",
3940
in: "transition ease-out duration-100",
4041
out: "transition ease-in duration-75"
@@ -348,33 +349,33 @@ defmodule LightningWeb.LayoutComponents do
348349
end
349350

350351
defp show_project_picker do
351-
Phoenix.LiveView.JS.show(to: "#project-picker-modal")
352-
|> Phoenix.LiveView.JS.show(
352+
JS.show(to: "#project-picker-modal")
353+
|> JS.show(
353354
to: "#project-picker-backdrop",
354355
transition:
355356
{"transition ease-out duration-200", "opacity-0", "opacity-100"}
356357
)
357-
|> Phoenix.LiveView.JS.show(
358+
|> JS.show(
358359
to: "#project-picker-content",
359360
transition:
360361
{"transition ease-out duration-200", "opacity-0 scale-95",
361362
"opacity-100 scale-100"}
362363
)
363-
|> Phoenix.LiveView.JS.focus(to: "#project-picker-input")
364+
|> JS.focus(to: "#project-picker-input")
364365
end
365366

366367
defp hide_project_picker do
367-
Phoenix.LiveView.JS.hide(
368+
JS.hide(
368369
to: "#project-picker-backdrop",
369370
transition: {"transition ease-in duration-150", "opacity-100", "opacity-0"}
370371
)
371-
|> Phoenix.LiveView.JS.hide(
372+
|> JS.hide(
372373
to: "#project-picker-content",
373374
transition:
374375
{"transition ease-in duration-150", "opacity-100 scale-100",
375376
"opacity-0 scale-95"}
376377
)
377-
|> Phoenix.LiveView.JS.hide(to: "#project-picker-modal", time: 150)
378+
|> JS.hide(to: "#project-picker-modal", time: 150)
378379
end
379380

380381
# https://play.tailwindcss.com/r7kBDT2cJY?layout=horizontal
@@ -568,14 +569,14 @@ defmodule LightningWeb.LayoutComponents do
568569
<div class="flex items-center">
569570
<div
570571
class="relative"
571-
phx-click-away={Phoenix.LiveView.JS.hide(to: "##{@dropdown_id}")}
572-
phx-window-keydown={Phoenix.LiveView.JS.hide(to: "##{@dropdown_id}")}
572+
phx-click-away={JS.hide(to: "##{@dropdown_id}")}
573+
phx-window-keydown={JS.hide(to: "##{@dropdown_id}")}
573574
phx-key="Escape"
574575
>
575576
<button
576577
class="flex items-center text-sm font-medium text-gray-500 hover:text-gray-700"
577578
phx-click={
578-
Phoenix.LiveView.JS.toggle(
579+
JS.toggle(
579580
to: "##{@dropdown_id}",
580581
in: "transition ease-out duration-100",
581582
out: "transition ease-in duration-75"

0 commit comments

Comments
 (0)