@phillipsharring/graspr-framework 0.2.4 → 0.2.6
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/core/auth-state.js +11 -0
- package/src/core/boosted-nav.js +6 -0
package/package.json
CHANGED
package/src/core/auth-state.js
CHANGED
|
@@ -52,6 +52,17 @@ function applyAuthState(authData) {
|
|
|
52
52
|
loginLink?.removeAttribute('hidden');
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
+
// Auth-visibility elements — show or hide based on auth state.
|
|
56
|
+
// Use hidden attribute in markup so they start invisible (no flash).
|
|
57
|
+
// data-show-if-auth: hidden by default, revealed when authenticated
|
|
58
|
+
// data-hide-if-auth: hidden by default, revealed when NOT authenticated
|
|
59
|
+
document.querySelectorAll('[data-show-if-auth]').forEach(el => {
|
|
60
|
+
if (authenticated) el.removeAttribute('hidden');
|
|
61
|
+
});
|
|
62
|
+
document.querySelectorAll('[data-hide-if-auth]').forEach(el => {
|
|
63
|
+
if (!authenticated) el.removeAttribute('hidden');
|
|
64
|
+
});
|
|
65
|
+
|
|
55
66
|
// Widgets that require an authenticated session.
|
|
56
67
|
// Track triggered elements in a WeakSet so each element only fires once,
|
|
57
68
|
// even if multiple afterSwap/afterSettle handlers call applyAuthState while
|
package/src/core/boosted-nav.js
CHANGED
|
@@ -62,6 +62,12 @@ document.body.addEventListener('htmx:beforeSwap', (e) => {
|
|
|
62
62
|
|
|
63
63
|
if (!newApp) return;
|
|
64
64
|
|
|
65
|
+
// Preserve the page title — replacing serverResponse strips <head>
|
|
66
|
+
const newTitle = doc.querySelector('title');
|
|
67
|
+
if (newTitle) {
|
|
68
|
+
document.title = newTitle.textContent;
|
|
69
|
+
}
|
|
70
|
+
|
|
65
71
|
detail.target = app;
|
|
66
72
|
detail.serverResponse = newApp.outerHTML;
|
|
67
73
|
detail.swapOverride = 'outerHTML';
|