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/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
  • +
  • + +

  • + + 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..82b155a 100644 --- a/app/Views/partials/validation-form.twig +++ b/app/Views/partials/validation-form.twig @@ -1,7 +1,9 @@ +{% include "components/spinner.twig" %}
    @@ -11,15 +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 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 %} 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"; + } } }