From 90b4c901dc3e3ec7d41ed9f306cd40d42d4986f4 Mon Sep 17 00:00:00 2001 From: Roene Date: Tue, 20 Aug 2024 11:36:44 +0200 Subject: [PATCH 01/25] Styling autocomplete --- config/rapidez/frontend.php | 9 ++-- resources/css/app.css | 1 + resources/css/components/autocomplete.css | 17 +++++++ resources/css/theme-variables.css | 1 + .../js/components/Search/Autocomplete.vue | 4 ++ .../views/layouts/partials/header.blade.php | 6 +-- .../partials/header/autocomplete.blade.php | 44 +++++++++++++------ .../header/autocomplete/all-results.blade.php | 10 +++++ .../header/autocomplete/background.blade.php | 3 ++ .../header/autocomplete/categories.blade.php | 13 +++--- .../header/autocomplete/products.blade.php | 20 ++++++--- .../partials/header/minicart.blade.php | 2 +- tailwind.config.js | 5 ++- 13 files changed, 100 insertions(+), 35 deletions(-) create mode 100644 resources/css/components/autocomplete.css create mode 100644 resources/views/layouts/partials/header/autocomplete/all-results.blade.php create mode 100644 resources/views/layouts/partials/header/autocomplete/background.blade.php diff --git a/config/rapidez/frontend.php b/config/rapidez/frontend.php index cd0584f6f..b99bd5a9e 100644 --- a/config/rapidez/frontend.php +++ b/config/rapidez/frontend.php @@ -33,11 +33,14 @@ // Attach additional indexes to the autocomplete // Uses the views in rapidez::layouts.partials.header.autocomplete 'additionals' => [ - 'categories' => ['name^3', 'description'], + 'categories' => [ + 'fields' => ['name^3', 'description'], + 'size' => 3, + ], ], - 'debounce' => 100, - 'size' => 10, + 'debounce' => 500, + 'size' => 3, ], // Link store codes to theme folders diff --git a/resources/css/app.css b/resources/css/app.css index 35ff9c3f7..6e3dba7d8 100644 --- a/resources/css/app.css +++ b/resources/css/app.css @@ -1,5 +1,6 @@ @import 'components/vue-slider'; @import './theme-variables.css'; +@import './components/autocomplete'; @tailwind base; @tailwind components; diff --git a/resources/css/components/autocomplete.css b/resources/css/components/autocomplete.css new file mode 100644 index 000000000..4ef7ca63c --- /dev/null +++ b/resources/css/components/autocomplete.css @@ -0,0 +1,17 @@ +.search-input + div div[groupposition='right'] { + @apply size-6 right-16 cursor-pointer z-50 !-translate-y-1/2 !top-1/2 !absolute; + + .cancel-icon { + @apply hidden; + } +} + +.search-input + div div[groupposition='right'] div[isclearicon='true']::before { + @apply size-6; + content: ''; + background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none'%3E%3Cpath d='M4.20986 4.38708L4.29286 4.29308C4.46505 4.1209 4.69415 4.01747 4.93718 4.00219C5.18021 3.98691 5.42046 4.06083 5.61286 4.21008L5.70686 4.29308L11.9999 10.5851L18.2929 4.29308C18.3851 4.19757 18.4955 4.12139 18.6175 4.06898C18.7395 4.01657 18.8707 3.98898 19.0035 3.98783C19.1362 3.98668 19.2679 4.01198 19.3908 4.06226C19.5137 4.11254 19.6254 4.18679 19.7193 4.28069C19.8131 4.37458 19.8874 4.48623 19.9377 4.60913C19.988 4.73202 20.0133 4.8637 20.0121 4.99648C20.011 5.12926 19.9834 5.26048 19.931 5.38249C19.8786 5.50449 19.8024 5.61483 19.7069 5.70708L13.4149 12.0001L19.7069 18.2931C19.879 18.4653 19.9825 18.6944 19.9978 18.9374C20.013 19.1804 19.9391 19.4207 19.7899 19.6131L19.7069 19.7071C19.5347 19.8793 19.3056 19.9827 19.0625 19.998C18.8195 20.0133 18.5793 19.9393 18.3869 19.7901L18.2929 19.7071L11.9999 13.4151L5.70686 19.7071C5.51826 19.8892 5.26566 19.99 5.00346 19.9878C4.74126 19.9855 4.49045 19.8803 4.30504 19.6949C4.11963 19.5095 4.01447 19.2587 4.01219 18.9965C4.00991 18.7343 4.1107 18.4817 4.29286 18.2931L10.5849 12.0001L4.29286 5.70708C4.12068 5.53489 4.01725 5.30579 4.00197 5.06276C3.98669 4.81974 4.06061 4.57949 4.20986 4.38708Z' fill='%232E4A56'/%3E%3C/svg%3E"); +} + +mark { + @apply bg-transparent text-inherit font-bold; +} \ No newline at end of file diff --git a/resources/css/theme-variables.css b/resources/css/theme-variables.css index 1a80dceac..15e65841d 100644 --- a/resources/css/theme-variables.css +++ b/resources/css/theme-variables.css @@ -5,6 +5,7 @@ --secondary-text: 255 255 255; --neutral: 51 65 85; --inactive: 100 116 139; + --inactive-100: 244 247 248; --highlight: 241 245 249; --border: 231 235 239; } diff --git a/resources/js/components/Search/Autocomplete.vue b/resources/js/components/Search/Autocomplete.vue index 988fad943..7df4e3bb6 100644 --- a/resources/js/components/Search/Autocomplete.vue +++ b/resources/js/components/Search/Autocomplete.vue @@ -31,6 +31,7 @@ export default { results: {}, resultsCount: 0, searchAdditionals: () => null, + overlay: false, } }, @@ -103,6 +104,9 @@ export default { let highlight = hit.highlight ?? source.highlight return highlight?.[field]?.[0] ?? source?.[field] ?? '' }, + showOverlay(isOpen) { + this.overlay = isOpen + }, }, } diff --git a/resources/views/layouts/partials/header.blade.php b/resources/views/layouts/partials/header.blade.php index 9e4caecd5..119716079 100644 --- a/resources/views/layouts/partials/header.blade.php +++ b/resources/views/layouts/partials/header.blade.php @@ -1,4 +1,4 @@ -
+
@@ -16,14 +16,14 @@
-
+
@include('rapidez::layouts.partials.header.autocomplete')
@include('rapidez::layouts.partials.header.account') @include('rapidez::layouts.partials.header.minicart')
-