@panomc/theme-core 1.0.0-dev.53 → 1.0.0-dev.54
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/lib/Store.js +2 -2
- package/src/lib/components/DefaultToast.svelte +2 -1
- package/src/lib/components/Toast.svelte +13 -1
- package/src/lib/components/ToastContainer.svelte +16 -2
- package/src/lib/pages/LoginPage.svelte +4 -4
- package/src/lib/pages/RegisterPage.svelte +2 -2
- package/src/lib/pages/ThemeSettingsPage.svelte +6 -5
- package/src/lib/ui-logics/layout-logics/ThemeSettingsLayoutLogics.js +15 -2
- package/src/lib/ui-logics/page-logics/SettingsPageLogics.js +7 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@panomc/theme-core",
|
|
3
|
-
"version": "1.0.0-dev.
|
|
3
|
+
"version": "1.0.0-dev.54",
|
|
4
4
|
"description": "The Pano theme engine: hooks factories, plugin engine, headless page controllers, default views and the theme CLI. Themes depend on this package instead of forking vanilla-theme.",
|
|
5
5
|
"author": "PanoMC",
|
|
6
6
|
"license": "MIT",
|
package/src/lib/Store.js
CHANGED
|
@@ -3,7 +3,7 @@ import { writable } from "svelte/store";
|
|
|
3
3
|
import { sendLogout } from "$pano/lib/services/auth.js";
|
|
4
4
|
import { goto } from "$app/navigation";
|
|
5
5
|
import { redirect } from "@sveltejs/kit";
|
|
6
|
-
import {
|
|
6
|
+
import { showSuccess as showSuccessToast } from "$pano/lib/components/ToastContainer.svelte";
|
|
7
7
|
|
|
8
8
|
export const notificationsCount = writable(0);
|
|
9
9
|
export const quickNotifications = writable([]);
|
|
@@ -25,7 +25,7 @@ export async function logout(session) {
|
|
|
25
25
|
});
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
await
|
|
28
|
+
await showSuccessToast("toasts.session-logged-out-successful");
|
|
29
29
|
await goto("/");
|
|
30
30
|
});
|
|
31
31
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<Toast {id}>{@html $_(text, { values })}</Toast>
|
|
1
|
+
<Toast {id} {variant}>{@html $_(text, { values })}</Toast>
|
|
2
2
|
|
|
3
3
|
<script>
|
|
4
4
|
import { _ } from 'svelte-i18n';
|
|
@@ -8,4 +8,5 @@
|
|
|
8
8
|
export let id;
|
|
9
9
|
export let text;
|
|
10
10
|
export let values;
|
|
11
|
+
export let variant = null;
|
|
11
12
|
</script>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<div
|
|
2
2
|
id="appToast{id}"
|
|
3
|
-
class="animate__animated animate__bounceInUp toast align-items-center shadow-lg text-bg-tertiary opacity-100"
|
|
3
|
+
class="animate__animated animate__bounceInUp toast align-items-center shadow-lg text-bg-tertiary opacity-100 {variantClass}"
|
|
4
4
|
role="alert"
|
|
5
5
|
aria-live="assertive"
|
|
6
6
|
aria-atomic="true"
|
|
@@ -10,4 +10,16 @@
|
|
|
10
10
|
|
|
11
11
|
<script>
|
|
12
12
|
export let id;
|
|
13
|
+
|
|
14
|
+
// 'success' | 'danger' | null. Mapped instead of interpolated straight into the class
|
|
15
|
+
// list so a caller can't inject an arbitrary utility class, and so a neutral toast
|
|
16
|
+
// keeps text-bg-tertiary's own contrast colour.
|
|
17
|
+
export let variant = null;
|
|
18
|
+
|
|
19
|
+
const VARIANT_CLASSES = {
|
|
20
|
+
success: 'text-success',
|
|
21
|
+
danger: 'text-danger',
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
$: variantClass = VARIANT_CLASSES[variant] ?? '';
|
|
13
25
|
</script>
|
|
@@ -29,13 +29,16 @@
|
|
|
29
29
|
return new Promise((resolve) => setTimeout(resolve, time));
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
|
|
32
|
+
// `options.variant` ('success' | 'danger') colours the toast text. Prefer the
|
|
33
|
+
// showSuccess/showError wrappers below at call sites — they read as the outcome they
|
|
34
|
+
// report. Plain `show` stays neutral for toasts that are neither.
|
|
35
|
+
export async function show(text, params = {}, toastComponent = DefaultToast, options = {}) {
|
|
33
36
|
if (text) {
|
|
34
37
|
params.text = text;
|
|
35
38
|
}
|
|
36
39
|
|
|
37
40
|
if (toastComponent === DefaultToast) {
|
|
38
|
-
params = { text, values: params };
|
|
41
|
+
params = { text, values: params, variant: options.variant ?? null };
|
|
39
42
|
}
|
|
40
43
|
|
|
41
44
|
const toast = { component: toastComponent, params };
|
|
@@ -71,6 +74,17 @@
|
|
|
71
74
|
}
|
|
72
75
|
}
|
|
73
76
|
|
|
77
|
+
// No toastComponent parameter on purpose: `variant` is only threaded into
|
|
78
|
+
// DefaultToast's props, so a custom component would silently drop it. Reach for
|
|
79
|
+
// `show` directly when you need one.
|
|
80
|
+
export function showSuccess(text, params = {}) {
|
|
81
|
+
return show(text, params, DefaultToast, { variant: 'success' });
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export function showError(text, params = {}) {
|
|
85
|
+
return show(text, params, DefaultToast, { variant: 'danger' });
|
|
86
|
+
}
|
|
87
|
+
|
|
74
88
|
export function limitTitle(text) {
|
|
75
89
|
const limit = 32;
|
|
76
90
|
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
import { currentLanguage } from "$pano/lib/language.util";
|
|
69
69
|
|
|
70
70
|
import { getCredentials, sendLogin, sendRegister, verifyLinkCode } from "$pano/lib/services/auth.js";
|
|
71
|
-
import {
|
|
71
|
+
import { showSuccess as showSuccessToast } from "$pano/lib/components/ToastContainer.svelte";
|
|
72
72
|
|
|
73
73
|
import { stripIdentifierWhitespace } from "$pano/lib/loginInput.util.js";
|
|
74
74
|
import { panoApiClient } from "$pano/lib/PluginAPI.js";
|
|
@@ -232,7 +232,7 @@
|
|
|
232
232
|
return data;
|
|
233
233
|
});
|
|
234
234
|
|
|
235
|
-
await
|
|
235
|
+
await showSuccessToast("successes.LOGIN_SUCCESSFUL");
|
|
236
236
|
await goto("/");
|
|
237
237
|
return;
|
|
238
238
|
}
|
|
@@ -247,7 +247,7 @@
|
|
|
247
247
|
return;
|
|
248
248
|
}
|
|
249
249
|
|
|
250
|
-
await
|
|
250
|
+
await showSuccessToast("successes.REGISTER_SUCCESSFUL");
|
|
251
251
|
|
|
252
252
|
const loginBody = await sendLogin({ usernameOrEmail: $usernameOrEmail, password: $password });
|
|
253
253
|
if (loginBody.result !== "ok") {
|
|
@@ -408,7 +408,7 @@
|
|
|
408
408
|
return data;
|
|
409
409
|
});
|
|
410
410
|
|
|
411
|
-
await
|
|
411
|
+
await showSuccessToast("successes.LOGIN_SUCCESSFUL");
|
|
412
412
|
|
|
413
413
|
await goto("/");
|
|
414
414
|
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
import { NETWORK_ERROR } from "$pano/lib/api.util";
|
|
57
57
|
|
|
58
58
|
import PageTitle from "$pano/lib/components/PageTitle.svelte";
|
|
59
|
-
import {
|
|
59
|
+
import { showSuccess as showSuccessToast } from "$pano/lib/components/ToastContainer.svelte";
|
|
60
60
|
|
|
61
61
|
import { sendRegister, getCredentials } from "$pano/lib/services/auth.js";
|
|
62
62
|
import { panoApiClient } from "$pano/lib/PluginAPI.js";
|
|
@@ -115,7 +115,7 @@
|
|
|
115
115
|
return data;
|
|
116
116
|
});
|
|
117
117
|
|
|
118
|
-
await
|
|
118
|
+
await showSuccessToast("successes.LOGIN_SUCCESSFUL");
|
|
119
119
|
await goto("/");
|
|
120
120
|
loading.set(false);
|
|
121
121
|
return;
|
|
@@ -62,7 +62,8 @@
|
|
|
62
62
|
<script>
|
|
63
63
|
import { _ } from "svelte-i18n";
|
|
64
64
|
import {
|
|
65
|
-
|
|
65
|
+
showSuccessToast,
|
|
66
|
+
showErrorToast,
|
|
66
67
|
showConfirm
|
|
67
68
|
} from "$pano/lib/ui-logics/layout-logics/ThemeSettingsLayoutLogics";
|
|
68
69
|
import { getContext } from "svelte";
|
|
@@ -479,7 +480,7 @@
|
|
|
479
480
|
$themeSettings = newSettings;
|
|
480
481
|
originalThemeSettings.set(structuredClone($themeSettings));
|
|
481
482
|
|
|
482
|
-
|
|
483
|
+
showSuccessToast(
|
|
483
484
|
$_("messages.settings-save-success") || "Ayarlar başarıyla kaydedildi!"
|
|
484
485
|
);
|
|
485
486
|
$saving = false;
|
|
@@ -516,7 +517,7 @@
|
|
|
516
517
|
$themeSettings = newSettings;
|
|
517
518
|
originalThemeSettings.set(structuredClone($themeSettings));
|
|
518
519
|
|
|
519
|
-
|
|
520
|
+
showSuccessToast(
|
|
520
521
|
$_("messages.settings-reset-tab-success") ||
|
|
521
522
|
"Sekme ayarları sıfırlandı!"
|
|
522
523
|
);
|
|
@@ -539,10 +540,10 @@
|
|
|
539
540
|
$themeSettings = newSettings;
|
|
540
541
|
originalThemeSettings.set(structuredClone($themeSettings));
|
|
541
542
|
|
|
542
|
-
|
|
543
|
+
showSuccessToast($_("messages.settings-reset-all-success"));
|
|
543
544
|
} catch (error) {
|
|
544
545
|
console.error("Failed to reset all settings:", error);
|
|
545
|
-
|
|
546
|
+
showErrorToast($_("messages.settings-reset-all-error"));
|
|
546
547
|
} finally {
|
|
547
548
|
$resettingAll = false;
|
|
548
549
|
}
|
|
@@ -21,8 +21,21 @@ function postReady() {
|
|
|
21
21
|
window.parent.postMessage({ type: "theme-settings-ready" }, "*");
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
// The theme settings UI runs inside an iframe in the panel, so its toasts are posted to
|
|
25
|
+
// the parent instead of rendered here. `variant` ('success' | 'danger') rides along so the
|
|
26
|
+
// panel can colour the toast — without it the panel has no way to tell an outcome from a
|
|
27
|
+
// failure and has to fall back to a neutral toast. A panel build that predates the field
|
|
28
|
+
// simply ignores it.
|
|
29
|
+
export function showToast(text, params = {}, toastComponent, variant = null) {
|
|
30
|
+
window.parent.postMessage({ type: "show-toast", text, params, toastComponent, variant }, "*");
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function showSuccessToast(text, params = {}) {
|
|
34
|
+
showToast(text, params, undefined, "success");
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export function showErrorToast(text, params = {}) {
|
|
38
|
+
showToast(text, params, undefined, "danger");
|
|
26
39
|
}
|
|
27
40
|
|
|
28
41
|
const confirmCallbacks = new Map();
|
|
@@ -183,11 +183,16 @@ export async function onLogoutSession(sessionId, loadingSessionId, showToast, in
|
|
|
183
183
|
loadingSessionId.set(null);
|
|
184
184
|
|
|
185
185
|
if (body.error) {
|
|
186
|
-
|
|
186
|
+
// The variant rides on `show`'s options argument rather than a separate
|
|
187
|
+
// showError parameter: onLogoutSession receives the toast function from the
|
|
188
|
+
// view, and widening that signature would be a breaking controller-props change.
|
|
189
|
+
await showToast('errors.' + body.error, {}, undefined, { variant: 'danger' });
|
|
187
190
|
return;
|
|
188
191
|
}
|
|
189
192
|
|
|
190
|
-
await showToast('toasts.session-logged-out-successful'
|
|
193
|
+
await showToast('toasts.session-logged-out-successful', {}, undefined, {
|
|
194
|
+
variant: 'success',
|
|
195
|
+
});
|
|
191
196
|
invalidateAll();
|
|
192
197
|
},
|
|
193
198
|
});
|