Skip to content

Commit f660785

Browse files
committed
Merge branch 'main' of github.com:shurco/litecart
2 parents 99791a1 + eb52079 commit f660785

File tree

5 files changed

+51
-20
lines changed

5 files changed

+51
-20
lines changed

internal/queries/products.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ func (q *ProductQueries) Product(private bool, id string) (*models.Product, erro
141141
product.attribute,
142142
product.digital,
143143
product.seo,
144-
json_array(json_object('id', product_image.id, 'name', product_image.name, 'ext', product_image.ext)) as images,
144+
json_group_array(json_object('id', product_image.id, 'name', product_image.name, 'ext', product_image.ext)) as images,
145145
strftime('%s', product.created),
146146
strftime('%s', product.updated)
147147
FROM product

web/site/index.html

+3-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
<div class="relative bg-white mt-2">
1111
<div class="flex justify-between cursor-pointer">
1212
<span class="tracking-wider text-gray-900">{{ costFormat( item.amount ) }} {{ currency }}</span>
13-
<button @click="inCart(item.id) ? removeCart(item.id) : addCart(item.id)" :class="{'bg-green-600': !inCart(item.id),'bg-red-600': inCart(item.id)}"
14-
class="group relative inline-flex items-center overflow-hidden rounded px-6 py-3 text-white focus:outline-none focus:ring">
13+
14+
<button @click="inCart(item.id) ? removeCart(item.id) : addCart(item.id)" :class="{'bg-green-600': !inCart(item.id),'bg-red-600': inCart(item.id)}" class="group relative inline-flex items-center overflow-hidden rounded px-6 py-3 text-white focus:outline-none focus:ring">
1515
<span v-if="!inCart(item.id)" class="absolute -start-full transition-all group-hover:start-4">
1616
<svg class="h-4 w-4 text-white">
1717
<use xlink:href="/assets/img/sprite.svg#plus" />
@@ -33,6 +33,7 @@
3333
</svg>
3434
</span>
3535
</button>
36+
3637
</div>
3738
<a :href="`/products/${item.slug}`" class="block overflow-hidden group mb-5 mt-2">
3839
<h3 class="text-sm text-gray-700 group-hover:underline group-hover:underline-offset-4">{{item.name}}</h3>

web/site/product.html

+25-6
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,31 @@
22
<section>
33
<div class="max-w-screen-xl px-4 py-8 mx-auto sm:px-6 sm:py-12 lg:px-8">
44
<div class="grid grid-cols-1 gap-4 lg:grid-cols-3 lg:gap-8" v-if="load">
5-
<div class="relative h-[350px] sm:h-[450px]">
6-
<img :src="(product.images ? `/uploads/${product.images[0].name}_md.${product.images[0].ext}` : '/assets/img/noimage.png')" alt
7-
class="rounded-lg absolute inset-0 h-full w-full object-cover opacity-100 group-hover:opacity-0" />
8-
<img :src="(product.images ? `/uploads/${product.images[0].name}_md.${product.images[0].ext}` : '/assets/img/noimage.png')" alt
9-
class="rounded-lg absolute inset-0 h-full w-full object-cover opacity-0 group-hover:opacity-100" />
10-
</div>
5+
6+
<template v-if="!product.images">
7+
<div class="relative h-[350px] sm:h-[450px]">
8+
<img src="/assets/img/noimage.png" alt="" class="rounded-lg absolute inset-0 h-full w-full object-cover" />
9+
</div>
10+
</template>
11+
12+
<template v-else-if="product.images.length === 1">
13+
<div class="relative h-[350px] sm:h-[450px]">
14+
<img :src="`/uploads/${product.images[0].name}_md.${product.images[0].ext}`" alt="" class="rounded-lg absolute inset-0 h-full w-full object-cover" />
15+
</div>
16+
</template>
17+
18+
<template v-else>
19+
<div class="relative overflow-hidden h-[350px] sm:h-[450px] rounded-lg">
20+
<div class="flex w-full h-full transition-transform duration-500 ease-in-out" :style="{ transform: `translateX(-${currentSlide * 100}%)` }">
21+
<div class="flex-shrink-0 w-full h-full" v-for="(slide, index) in product.images" :key="index">
22+
<img :src="`/uploads/${slide.name}_md.${slide.ext}`" alt="" class="block w-full h-full object-cover" />
23+
</div>
24+
</div>
25+
<button @click="prevSlide(product.images.length)" class="absolute left-0 top-1/2 bg-white p-2 rounded-r-lg">&#8592;</button>
26+
<button @click="nextSlide(product.images.length)" class="absolute right-0 top-1/2 bg-white p-2 rounded-l-lg">&#8594;</button>
27+
</div>
28+
</template>
29+
1130
<div class="lg:col-span-2">
1231
<h1 class="text-xl font-bold text-gray-900 sm:text-3xl">{{product.name}}</h1>
1332
<div class="mt-4">

0 commit comments

Comments
 (0)