-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: improve predictive search logic and component separation
- Loading branch information
1 parent
7ecf1c2
commit acbf3c4
Showing
5 changed files
with
94 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<script setup lang="ts"> | ||
import type { ProductFragment } from '@@/types/shopify'; | ||
// Props | ||
const props = defineProps<{ | ||
product: ProductFragment; | ||
}>(); | ||
// Helpers | ||
const { getColorOption } = useProductHelpers(); | ||
// Computed | ||
const options = computed(() => props.product?.options); | ||
const colorOption = computed(() => getColorOption(options.value)); | ||
const colorOptionName = computed(() => colorOption.value?.optionValues[0]?.name); | ||
</script> | ||
|
||
<template> | ||
<NuxtLink | ||
:to="`/products/${product.handle}`" | ||
class="max-w-fit hover:text-gray-500" | ||
> | ||
<p v-if="colorOptionName" class="normal-case truncate ..."> | ||
{{ product.title }} ({{ colorOptionName }}) | ||
</p> | ||
<p v-else class="normal-case truncate ...">{{ product.title }}</p> | ||
</NuxtLink> | ||
</template> |
42 changes: 42 additions & 0 deletions
42
app/components/search/suggestions/suggested-product-card.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<script setup lang="ts"> | ||
import type { ProductFragment } from '@@/types/shopify'; | ||
// Props | ||
const props = defineProps<{ | ||
product: ProductFragment; | ||
}>(); | ||
// Helpers | ||
const { getColorOption } = useProductHelpers(); | ||
// Computed | ||
const options = computed(() => props.product?.options); | ||
const colorOption = computed(() => getColorOption(options.value)); | ||
const colorOptionName = computed(() => colorOption.value?.optionValues[0]?.name); | ||
</script> | ||
|
||
<template> | ||
<NuxtLink | ||
:to="`/products/${product.handle}`" | ||
class="flex gap-4" | ||
> | ||
<div class="w-24 aspect-square shrink-0"> | ||
<ShopifyImage | ||
:image="product.featuredImage" | ||
:alt="product.featuredImage?.altText || product.title" | ||
/> | ||
</div> | ||
<div class="flex flex-col"> | ||
<div class="mb-2"> | ||
<h2 v-if="product.title">{{ product.title }}</h2> | ||
<h3 v-if="colorOption" class="normal-case"> | ||
{{ colorOptionName }} | ||
</h3> | ||
</div> | ||
<PriceDisplay | ||
:price="product.priceRange.minVariantPrice" | ||
:compare-at-price-range="product.compareAtPriceRange.minVariantPrice" | ||
/> | ||
</div> | ||
</NuxtLink> | ||
</template> |