From 72c9650f7142945e367dd916aa55a7303e30cfa3 Mon Sep 17 00:00:00 2001 From: hippoz <10706925-hippoz@users.noreply.gitlab.com> Date: Sat, 22 Jul 2023 21:24:25 +0300 Subject: [PATCH] greatly improve handling of modals --- frontend/src/animations.js | 16 ++- .../components/overlays/AddCommunity.svelte | 44 ++---- .../components/overlays/CreateAccount.svelte | 56 +++----- .../components/overlays/CreateChannel.svelte | 54 +++----- .../components/overlays/EditChannel.svelte | 46 +++---- .../components/overlays/EditMessage.svelte | 46 +++---- frontend/src/components/overlays/Login.svelte | 52 +++---- frontend/src/components/overlays/Modal.svelte | 57 ++++++++ .../src/components/overlays/Prompt.svelte | 42 ++---- .../src/components/overlays/Settings.svelte | 130 ++++++++---------- frontend/src/styles/global.css | 16 ++- 11 files changed, 262 insertions(+), 297 deletions(-) create mode 100644 frontend/src/components/overlays/Modal.svelte diff --git a/frontend/src/animations.js b/frontend/src/animations.js index 1fb8a06..3250183 100644 --- a/frontend/src/animations.js +++ b/frontend/src/animations.js @@ -1,8 +1,22 @@ import { fade, fly, scale } from "svelte/transition"; -import { cubicInOut } from "svelte/easing"; +import { cubicInOut, linear } from "svelte/easing"; import { getItem } from "./storage"; import { smallViewport } from "./stores"; + +// Function specific for the Login and CreateAccount modals, where the transition duration is relied upon +export function maybeModalFadeIf(...e) { + if (e[1] && e[1]._condition) + return maybeModalFade(e[0]); + else + return { + delay: 0, + duration: e[1].duration, + easing: e[1].easing, + css: (_t) => "" + }; +} + export function maybeModalFade(node) { return maybeFade(node, { duration: 175, easing: cubicInOut }); } diff --git a/frontend/src/components/overlays/AddCommunity.svelte b/frontend/src/components/overlays/AddCommunity.svelte index 44163e6..6410691 100644 --- a/frontend/src/components/overlays/AddCommunity.svelte +++ b/frontend/src/components/overlays/AddCommunity.svelte @@ -1,7 +1,7 @@ - + + Create Community - + + + + + diff --git a/frontend/src/components/overlays/CreateAccount.svelte b/frontend/src/components/overlays/CreateAccount.svelte index 6e1bbd5..ba0401e 100644 --- a/frontend/src/components/overlays/CreateAccount.svelte +++ b/frontend/src/components/overlays/CreateAccount.svelte @@ -1,7 +1,7 @@ -