From da9dfe3b6672cb29d7e261a47a19248135254cf9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonatan=20K=C5=82osko?= Date: Mon, 6 Nov 2023 18:13:16 +0100 Subject: [PATCH] Update modal enter and leave (#2323) --- assets/css/utilities.css | 26 -------------- .../components/core_components.ex | 35 +++++++++++-------- .../live/hub/edit/team_component.ex | 9 +++-- test/livebook_teams/web/hub/new_live_test.exs | 8 ++--- 4 files changed, 28 insertions(+), 50 deletions(-) diff --git a/assets/css/utilities.css b/assets/css/utilities.css index f3efd5870..468db5b9a 100644 --- a/assets/css/utilities.css +++ b/assets/css/utilities.css @@ -35,32 +35,6 @@ /* Animations */ - .fade-in { - animation: fade-in-frames 200ms ease-out; - } - - .fade-out { - animation: fade-out-frames 200ms ease-in; - } - - @keyframes fade-in-frames { - from { - opacity: 0; - } - to { - opacity: 1; - } - } - - @keyframes fade-out-frames { - from { - opacity: 1; - } - to { - opacity: 0; - } - } - .delay-200 { animation: delay-frames 200ms; } diff --git a/lib/livebook_web/components/core_components.ex b/lib/livebook_web/components/core_components.ex index 293e76e4f..02d8de92f 100644 --- a/lib/livebook_web/components/core_components.ex +++ b/lib/livebook_web/components/core_components.ex @@ -172,12 +172,14 @@ defmodule LivebookWeb.CoreComponents do ~H"""
-
+
@@ -192,17 +194,15 @@ defmodule LivebookWeb.CoreComponents do aria-modal="true" tabindex="0" autofocus - phx-window-keydown={hide_modal(@id)} - phx-click-away={hide_modal(@id)} + phx-window-keydown={JS.exec("data-cancel", to: "##{@id}")} + phx-click-away={JS.exec("data-cancel", to: "##{@id}")} phx-key="escape" > - <.link :if={@patch} patch={@patch} class="hidden" id={"#{@id}-return"}> - <.link :if={@navigate} patch={@navigate} class="hidden" id={"#{@id}-return"}> + <%= if @default? do %>
- <.modal show={@show_key} id="show-key-modal" width={:medium} patch={~p"/hub/#{@hub.id}"}> + <.modal :if={@show_key} id="key-modal" show width={:medium} patch={~p"/hub/#{@hub.id}"}> <.teams_key_modal teams_key={@hub.teams_key} /> diff --git a/test/livebook_teams/web/hub/new_live_test.exs b/test/livebook_teams/web/hub/new_live_test.exs index f8759852c..fcbf9e546 100644 --- a/test/livebook_teams/web/hub/new_live_test.exs +++ b/test/livebook_teams/web/hub/new_live_test.exs @@ -52,11 +52,11 @@ defmodule LivebookWeb.Hub.NewLiveTest do # access the page and shows the teams key modal {:ok, view, _html} = live(conn, "/hub/team-#{name}?show-key=true") - refute has_element?(view, "#show-key-modal.hidden") + assert has_element?(view, "#key-modal") # access the page when closes the modal assert {:ok, view, _html} = live(conn, "/hub/team-#{name}") - assert has_element?(view, "#show-key-modal.hidden") + refute has_element?(view, "#key-modal") # checks if the hub is in the sidebar assert_sidebar_hub(view, "team-#{name}", name) @@ -113,11 +113,11 @@ defmodule LivebookWeb.Hub.NewLiveTest do # access the page and shows the teams key modal {:ok, view, _html} = live(conn, "/hub/team-#{name}?show-key=true") - refute has_element?(view, "#show-key-modal.hidden") + assert has_element?(view, "#key-modal") # access the page when closes the modal assert {:ok, view, _html} = live(conn, "/hub/team-#{name}") - assert has_element?(view, "#show-key-modal.hidden") + refute has_element?(view, "#key-modal") # checks if the hub is in the sidebar assert_sidebar_hub(view, "team-#{name}", name)