From 290a502b1eb2b085592d8132533fccacc3cbf546 Mon Sep 17 00:00:00 2001 From: Drew Date: Mon, 31 Mar 2025 14:42:38 -0600 Subject: [PATCH] initial search filter feature --- assets/scss/components/_search.scss | 48 ++++ assets/scss/main.scss | 1 + config.toml | 8 + layouts/_default/baseof.html | 1 + layouts/index.html | 1 + layouts/index.json | 14 ++ layouts/partials/search-interface.html | 54 +++++ static/js/search.js | 296 +++++++++++++++++++++++++ 8 files changed, 423 insertions(+) create mode 100644 assets/scss/components/_search.scss create mode 100644 layouts/index.json create mode 100644 layouts/partials/search-interface.html create mode 100644 static/js/search.js diff --git a/assets/scss/components/_search.scss b/assets/scss/components/_search.scss new file mode 100644 index 0000000..3676d0a --- /dev/null +++ b/assets/scss/components/_search.scss @@ -0,0 +1,48 @@ +.search-interface { + @apply sticky top-0 bg-white z-10 p-4; + + .search-form { + @apply space-y-4; + } + + .search-input-group { + @apply flex gap-2; + } + + .search-input { + @apply w-full p-2 border rounded-lg focus:ring-2 focus:ring-blue-500; + } + + .filter-toggle { + @apply px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700; + } + + .filter-panel { + @apply hidden transition-all duration-200 ease-in-out; + @apply bg-gray-50 rounded-lg p-4 mt-4; + + &.active { + @apply block; + } + } + + .filter-groups { + @apply grid gap-4 md:grid-cols-2 lg:grid-cols-3; + } + + .filter-group { + @apply space-y-2; + + h3 { + @apply font-semibold text-gray-700; + } + } + + .results-count { + @apply mt-4 text-sm text-gray-600; + } + + .results-list { + @apply mt-4 space-y-4; + } +} diff --git a/assets/scss/main.scss b/assets/scss/main.scss index 016a01d..b7aa9d7 100644 --- a/assets/scss/main.scss +++ b/assets/scss/main.scss @@ -11,6 +11,7 @@ // Components @import "components/wompum"; +@import "components/search"; body { font-family: $font-garamond; diff --git a/config.toml b/config.toml index 9d34023..7c97487 100644 --- a/config.toml +++ b/config.toml @@ -8,3 +8,11 @@ theme = "hugo-starter-tailwind-basic" [minify] minifyOutput = true + +[outputs] + home = ["HTML", "RSS", "JSON"] + +[outputFormats.JSON] + mediaType = "application/json" + baseName = "search" + isPlainText = true diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html index b841a4a..90e7454 100644 --- a/layouts/_default/baseof.html +++ b/layouts/_default/baseof.html @@ -27,5 +27,6 @@ + {{ block "scripts" . }}{{ end }} diff --git a/layouts/index.html b/layouts/index.html index 4d25239..44317f1 100644 --- a/layouts/index.html +++ b/layouts/index.html @@ -1,4 +1,5 @@ {{ define "main" }} +{{ partial "search-interface.html" . }}