-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from vuesence/products
Products
- Loading branch information
Showing
15 changed files
with
365 additions
and
30 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# Notes | ||
|
||
## Store examples | ||
|
||
https://moi-tvoi.ru/catalog/dekorativnye_igrushki/ | ||
https://www.livemaster.ru/catalogue |
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,30 @@ | ||
[ | ||
{ | ||
"id": 1, | ||
"title": "toy 1", | ||
"shortDesc": "Высота: 10см", | ||
"images": ["toy.jpg"], | ||
"price": 100 | ||
}, | ||
{ | ||
"id": 2, | ||
"title": "toy 2", | ||
"shortDesc": "Высота: 10см", | ||
"images": ["toy.jpg"], | ||
"price": 300 | ||
}, | ||
{ | ||
"id": 3, | ||
"title": "toy 1", | ||
"shortDesc": "Высота: 10см", | ||
"images": ["toy.jpg"], | ||
"price": 100 | ||
}, | ||
{ | ||
"id": 4, | ||
"title": "toy 1", | ||
"shortDesc": "Высота: 10см", | ||
"images": ["toy.jpg"], | ||
"price": 100 | ||
} | ||
] |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,26 @@ | ||
<script setup> | ||
defineProps({ | ||
num: { | ||
type: Number, | ||
default: 0, | ||
}, | ||
}); | ||
</script> | ||
|
||
<template> | ||
<span v-if="num > 0" class="badge">{{ num }}</span> | ||
</template> | ||
|
||
<style lang="scss" scoped> | ||
.badge { | ||
position: absolute; | ||
top: -5px; | ||
right: -5px; | ||
border-radius: 50%; | ||
background-color: red; | ||
font-size: 8px; | ||
color: white; | ||
line-height: 7px; | ||
padding: 3px 5px;; | ||
} | ||
</style> |
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,11 @@ | ||
import http from "./http"; | ||
|
||
const products = { | ||
|
||
async categoryProducts(categoryId) { | ||
return http.get(`/arty-crafty/api/category-products-${categoryId}.json`); | ||
}, | ||
|
||
}; | ||
|
||
export default products; |
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,124 @@ | ||
<script setup lang="ts"> | ||
import { useRouter } from "vue-router"; | ||
import BaseIcon from "@/app/components/ui/BaseIcon.vue"; | ||
import { useFavourites } from "@/products/composables/useFavourites"; | ||
const props = defineProps({ | ||
product: { | ||
type: Object, | ||
default: () => { }, | ||
}, | ||
}); | ||
const router = useRouter(); | ||
const { toggleFavourite, listFavourites, isInFavourites } = useFavourites(); | ||
function gotoProduct() { | ||
router.push({ name: "product", params: { productId: props.product.id } }); | ||
} | ||
function addToCart() { | ||
console.log("addToCart", props.product); | ||
toggleFavourite(props.product.id); | ||
} | ||
</script> | ||
|
||
<template> | ||
<div class="product-card"> | ||
{{ listFavourites() }} | ||
<div class="images"> | ||
<img :src="`/arty-crafty/api/${product.images[0]}`" :alt="product.title" @click="gotoProduct()"> | ||
<BaseIcon | ||
size="50" | ||
name="favourite" | ||
class="favourite-icon" | ||
:class="{ selected: isInFavourites(product.id) }" | ||
:fill="isInFavourites(product.id) ? 'currentColor' : 'none'" | ||
@click="toggleFavourite(props.product.id)" | ||
/> | ||
</div> | ||
<div class="description"> | ||
<h2 class="title"> | ||
{{ product.title }} | ||
</h2> | ||
<div class="desc"> | ||
{{ product.desc }} | ||
</div> | ||
<div class="price-wrapper" @click="addToCart()"> | ||
<div class="price"> | ||
{{ product.price }} <span class="currency-symbol">₽</span> | ||
</div> | ||
<!-- <button class="add-to-cart-button" type="button" title="Add to cart"> | ||
<BaseIcon size="20" name="add-to-cart" class="icon" fill1="white" /> | ||
</button> --> | ||
</div> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<style lang="scss" scoped> | ||
.product-card { | ||
border: 1px solid var(--vwa-c-divider); | ||
border-radius: 3px; | ||
cursor: pointer; | ||
width: 15rem; | ||
.mobile & { | ||
width: 100%; | ||
} | ||
.images { | ||
position: relative; | ||
img { | ||
max-width: 100%; | ||
border-top-right-radius: 3px; | ||
border-top-left-radius: 3px; | ||
} | ||
.favourite-icon { | ||
position: absolute; | ||
top: 0; | ||
right: 0; | ||
padding: 10px; | ||
margin: 1rem; | ||
transition: all 0.1s ease-in-out; | ||
color: red !important; | ||
// &.selected { | ||
// color: red !important; | ||
// } | ||
} | ||
} | ||
.description { | ||
padding: 0.4rem; | ||
.title { | ||
margin: 0.5rem 0; | ||
} | ||
.desc { | ||
margin: 0.5rem 0; | ||
} | ||
.price-wrapper { | ||
display: flex; | ||
justify-content: space-between; | ||
align-items: flex-end; | ||
.price { | ||
font-weight: 500; | ||
font-size: 1.2rem; | ||
.currency-symbol { | ||
color: #999; | ||
} | ||
} | ||
.add-to-cart-button { | ||
padding: 10px; | ||
cursor: pointer; | ||
border: 1px solid transparent; | ||
background-color: rgb(254, 114, 0); | ||
color: rgb(255, 255, 255); | ||
height: auto; | ||
border-radius: 50%; | ||
} | ||
} | ||
} | ||
} | ||
</style> |
Oops, something went wrong.