From 0d6ad2c233de13c19685562e2f699760ce5db241 Mon Sep 17 00:00:00 2001 From: Yanik Kumar Date: Tue, 15 Jul 2025 10:41:14 +0530 Subject: [PATCH 1/5] Fixed the bug for header and footer in submit again request --- app/Controllers/ValidationTestController.php | 10 +++++++++- app/Views/validation-test.twig | 10 ++++------ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/app/Controllers/ValidationTestController.php b/app/Controllers/ValidationTestController.php index f9ad7de..725b64b 100644 --- a/app/Controllers/ValidationTestController.php +++ b/app/Controllers/ValidationTestController.php @@ -8,6 +8,14 @@ class ValidationTestController { public function index() { + if (is_htmx_request()) { + // Only return the form fragment for HTMX requests + return view('partials/validation-test', [ + 'errors' => [], + 'old' => [], + ]); + } + return view('validation-test', ['title' => 'ValidationTestController Index']); } @@ -33,4 +41,4 @@ public function handleForm() 'email' => $data['email'], ]); } -} \ No newline at end of file +} diff --git a/app/Views/validation-test.twig b/app/Views/validation-test.twig index 9322b7e..57c5493 100644 --- a/app/Views/validation-test.twig +++ b/app/Views/validation-test.twig @@ -2,10 +2,8 @@ {% block title %}validation-test{% endblock %} {% block content %} -

validation-test

-

This is the validation-test page.

-

Validation Test Form

-
- {% include "partials/validation-form.twig" %} -
+

Validation Test Form

+
+ {% include "partials/validation-form.twig" %} +
{% endblock %} From 226a348149dfbaf449bdb7c79ec562246a26b7a1 Mon Sep 17 00:00:00 2001 From: Yanik Kumar Date: Tue, 15 Jul 2025 11:14:30 +0530 Subject: [PATCH 2/5] Spinner added before the htmx request submission --- app/Views/Components/spinner.twig | 29 +++++++++++++++++++++++++ app/Views/partials/validation-form.twig | 5 ++++- 2 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 app/Views/Components/spinner.twig diff --git a/app/Views/Components/spinner.twig b/app/Views/Components/spinner.twig new file mode 100644 index 0000000..1194a35 --- /dev/null +++ b/app/Views/Components/spinner.twig @@ -0,0 +1,29 @@ +{# SproutPHP Component: spinner.twig #} +
+
+
+ \ No newline at end of file diff --git a/app/Views/partials/validation-form.twig b/app/Views/partials/validation-form.twig index 933ac13..1b1bdd1 100644 --- a/app/Views/partials/validation-form.twig +++ b/app/Views/partials/validation-form.twig @@ -1,7 +1,9 @@ +{% include "components/spinner.twig" %}
@@ -21,5 +23,6 @@
{{ errors.email }}
{% endif %} - +
\ No newline at end of file From 2f662219afdef7f92b6459ae0c6618e1aa40cf6b Mon Sep 17 00:00:00 2001 From: Yanik Kumar Date: Tue, 15 Jul 2025 11:24:28 +0530 Subject: [PATCH 3/5] Error removing on focusin --- app/Views/partials/validation-form.twig | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/app/Views/partials/validation-form.twig b/app/Views/partials/validation-form.twig index 1b1bdd1..82b155a 100644 --- a/app/Views/partials/validation-form.twig +++ b/app/Views/partials/validation-form.twig @@ -13,16 +13,28 @@ {% if errors.name %} -
{{ errors.name }}
+
{{ errors.name }}
{% endif %}
{% if errors.email %} -
{{ errors.email }}
+
{{ errors.email }}
{% endif %}
- \ No newline at end of file + + \ No newline at end of file From 0dc5ce59bf9e7776e2ad97575823306d876b9dbc Mon Sep 17 00:00:00 2001 From: Yanik Kumar Date: Tue, 15 Jul 2025 11:40:12 +0530 Subject: [PATCH 4/5] Dark-Light mode switch added --- app/Views/Components/navbar.twig | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/app/Views/Components/navbar.twig b/app/Views/Components/navbar.twig index 3ead3aa..2ba86e0 100644 --- a/app/Views/Components/navbar.twig +++ b/app/Views/Components/navbar.twig @@ -14,7 +14,37 @@
  • Docs
  • +
  • + +

  • + + From 3ee1c99b22aa781097430738d7eaf13fe1a9b2ce Mon Sep 17 00:00:00 2001 From: Yanik Kumar Date: Tue, 15 Jul 2025 11:46:09 +0530 Subject: [PATCH 5/5] Updated postInstall script with darkmode button --- core/Console/PostInstall.php | 99 +++++++++++++++++++++++++++++++----- 1 file changed, 87 insertions(+), 12 deletions(-) diff --git a/core/Console/PostInstall.php b/core/Console/PostInstall.php index a545046..c571320 100644 --- a/core/Console/PostInstall.php +++ b/core/Console/PostInstall.php @@ -59,11 +59,11 @@ public static function run() } $color = ''; - $needsColor = in_array($choice, ['5','6','7','8']); + $needsColor = in_array($choice, ['5', '6', '7', '8']); if ($needsColor) { echo "Enter color name (amber, blue, cyan, fuchsia, green, grey, indigo, jade, lime, orange, pink, pumpkin, purple, red, sand, slate, violet, yellow, zinc): "; $color = strtolower(trim(fgets(STDIN))); - $validColors = ['amber','blue','cyan','fuchsia','green','grey','indigo','jade','lime','orange','pink','pumpkin','purple','red','sand','slate','violet','yellow','zinc']; + $validColors = ['amber', 'blue', 'cyan', 'fuchsia', 'green', 'grey', 'indigo', 'jade', 'lime', 'orange', 'pink', 'pumpkin', 'purple', 'red', 'sand', 'slate', 'violet', 'yellow', 'zinc']; if (!in_array($color, $validColors)) { echo "Invalid color. Defaulting to blue.\n"; $color = 'blue'; @@ -78,21 +78,96 @@ public static function run() $file = ''; switch ($choice) { - case '1': $file = "pico$min.css"; break; - case '2': $file = "pico.classless$min.css"; break; - case '3': $file = "pico.conditional$min.css"; break; - case '4': $file = "pico.fluid.classless$min.css"; break; - case '5': $file = "pico.$color$min.css"; break; - case '6': $file = "pico.classless.$color$min.css"; break; - case '7': $file = "pico.conditional.$color$min.css"; break; - case '8': $file = "pico.fluid.classless.conditional.$color$min.css"; break; - case '9': $file = "pico.colors$min.css"; break; - default: $file = "pico$min.css"; break; + case '1': + $file = "pico$min.css"; + break; + case '2': + $file = "pico.classless$min.css"; + break; + case '3': + $file = "pico.conditional$min.css"; + break; + case '4': + $file = "pico.fluid.classless$min.css"; + break; + case '5': + $file = "pico.$color$min.css"; + break; + case '6': + $file = "pico.classless.$color$min.css"; + break; + case '7': + $file = "pico.conditional.$color$min.css"; + break; + case '8': + $file = "pico.fluid.classless.conditional.$color$min.css"; + break; + case '9': + $file = "pico.colors$min.css"; + break; + default: + $file = "pico$min.css"; + break; } $url = $base . $file; $dest = __DIR__ . '/../../public/assets/css/sprout.min.css'; self::download($url, $dest); + + // Prompt for dark/light mode toggle + echo "\nWould you like to include a dark/light mode toggle button in your navbar? (y/N): "; + $includeToggle = strtolower(trim(fgets(STDIN))); + if ($includeToggle === 'y') { + $navbarPath = __DIR__ . '/../../app/Views/components/navbar.twig'; + $navbar = file_get_contents($navbarPath); + // Only add if not already present + if (strpos($navbar, 'theme-toggle-btn') === false) { + $toggleBtn = << + + + + HTML; + // Insert before of the right-side nav (last in file) + $navbar = preg_replace('/(<\/ul>)(?![\s\S]*<\/ul>)/', "$toggleBtn\n$1", $navbar, 1); + // Add the script before at the end + $toggleScript = << + SCRIPT; + $navbar = preg_replace('/<\/div>\s*$/', "$toggleScript\n", $navbar, 1); + file_put_contents($navbarPath, $navbar); + echo "✅ Dark/light mode toggle added to your navbar.\n"; + } else { + echo "â„šī¸ Dark/light mode toggle already present in your navbar.\n"; + } + } else { + echo "â„šī¸ You can add a dark/light mode toggle later by yourself if you wish.\n"; + } } }