diff --git a/app/components/search/search-menu-desktop.vue b/app/components/search/search-menu-desktop.vue index b3c14b6..31469ca 100644 --- a/app/components/search/search-menu-desktop.vue +++ b/app/components/search/search-menu-desktop.vue @@ -43,24 +43,6 @@ const closeSearch = () => { emit('closeSearch'); }; -// Helpers -const { getColorOption } = useProductHelpers(); - -// Computed -const productsWithOptions = computed(() => - props.products.map((product) => { - const options = product.options; - const colorOption = getColorOption(options); - const colorOptionName = colorOption?.optionValues[0]?.name; - - return { - ...product, - colorOption, - colorOptionName - }; - }) -); - // Watchers watch( () => appStore.searchMenuOpen, @@ -105,58 +87,32 @@ watch(

Suggestions

-
- + -

- {{ product.title }} ({{ product.colorOptionName }}) -

- {{ product?.title }} -
+ :product="product" + />
{{ link.label }}
-
+

Products

- -
- -
-
-
-

{{ product.title }}

-

- {{ product.colorOptionName }} -

-
- -
-
+ :product="product" + />
diff --git a/app/components/search/search-menu-mobile.vue b/app/components/search/search-menu-mobile.vue index 25d8953..34a0652 100644 --- a/app/components/search/search-menu-mobile.vue +++ b/app/components/search/search-menu-mobile.vue @@ -36,24 +36,6 @@ const closeSearch = () => { emit('closeSearch'); }; -// Helpers -const { getColorOption } = useProductHelpers(); - -// Computed -const productsWithOptions = computed(() => - props.products.map((product) => { - const options = product.options; - const colorOption = getColorOption(options); - const colorOptionName = colorOption?.optionValues[0]?.name; - - return { - ...product, - colorOption, - colorOptionName - }; - }) -); - // Watchers watch( () => appStore.searchMenuOpen, @@ -96,32 +78,12 @@ watch(
-
- + -
- -
-
-
-

{{ product.title }}

-

- {{ product.colorOptionName }} -

-
- -
-
+ :product="product" + />
diff --git a/app/components/search/search-menu.vue b/app/components/search/search-menu.vue index 587ca76..d0bc358 100644 --- a/app/components/search/search-menu.vue +++ b/app/components/search/search-menu.vue @@ -17,7 +17,14 @@ const shopify = useShopify(); // Debounce query const handleSearch = async (query: string) => { - searchQuery.value = query.trim(); + const trimmedQuery = query.trim(); + + if (!trimmedQuery) { + searchResults.value = []; + return; + } + + searchQuery.value = trimmedQuery; const searchVars: PredictiveSearchQueryVariables = { query: searchQuery.value, diff --git a/app/components/search/suggestions/suggested-link.vue b/app/components/search/suggestions/suggested-link.vue new file mode 100644 index 0000000..85c321c --- /dev/null +++ b/app/components/search/suggestions/suggested-link.vue @@ -0,0 +1,28 @@ + + + diff --git a/app/components/search/suggestions/suggested-product-card.vue b/app/components/search/suggestions/suggested-product-card.vue new file mode 100644 index 0000000..15b5363 --- /dev/null +++ b/app/components/search/suggestions/suggested-product-card.vue @@ -0,0 +1,42 @@ + + +