Skip to content

Commit fb052aa

Browse files
committed
feat: update product page
1 parent 0c02b06 commit fb052aa

File tree

2 files changed

+48
-17
lines changed

2 files changed

+48
-17
lines changed

gql/queries/getProduct.gql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ query getProduct($slug: ID!, $sku: String!) {
1212
}
1313
productTypes {
1414
nodes {
15-
products(where: { sku: $sku }) {
15+
products(where: { stockStatus: IN_STOCK, sku: $sku }) {
1616
nodes {
1717
slug
1818
image {

pages/product/[slug].vue

Lines changed: 47 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,19 @@
99
</div>
1010
</div>
1111
<div>
12-
<div class="flex-col flex gap-3">
13-
<div>
14-
<h1 class="text-2xl">{{ product.name }}</h1>
15-
</div>
16-
<div>
12+
<div class="flex-col flex gap-4">
13+
<div class="pb-4 border-b border-white/20">
14+
<h1 class="text-2xl font-semibold mb-1">{{ product.name }}</h1>
1715
<div class="flex justify-between flex-row items-baseline">
1816
<div class="flex flex-row items-baseline">
19-
<p class="text-xl font-bold" v-html="product.salePrice"></p>
17+
<p class="text-xl font-bold text-[#ff0000]" v-html="product.salePrice"></p>
2018
<p class="text-sm ml-2">VAT included</p>
2119
</div>
2220
</div>
2321
<div class="flex-wrap items-baseline flex-row flex">
2422
<p class="text-sm">Originally:</p>
2523
<p class="text-sm ml-1 line-through" v-html="product.regularPrice"></p>
26-
<p class="text-sm ml-1">{{ calculateDiscountPercentage }}%</p>
24+
<p class="text-sm ml-1 text-[#ff0000]">{{ calculateDiscountPercentage }}%</p>
2725
</div>
2826
</div>
2927
<div class="flex gap-2" v-for="(variation, i) in product.productTypes.nodes" :key="variation.id">
@@ -35,16 +33,16 @@
3533
</NuxtLink>
3634
</div>
3735
</div>
38-
<div>
39-
<div>Size: {{ selectedVariation }}</div>
40-
<div class="flex gap-2 mt-3 flex-wrap">
36+
<div class="pb-4 border-b border-white/20">
37+
<div class="text-sm font-semibold leading-5">Size: {{ selectedVariation }}</div>
38+
<div class="flex gap-2 mt-3 mb-4 flex-wrap">
4139
<label
42-
class="py-1 px-3 border rounded-md"
40+
class="py-1 px-3 border rounded-md cursor-pointer select"
4341
v-for="variation in product.variations.nodes"
4442
:key="variation.id"
4543
:class="[
4644
variation.stockStatus === 'OUT_OF_STOCK' ? 'disabled' : '',
47-
selectedVariation === variation.attributes.nodes.map((attr) => attr.value).toString() ? 'bg-red-500' : '',
45+
selectedVariation === variation.attributes.nodes.map((attr) => attr.value).toString() ? 'selected' : '',
4846
]">
4947
<input
5048
type="radio"
@@ -53,11 +51,32 @@
5351
:value="variation.attributes.nodes.map((attr) => attr.value).toString()"
5452
:disabled="variation.stockStatus === 'OUT_OF_STOCK'"
5553
v-model="selectedVariation" />
56-
<span>{{ variation.attributes.nodes.map((attr) => attr.value).toString() }}</span>
54+
<span :title="`Size: ${variation.attributes.nodes.map((attr) => attr.value).toString()}`">{{
55+
variation.attributes.nodes.map((attr) => attr.value).toString()
56+
}}</span>
5757
</label>
5858
</div>
59+
<div class="flex">
60+
<button type="submit" class="w-full h-12 border rounded-md tracking-wide font-semibold border-[#990000] bg-[#ff0000] transition duration-200 hover:bg-[#c90000]">
61+
Add to Cart
62+
</button>
63+
<div class="cursor-pointer">
64+
<div class="w-12 h-12 rounded-md border ml-4 flex justify-center items-center">
65+
<Icon name="ion:heart-outline" size="26" />
66+
</div>
67+
</div>
68+
</div>
69+
</div>
70+
<div>
71+
<div class="text-base mb-2 font-semibold">Featured Information</div>
72+
<div class="description leading-7 overflow-hidden max-h-84 text-sm">
73+
<ul>
74+
<li>Free returns within 15 days. Click for detailed <a class="underline" href="#">information</a>.</li>
75+
<li>Article number: {{ product.sku }}</li>
76+
<div v-html="product.description"></div>
77+
</ul>
78+
</div>
5979
</div>
60-
<div v-html="product.description"></div>
6180
</div>
6281
</div>
6382
</div>
@@ -122,8 +141,20 @@ const calculateDiscountPercentage = computed(() => {
122141
// const product = data?.value?.product;
123142
</script>
124143
125-
<style>
144+
<style lang="postcss">
126145
.disabled {
127-
opacity: 0.4;
146+
@apply opacity-40 cursor-default;
147+
}
148+
.selected,
149+
.select:hover:not(.disabled) {
150+
background-color: rgb(242 26 26 / 15%);
151+
border: solid 2px #ff0000;
152+
padding: 0.188rem 0.688rem;
153+
color: #ff0000;
154+
}
155+
.description ul li {
156+
background: url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjxlbGxpcHNlIHJ5PSIzIiByeD0iMyIgY3k9IjMiIGN4PSIzIiBmaWxsPSIjYzljOWM5Ii8+PC9zdmc+)
157+
no-repeat 0 0.7rem;
158+
padding-left: 0.938rem;
128159
}
129160
</style>

0 commit comments

Comments
 (0)