refactor: Consolidate script imports and update Alpine.js syntax in templates
This commit updates all generated template files and the header.templ source to use consolidated script bundles and modern Alpine.js syntax. Changes to templates/*.go (generated from .templ source files): - Replace individual script imports (admin.js, toast.js, header.js, etc.) with single /static/main.js bundle - Convert onclick attributes to Alpine.js @click directives for better integration with reactive components - Add x-data attributes to body elements where needed for Alpine components - Update event handlers to use Alpine.js syntax consistently Changes to templates/header.templ source file: - Add Alpine.js test div with x-data and x-init for debugging - Reformat theme dropdown and user menu markup with proper indentation - Maintain consistent Alpine.js directive formatting throughout This change reduces the number of HTTP requests and ensures consistent Alpine.js integration across all pages.
This commit is contained in:
@@ -30,7 +30,7 @@ func ErrorToast(message string) templ.Component {
|
||||
}
|
||||
ctx = templ.ClearChildren(ctx)
|
||||
if message != "" {
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 1, "<script>\n\t\t\tdocument.addEventListener('DOMContentLoaded', function() {\n\t\t\t\t// Show error toast with 8 second auto-dismiss\n\t\t\t\twindow.showToast.error('{ message }', 8000);\n\n\t\t\t\t// Add retry button to the toast\n\t\t\t\tsetTimeout(function() {\n\t\t\t\t\tconst toastContainer = document.getElementById('toast-container');\n\t\t\t\t\tif (toastContainer && toastContainer.lastElementChild) {\n\t\t\t\t\t\tconst toast = toastContainer.lastElementChild;\n\t\t\t\t\t\tconst retryBtn = document.createElement('button');\n\t\t\t\t\t\tretryBtn.className = 'ml-4 px-3 py-1 bg-white/20 hover:bg-white/30 rounded text-sm font-medium transition-colors';\n\t\t\t\t\t\tretryBtn.textContent = 'Retry';\n\t\t\t\t\t\tretryBtn.onclick = function() {\n\t\t\t\t\t\t\twindow.location.reload();\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\t// Insert before the close button\n\t\t\t\t\t\tconst closeBtn = toast.querySelector('.toast-close');\n\t\t\t\t\t\tif (closeBtn) {\n\t\t\t\t\t\t\tcloseBtn.parentElement.insertBefore(retryBtn, closeBtn);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\ttoast.appendChild(retryBtn);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}, 100);\n\t\t\t});\n\t\t</script>")
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 1, "<div x-data=\"toastError\" x-init=\"showErrorToast('{ message }')\"></div>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user