Skip to content

Instantly share code, notes, and snippets.

@czue
Created June 21, 2024 09:22
Show Gist options
  • Save czue/73cec7ff562aff0943e55538fe9b4550 to your computer and use it in GitHub Desktop.
Save czue/73cec7ff562aff0943e55538fe9b4550 to your computer and use it in GitHub Desktop.
Patch to add flowbite + datepicker to a SaaS pegasus Project
diff --git a/assets/javascript/site.js b/assets/javascript/site.js
index a34accb4..32ded7dc 100644
--- a/assets/javascript/site.js
+++ b/assets/javascript/site.js
@@ -3,3 +3,5 @@
import 'htmx.org';
import './htmx';
import './alpine';
+import 'flowbite';
+import 'flowbite/dist/datepicker';
diff --git a/package.json b/package.json
index 11648e3b..d20b154a 100644
--- a/package.json
+++ b/package.json
@@ -47,6 +47,7 @@
"bulma": "^1.0.1",
"chart.js": "^4.4.3",
"daisyui": "^4.11.1",
+ "flowbite": "^2.3.0",
"htmx.org": "^1.9.12",
"js-cookie": "^3.0.5",
"react": "^18.3.1",
diff --git a/tailwind.config.js b/tailwind.config.js
index ea67035c..198be211 100644
--- a/tailwind.config.js
+++ b/tailwind.config.js
@@ -11,6 +11,7 @@ module.exports = {
'./templates_bootstrap/**/*.html',
'./templates_bulma/**/*.html',
'./apps/web/templatetags/form_tags.py',
+ './node_modules/flowbite/**/*.js',
],
safelist: [
'alert-success',
@@ -37,5 +38,6 @@ module.exports = {
plugins: [
require('@tailwindcss/typography'),
require("daisyui"),
+ require('flowbite/plugin'),
],
}
diff --git a/templates/pegasus/examples/example_form.html b/templates/pegasus/examples/example_form.html
index cae30b6b..4ae27b1e 100644
--- a/templates/pegasus/examples/example_form.html
+++ b/templates/pegasus/examples/example_form.html
@@ -5,6 +5,16 @@
<section class="app-card">
<h2 class="pg-subtitle">Example Form</h2>
<form method="post">
+
+<div class="relative max-w-sm">
+ <div class="absolute inset-y-0 start-0 flex items-center ps-3 pointer-events-none">
+ <svg class="w-4 h-4 text-gray-500 dark:text-gray-400" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 20 20">
+ <path d="M20 4a2 2 0 0 0-2-2h-2V1a1 1 0 0 0-2 0v1h-3V1a1 1 0 0 0-2 0v1H6V1a1 1 0 0 0-2 0v1H2a2 2 0 0 0-2 2v2h20V4ZM0 18a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V8H0v10Zm5-8h10a1 1 0 0 1 0 2H5a1 1 0 0 1 0-2Z"/>
+ </svg>
+ </div>
+ <input datepicker datepicker-format="mm/dd/yyyy" type="text" class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full ps-10 p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500" placeholder="Select date">
+</div>
+
{% csrf_token %}
{% render_form_fields form %}
<input type="submit" value="Save Data" class="pg-button-secondary">
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment