-
Notifications
You must be signed in to change notification settings - Fork 4
/
shop.vue
120 lines (111 loc) · 2.98 KB
/
shop.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
<template>
<div class="shop">
<div class="shop-items">
<h4>Select item</h4>
<div class="shop-items-container">
<div
v-for="i in 12"
@click="addToTheList(i)"
:key="i"
class="shop-items-container-item"
>
{{ i }}
</div>
</div>
</div>
<div class="shop-card">
<h4>Shopping card</h4>
<div class="shop-card-items">
<div
v-for="(item, key) in list"
:key="key"
@click="removeFromList(item)"
class="shop-card-items-item"
>
<div class="shop-card-items-item-remove">x</div>
<p>item number {{ item }} added</p>
</div>
</div>
</div>
</div>
</template>
<script>
import { computed } from "vue";
import { useBucket } from "../../dist/v-bucket.esm-browser.prod";
export default {
setup() {
const bucket = useBucket();
const addToTheList = id => {
// run commit
bucket.commit("shop/add", id);
};
const removeFromList = id => {
bucket.commit("shop/remove", id);
};
const list = computed(() => {
return bucket.getters["shop/getList"];
});
return {
addToTheList,
removeFromList,
list
};
}
};
</script>
<style lang="scss" scoped>
.shop {
margin: 0 auto;
padding: 7px 15px;
width: 900px;
display: flex;
border: 1px solid #e9e9e9;
border-radius: 5px;
&-items {
margin-right: 15px;
flex: 1;
text-align: left;
&-container {
display: flex;
justify-content: flex-start;
align-items: center;
flex-wrap: wrap;
&-item {
cursor: pointer;
width: 100px;
height: 100px;
background: #dadada;
border-radius: 15px;
margin: 10px 5px;
display: flex;
justify-content: center;
align-items: center;
}
}
}
&-card {
background: rgb(74, 74, 255);
color: white;
border-radius: 5px;
width: 360px;
&-items {
padding: 0 20px;
&-item {
display: flex;
align-items: center;
& > div {
cursor: pointer;
width: 20px;
height: 20px;
background: rgb(255, 52, 52);
display: flex;
justify-content: center;
align-items: center;
border-radius: 4px;
margin-right: 10px;
}
}
}
}
}
</style>