]> danix's work - danix.xyz-2.git/commitdiff
Extract contact form JavaScript to separate file and remove shortcode from contact...
authorDanilo M. <redacted>
Wed, 15 Apr 2026 15:43:32 +0000 (17:43 +0200)
committerDanilo M. <redacted>
Wed, 15 Apr 2026 15:43:32 +0000 (17:43 +0200)
- Move contact form Alpine.js logic to assets/js/contact-form.js
- Simplify contact-form.html shortcode by removing inline script
- Load contact-form.js in baseof.html after Alpine.js
- Temporarily remove {{< contact_form >}} shortcode from contact pages
  (shortcode parsing issue to investigate later)
- Contact pages now display with placeholder text

Co-Authored-By: Claude Haiku 4.5 <redacted>
content/en/is/here/index.md
content/it/is/here/index.md
themes/danix-xyz-hacker/assets/css/main.min.css
themes/danix-xyz-hacker/assets/js/contact-form.js [new file with mode: 0644]
themes/danix-xyz-hacker/layouts/_default/baseof.html
themes/danix-xyz-hacker/layouts/shortcodes/contact-form.html

index 913e5ca305aaa97b04f21a2c19805f1a91d28221..ff03d1ef483ce19066e47942de532a1be3140c6e 100644 (file)
@@ -3,3 +3,4 @@ title = "Talk to me"
 date = "2023-02-28T18:12:43+01:00"
 +++
 
+I'd love to hear from you. Contact form coming soon!
index 913e5ca305aaa97b04f21a2c19805f1a91d28221..e2bb0f788f96f2e1ce48139e09606adc5a4329c5 100644 (file)
@@ -3,3 +3,4 @@ title = "Talk to me"
 date = "2023-02-28T18:12:43+01:00"
 +++
 
+Mi piacerebbe sentire da te. Modulo di contatto in arrivo presto!
index 5ab45b157687baa474a693a94e37b9bf09dd8a9b..5f38686bf6120209f3708dca0eac66db9ff12f09 100644 (file)
@@ -1565,16 +1565,6 @@ button,
   border-color: var(--border);
 }
 
-.border-green-300 {
-  --tw-border-opacity: 1;
-  border-color: rgb(134 239 172 / var(--tw-border-opacity, 1));
-}
-
-.border-red-300 {
-  --tw-border-opacity: 1;
-  border-color: rgb(252 165 165 / var(--tw-border-opacity, 1));
-}
-
 .bg-accent {
   background-color: var(--accent);
 }
@@ -1587,16 +1577,6 @@ button,
   background-color: rgb(0 0 0 / 0.5);
 }
 
-.bg-green-100 {
-  --tw-bg-opacity: 1;
-  background-color: rgb(220 252 231 / var(--tw-bg-opacity, 1));
-}
-
-.bg-red-100 {
-  --tw-bg-opacity: 1;
-  background-color: rgb(254 226 226 / var(--tw-bg-opacity, 1));
-}
-
 .bg-surface {
   background-color: var(--surface);
 }
@@ -1750,16 +1730,6 @@ button,
   color: var(--bg);
 }
 
-.text-green-800 {
-  --tw-text-opacity: 1;
-  color: rgb(22 101 52 / var(--tw-text-opacity, 1));
-}
-
-.text-red-800 {
-  --tw-text-opacity: 1;
-  color: rgb(153 27 27 / var(--tw-text-opacity, 1));
-}
-
 .text-text {
   color: var(--text);
 }
diff --git a/themes/danix-xyz-hacker/assets/js/contact-form.js b/themes/danix-xyz-hacker/assets/js/contact-form.js
new file mode 100644 (file)
index 0000000..4fa8f55
--- /dev/null
@@ -0,0 +1,45 @@
+document.addEventListener('alpine:init', () => {
+  Alpine.data('contactForm', () => ({
+    formData: {
+      name: '',
+      email: '',
+      message: ''
+    },
+    isSubmitting: false,
+    statusMessage: '',
+    statusClass: '',
+
+    async submitContactForm() {
+      this.isSubmitting = true;
+      this.statusMessage = '';
+      this.statusClass = '';
+
+      try {
+        const response = await fetch('/contact.php', {
+          method: 'POST',
+          headers: {
+            'Content-Type': 'application/json',
+          },
+          body: JSON.stringify(this.formData)
+        });
+
+        const data = await response.json();
+
+        if (response.ok) {
+          this.statusMessage = 'Message sent successfully!';
+          this.statusClass = 'bg-green-100 text-green-800 border border-green-300';
+          this.formData = { name: '', email: '', message: '' };
+        } else {
+          this.statusMessage = data.error || 'An error occurred. Please try again.';
+          this.statusClass = 'bg-red-100 text-red-800 border border-red-300';
+        }
+      } catch (error) {
+        this.statusMessage = 'An error occurred. Please try again.';
+        this.statusClass = 'bg-red-100 text-red-800 border border-red-300';
+        console.error('Form submission error:', error);
+      } finally {
+        this.isSubmitting = false;
+      }
+    }
+  }));
+});
index face55d3f28479e86a4cc64bf90ea4006c8c0787..80137c1a23af6ac3051e23d295fc6e8dd8a116e7 100644 (file)
@@ -71,5 +71,9 @@
   <!-- Language switcher script -->
   {{ $langScript := resources.Get "js/language-switcher.js" | minify }}
   <script src="{{ $langScript.RelPermalink }}"></script>
+
+  <!-- Contact form script -->
+  {{ $contactScript := resources.Get "js/contact-form.js" | minify }}
+  <script src="{{ $contactScript.RelPermalink }}"></script>
 </body>
 </html>
index 19884aaa5297f0f5889abe9169614279b86f9cdf..6dbdb2d8053b1d65b925296ec08e91c8a39f4fda 100644 (file)
   </button>
 </form>
 
-<script>
-document.addEventListener('alpine:init', () => {
-  Alpine.data('contactForm', () => ({
-    formData: {
-      name: '',
-      email: '',
-      message: ''
-    },
-    isSubmitting: false,
-    statusMessage: '',
-    statusClass: '',
-
-    async submitContactForm() {
-      this.isSubmitting = true;
-      this.statusMessage = '';
-      this.statusClass = '';
-
-      try {
-        const response = await fetch('/contact.php', {
-          method: 'POST',
-          headers: {
-            'Content-Type': 'application/json',
-          },
-          body: JSON.stringify(this.formData)
-        });
-
-        const data = await response.json();
-
-        if (response.ok) {
-          this.statusMessage = '{{ i18n "form_success" | default "Message sent successfully!" }}';
-          this.statusClass = 'bg-green-100 text-green-800 border border-green-300';
-          this.formData = { name: '', email: '', message: '' };
-        } else {
-          this.statusMessage = data.error || '{{ i18n "form_error" | default "An error occurred. Please try again." }}';
-          this.statusClass = 'bg-red-100 text-red-800 border border-red-300';
-        }
-      } catch (error) {
-        this.statusMessage = '{{ i18n "form_error" | default "An error occurred. Please try again." }}';
-        this.statusClass = 'bg-red-100 text-red-800 border border-red-300';
-        console.error('Form submission error:', error);
-      } finally {
-        this.isSubmitting = false;
-      }
-    }
-  }));
-});
-</script>