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
-
+
+ Cancel
+ Create
+
+
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 @@
-
+
+
+
+ Password
+
+
+
+
+
+ Log in instead
+ Create
+
+
diff --git a/frontend/src/components/overlays/CreateChannel.svelte b/frontend/src/components/overlays/CreateChannel.svelte
index aa420d6..bb43b6f 100644
--- a/frontend/src/components/overlays/CreateChannel.svelte
+++ b/frontend/src/components/overlays/CreateChannel.svelte
@@ -1,7 +1,7 @@
-
+
+
+ Create Channel
+ {#if community.id !== -1}
+ in { community.name }
+ {/if}
+
-
+
+ Cancel
+ Create
+
+
diff --git a/frontend/src/components/overlays/EditChannel.svelte b/frontend/src/components/overlays/EditChannel.svelte
index 59476ab..d104af8 100644
--- a/frontend/src/components/overlays/EditChannel.svelte
+++ b/frontend/src/components/overlays/EditChannel.svelte
@@ -1,7 +1,7 @@
-
+
+ Cancel
+ Delete
+ Save
+
+
diff --git a/frontend/src/components/overlays/EditMessage.svelte b/frontend/src/components/overlays/EditMessage.svelte
index a29f7be..f8ff1df 100644
--- a/frontend/src/components/overlays/EditMessage.svelte
+++ b/frontend/src/components/overlays/EditMessage.svelte
@@ -1,7 +1,7 @@
-
+
+ Cancel
+ Delete
+ Save
+
+
diff --git a/frontend/src/components/overlays/Login.svelte b/frontend/src/components/overlays/Login.svelte
index 8effaea..27aaf14 100644
--- a/frontend/src/components/overlays/Login.svelte
+++ b/frontend/src/components/overlays/Login.svelte
@@ -2,8 +2,8 @@
import { overlayStore, OverlayType } from "../../stores";
import { remoteCall } from "../../request";
import { authWithToken } from "../../auth";
- import { maybeModalScale } from "../../animations";
import { methods } from "../../request";
+ import Modal from "./Modal.svelte";
let username = "";
let password = "";
@@ -35,47 +35,33 @@
overlayStore.push(OverlayType.CreateAccount);
}
};
- const onKeydown = async (e) => {
- if (e.code !== "Enter")
- return;
-
- await login();
- };
-
+
+ Create an account instead
+ Log In
+
+
diff --git a/frontend/src/components/overlays/Modal.svelte b/frontend/src/components/overlays/Modal.svelte
new file mode 100644
index 0000000..7aedc58
--- /dev/null
+++ b/frontend/src/components/overlays/Modal.svelte
@@ -0,0 +1,57 @@
+
+
+
+
+
+
+
+ {#if $$slots.header}
+
+ {/if}
+
+ {#if $$slots.content}
+
+
+
+ {/if}
+
+ {#if $$slots.footer}
+
+ {/if}
+
+
diff --git a/frontend/src/components/overlays/Prompt.svelte b/frontend/src/components/overlays/Prompt.svelte
index f917570..586251a 100644
--- a/frontend/src/components/overlays/Prompt.svelte
+++ b/frontend/src/components/overlays/Prompt.svelte
@@ -1,5 +1,5 @@
-
+
+ { heading }
-
+
+ Cancel
+ Submit
+
+
diff --git a/frontend/src/components/overlays/Settings.svelte b/frontend/src/components/overlays/Settings.svelte
index 90be95c..7931318 100644
--- a/frontend/src/components/overlays/Settings.svelte
+++ b/frontend/src/components/overlays/Settings.svelte
@@ -2,12 +2,12 @@
import { overlayStore, userInfoStore, smallViewport, theme, doAnimations, OverlayType, sendTypingUpdatesItemStore } from "../../stores";
import { logOut } from "../../auth";
import { maybeModalFade, maybeModalScale } from "../../animations";
- import request, { methods, remoteBlobUpload, remoteCall } from "../../request";
+ import request, { methods, remoteBlobUpload } from "../../request";
import { apiRoute, getItem } from "../../storage";
import UserView from "../UserView.svelte";
import ChipBar from "../ChipBar.svelte";
- import Switch from "../Switch.svelte";
import StoredSwitch from "../StoredSwitch.svelte";
+ import Modal from "./Modal.svelte";
export let close = () => {};
let avatarFileInput;
@@ -76,12 +76,7 @@
};
-
-
-
-
-
+
+ Settings
-
-
selectedTab = tab } options={[
- { id: "ACCOUNT", text: "Account", icon: "person" },
- { id: "PRIVACY", text: "Privacy", icon: "lock" },
- { id: "APPEARANCE", text: "Appearance", icon: "palette" },
- ]}>
+
+ selectedTab = tab } options={[
+ { id: "ACCOUNT", text: "Account", icon: "person" },
+ { id: "PRIVACY", text: "Privacy", icon: "lock" },
+ { id: "APPEARANCE", text: "Appearance", icon: "palette" },
+ ]}>
+
+
+
+ {#if selectedTab === "ACCOUNT"}
+
+
+
+
+ Update Avatar
+ Log Out
+
+
+ {:else if selectedTab == "PRIVACY"}
+
+
+ Let others know when I'm typing
+ If this is enabled, other users will see an indicator while you're typing a message.
+
+
+
+
+
+
+
+ Make Waffle work
+ Waffle needs to store data such as your messages, created channels, your username, your profile picture and more in order to work. If you'd like to stop this, you can delete your account.
+
+
+ {:else if selectedTab === "APPEARANCE"}
+ Theme
+
+ Dark
+ Light
+
- {#if selectedTab === "ACCOUNT"}
-
-
-
-
- Update Avatar
- Log Out
-
+
+
+ Reduce animations
+ Reduce the amount of animations and visual effects.
- {:else if selectedTab == "PRIVACY"}
-
-
- Let others know when I'm typing
- If this is enabled, other users will see an indicator while you're typing a message.
-
-
-
-
+
+
-
-
- Make Waffle work
- Waffle needs to store data such as your messages, created channels, your username, your profile picture and more in order to work. If you'd like to stop this, you can delete your account.
-
-
- {:else if selectedTab === "APPEARANCE"}
-
Theme
-
- Dark
- Light
-
-
-
-
-
-
- Reduce animations
- Reduce the amount of animations and visual effects.
-
-
-
-
-
- {:else}
-
Page not found: { selectedTab }
- {/if}
-
-
-
+
+ {:else}
+ Page not found: { selectedTab }
+ {/if}
+
+
diff --git a/frontend/src/styles/global.css b/frontend/src/styles/global.css
index 1c57b7f..a2e3044 100644
--- a/frontend/src/styles/global.css
+++ b/frontend/src/styles/global.css
@@ -222,10 +222,13 @@ body {
bottom: 0;
z-index: 15;
background-color: rgba(0, 0, 0, 0.4);
- backdrop-filter: blur(1.5px);
contain: strict;
}
+.modal-backdrop.blur {
+ backdrop-filter: blur(1.5px);
+}
+
.modal-backdrop-opaque {
background-color: var(--background-color-1);
backdrop-filter: unset;
@@ -284,7 +287,6 @@ body {
.modal-backdrop {
align-items: flex-end;
justify-content: center;
- backdrop-filter: unset;
}
.modal-backdrop-opaque {
@@ -327,8 +329,10 @@ body {
background: none;
text-align: center;
border: none;
- padding: 0.7em;
- border-radius: 1em;
+ padding: 0.85em;
+ padding-top: 0.65em;
+ padding-bottom: 0.65em;
+ border-radius: 9999px;
font: inherit;
user-select: none;
font-weight: 550;
@@ -588,6 +592,10 @@ body {
border-bottom-left-radius: var(--radius-mdplus);
}
+.full-width {
+ width: 100%;
+}
+
/*! the tweaks below are heavily based on modern-normalize v1.1.0 | MIT License | https://github.com/sindresorhus/modern-normalize */