@ecomplus/widget-martan 1.1.22 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (97) hide show
  1. package/.version +0 -0
  2. package/CHANGELOG.md +14 -0
  3. package/cms.config.js +78 -83
  4. package/dist/public/widget-martan.0.min.js +62 -0
  5. package/dist/public/widget-martan.0.min.js.map +1 -0
  6. package/dist/public/widget-martan.1.min.js.map +1 -1
  7. package/dist/public/widget-martan.2.min.js +1 -1
  8. package/dist/public/widget-martan.2.min.js.map +1 -1
  9. package/dist/public/widget-martan.3.min.js +1 -1
  10. package/dist/public/widget-martan.3.min.js.map +1 -1
  11. package/dist/public/widget-martan.4.min.js +1 -1
  12. package/dist/public/widget-martan.4.min.js.map +1 -1
  13. package/dist/public/widget-martan.5.min.js +1 -1
  14. package/dist/public/widget-martan.5.min.js.map +1 -1
  15. package/dist/public/widget-martan.6.min.js +2 -0
  16. package/dist/public/widget-martan.6.min.js.map +1 -0
  17. package/dist/public/widget-martan.7.min.js +2 -0
  18. package/dist/public/widget-martan.7.min.js.map +1 -0
  19. package/dist/public/widget-martan.8.min.js +2 -0
  20. package/dist/public/widget-martan.8.min.js.map +1 -0
  21. package/dist/public/widget-martan.9.min.js +2 -0
  22. package/dist/public/widget-martan.9.min.js.map +1 -0
  23. package/dist/public/widget-martan.var.min.js +3 -3
  24. package/dist/public/widget-martan.var.min.js.map +1 -1
  25. package/dist/widget-martan.0.min.js +62 -0
  26. package/dist/widget-martan.0.min.js.map +1 -0
  27. package/dist/widget-martan.1.min.js.map +1 -1
  28. package/dist/widget-martan.2.min.js +1 -1
  29. package/dist/widget-martan.2.min.js.map +1 -1
  30. package/dist/widget-martan.3.min.js +1 -1
  31. package/dist/widget-martan.3.min.js.map +1 -1
  32. package/dist/widget-martan.4.min.js +1 -1
  33. package/dist/widget-martan.4.min.js.map +1 -1
  34. package/dist/widget-martan.5.min.js +1 -1
  35. package/dist/widget-martan.5.min.js.map +1 -1
  36. package/dist/widget-martan.6.min.js +2 -0
  37. package/dist/widget-martan.6.min.js.map +1 -0
  38. package/dist/widget-martan.7.min.js +2 -0
  39. package/dist/widget-martan.7.min.js.map +1 -0
  40. package/dist/widget-martan.8.min.js +2 -0
  41. package/dist/widget-martan.8.min.js.map +1 -0
  42. package/dist/widget-martan.9.min.js +2 -0
  43. package/dist/widget-martan.9.min.js.map +1 -0
  44. package/dist/widget-martan.min.js +3 -3
  45. package/dist/widget-martan.min.js.map +1 -1
  46. package/package.json +2 -2
  47. package/src/append/product-block.ejs +5 -1
  48. package/src/append/product-card-slots.ejs +1 -1
  49. package/src/append/product-slots.ejs +1 -9
  50. package/src/index.js +17 -12
  51. package/src/utils/configProps.js +29 -0
  52. package/src/utils/lighten-color.js +20 -0
  53. package/src/utils/widget-initializer.js +60 -0
  54. package/src/widgets/questions/Questions.vue +436 -0
  55. package/src/widgets/questions/index.js +10 -0
  56. package/src/widgets/ratings/Rating.vue +223 -0
  57. package/src/widgets/ratings/index.js +232 -0
  58. package/src/widgets/reviews/Reviews.vue +317 -288
  59. package/src/widgets/reviews/components/Quickview.vue +390 -0
  60. package/src/widgets/reviews/components/Rating.vue +106 -0
  61. package/src/widgets/reviews/components/RatingBreakdown.vue +171 -0
  62. package/src/widgets/reviews/components/RatingHistogram.vue +306 -0
  63. package/src/widgets/reviews/components/RatingSummary.vue +226 -0
  64. package/src/widgets/reviews/components/RatingSummaryG.vue +104 -0
  65. package/src/widgets/reviews/components/ReviewCard.vue +223 -0
  66. package/src/widgets/reviews/{ReviewReply.vue → components/ReviewReply.vue} +42 -1
  67. package/src/widgets/reviews/{Score.vue → components/Score.vue} +3 -4
  68. package/src/widgets/reviews/{Sort.vue → components/Sort.vue} +1 -1
  69. package/src/widgets/reviews/components/SortDropdown.vue +184 -0
  70. package/src/widgets/reviews/components/VerifiedPurchase.vue +121 -0
  71. package/src/widgets/reviews/headers/Center.vue +248 -0
  72. package/src/widgets/reviews/headers/Compact.vue +225 -0
  73. package/src/widgets/reviews/headers/Histogram.vue +224 -0
  74. package/src/widgets/reviews/headers/Padrao.vue +113 -0
  75. package/src/widgets/reviews/headers/Summary.vue +217 -0
  76. package/src/widgets/reviews/index.js +2 -48
  77. package/src/append/body.ejs +0 -79
  78. package/src/append/head.ejs +0 -5
  79. package/src/append/stamps.ejs +0 -3
  80. package/src/widgets/reviews/AuthorAndRating.vue +0 -30
  81. package/src/widgets/reviews/AverageScore.vue +0 -160
  82. package/src/widgets/reviews/AverageTotal.vue +0 -35
  83. package/src/widgets/reviews/CardReview.vue +0 -87
  84. package/src/widgets/reviews/GridView.vue +0 -113
  85. package/src/widgets/reviews/HeaderExpanded.vue +0 -84
  86. package/src/widgets/reviews/HeaderMinimal.vue +0 -110
  87. package/src/widgets/reviews/ListView.vue +0 -47
  88. package/src/widgets/reviews/Quickview.vue +0 -397
  89. package/src/widgets/reviews/ReviewBody.vue +0 -39
  90. package/src/widgets/reviews/ThumbsPictures.vue +0 -135
  91. package/src/widgets/reviews/Total.vue +0 -79
  92. package/src/widgets/reviews/VerifiedPurchase.vue +0 -110
  93. package/src/widgets/reviews/isRecommended.vue +0 -44
  94. package/src/widgets/snippets/Rating.vue +0 -71
  95. package/src/widgets/snippets/Snippets.vue +0 -311
  96. package/src/widgets/snippets/index.js +0 -45
  97. /package/src/widgets/reviews/{VideoPlayer.vue → components/VideoPlayer.vue} +0 -0
@@ -1,110 +0,0 @@
1
- <template>
2
- <div>
3
- <div class="mt-rating__verified">
4
- <svg
5
- xmlns="http://www.w3.org/2000/svg"
6
- class="icon icon-tabler icon-tabler-discount-check-filled"
7
- width="24"
8
- height="24"
9
- viewBox="0 0 24 24"
10
- stroke-width="2"
11
- stroke="currentColor"
12
- fill="none"
13
- stroke-linecap="round"
14
- stroke-linejoin="round"
15
- >
16
- <path stroke="none" d="M0 0h24v24H0z" fill="none" />
17
- <path
18
- d="M12.01 2.011a3.2 3.2 0 0 1 2.113 .797l.154 .145l.698 .698a1.2 1.2 0 0 0 .71 .341l.135 .008h1a3.2 3.2 0 0 1 3.195 3.018l.005 .182v1c0 .27 .092 .533 .258 .743l.09 .1l.697 .698a3.2 3.2 0 0 1 .147 4.382l-.145 .154l-.698 .698a1.2 1.2 0 0 0 -.341 .71l-.008 .135v1a3.2 3.2 0 0 1 -3.018 3.195l-.182 .005h-1a1.2 1.2 0 0 0 -.743 .258l-.1 .09l-.698 .697a3.2 3.2 0 0 1 -4.382 .147l-.154 -.145l-.698 -.698a1.2 1.2 0 0 0 -.71 -.341l-.135 -.008h-1a3.2 3.2 0 0 1 -3.195 -3.018l-.005 -.182v-1a1.2 1.2 0 0 0 -.258 -.743l-.09 -.1l-.697 -.698a3.2 3.2 0 0 1 -.147 -4.382l.145 -.154l.698 -.698a1.2 1.2 0 0 0 .341 -.71l.008 -.135v-1l.005 -.182a3.2 3.2 0 0 1 3.013 -3.013l.182 -.005h1a1.2 1.2 0 0 0 .743 -.258l.1 -.09l.698 -.697a3.2 3.2 0 0 1 2.269 -.944zm3.697 7.282a1 1 0 0 0 -1.414 0l-3.293 3.292l-1.293 -1.292l-.094 -.083a1 1 0 0 0 -1.32 1.497l2 2l.094 .083a1 1 0 0 0 1.32 -.083l4 -4l.083 -.094a1 1 0 0 0 -.083 -1.32z"
19
- stroke-width="0"
20
- fill="currentColor"
21
- />
22
- </svg>
23
-
24
- <span> {{ i19verifiedBuyer }} </span>
25
- </div>
26
- <div class="collapse multi-collapse" :id="collapseId">
27
- <div class="card card-body">
28
- <h5> {{ i19howProcessVerifiedMsg }} </h5>
29
-
30
- <p>
31
- {{ i19useMartanPrivacyMsg }}
32
- </p>
33
-
34
- <p>
35
- {{ i19howWeCollectMsg }}
36
- </p>
37
-
38
- <p>
39
- {{ i19howClientsReviewMsg }}
40
- </p>
41
- </div>
42
- </div>
43
- </div>
44
- </template>
45
-
46
- <script>
47
- import { i18n } from "@ecomplus/utils";
48
- import { $ } from "@ecomplus/storefront-twbs";
49
-
50
- export default {
51
- name: "VerifiedPurchase",
52
-
53
- props: {
54
- showVerified: {
55
- type: Boolean,
56
- default: false,
57
- },
58
- },
59
-
60
- data () {
61
- return {
62
- collapseId: null,
63
- };
64
- },
65
-
66
- computed: {
67
- i19verifiedBuyer: () => 'Comprador verificado',
68
- i19howProcessVerifiedMsg: () => i18n({
69
- en_us: 'How we verify and process reviews',
70
- pt_br: 'Como verificamos e processamos avaliações'
71
- }),
72
- i19useMartanPrivacyMsg: () => i18n({
73
- en_us: 'We use Martan, a web-based application that provides an online reviews and marketing solution, to collect, source, process and display reviews on our website.',
74
- pt_br: 'Utilizamos o Martan, uma aplicação baseada na web que oferece uma solução de avaliações online e marketing, para coletar, originar, processar e exibir avaliações em nosso site.'
75
- }),
76
- i19howWeCollectMsg: () => i18n({
77
- en_us: 'We automatically send review requests through Martan to customers for whom we have a record of purchasing products directly from our website. This allows us to verify the reliability of the review through technical means such as the customers email address. Reviews submitted directly through these requests are marked as "Verified Purchase", and the following statement will be displayed in the interface where the review is published: "This review was collected from a verified customer who purchased this item."',
78
- pt_br: 'Enviamos automaticamente solicitações de avaliações por meio do Martan aos clientes para os quais temos registro de que compraram produtos diretamente em nosso site. Isso nos permite verificar a confiabilidade da avaliação por meio de meios técnicos, como o endereço de e-mail do cliente. As avaliações enviadas diretamente por essas solicitações são marcadas como "Compra verificada", e a seguinte declaração será exibida na interface em que a avaliação for publicada: "Esta avaliação foi coletada de um cliente verificado que comprou este item".'
79
- }),
80
- i19howClientsReviewMsg: () => i18n({
81
- en_us: 'Customers can choose how to rate reviewed products with a score between 1 and 5. The average review score is calculated using a simple mathematical average, which is then rounded to a half or full star rating using standard rounding rules. The average review score includes reviews for which customers received discounts on future purchases for adding a photo or video to their review.',
82
- pt_br: 'Os clientes podem escolher como avaliar os produtos avaliados com uma pontuação entre 1 e 5. A pontuação média das avaliações é calculada usando uma média matemática simples, que é então arredondada para uma meia ou uma avaliação de estrela completa usando regras padrão de arredondamento. A pontuação média das avaliações inclui avaliações para as quais os clientes receberam descontos em compras futuras por adicionar uma foto ou um vídeo à sua avaliação.'
83
- })
84
- },
85
-
86
- methods: {
87
- open: function () {
88
- $("#" + this.collapseId).collapse("toggle");
89
- },
90
- },
91
-
92
- mounted: function () {
93
- this.collapseId = "mt-verified-" + Date.now();
94
- },
95
- };
96
- </script>
97
-
98
- <style lang="scss">
99
-
100
- .mt-rating__verified {
101
- font-size: 12px;
102
- color: #6b6d76;
103
- font-weight: 400;
104
-
105
- svg {
106
- width: 15px;
107
- color: var(--success);
108
- }
109
- }
110
- </style>
@@ -1,44 +0,0 @@
1
- <template>
2
- <div
3
- class="mt-is__recomended"
4
- :title="
5
- recommended
6
- ? i19customerRecommendProduct
7
- : i19customerNoRecommendProduct
8
- "
9
- >
10
- <span> {{ i19recommendProductQn }} </span>
11
- <span>{{ recommended ? i19yes : i19no }}</span>
12
- </div>
13
- </template>
14
-
15
- <script>
16
-
17
- import {
18
- i19yes,
19
- i19no
20
- } from '@ecomplus/i18n'
21
-
22
- import { i18n } from '@ecomplus/utils'
23
-
24
- export default {
25
-
26
- name: "isRecommended",
27
-
28
- props: {
29
- recommended: {
30
- type: Boolean,
31
- default: true
32
- }
33
- },
34
-
35
- computed: {
36
- i19customerRecommendProduct: () => 'Cliente recomendaria o produto',
37
- i19customerNoRecommendProduct: () => 'Cliente não recomendaria o produto',
38
- i19no: () => i18n(i19no),
39
- i19recommendProductQn: () => 'Recomendaria o produto ?',
40
- i19yes: () => i18n(i19yes),
41
- },
42
-
43
- };
44
- </script>
@@ -1,71 +0,0 @@
1
- <template>
2
- <span class="martan-rating">
3
- <svg
4
- v-for="(star, index) in stars"
5
- :key="index"
6
- xmlns="http://www.w3.org/2000/svg"
7
- class="icon icon-tabler"
8
- :class="`${stars[index]} ? 'icon-tabler-star-filled' : icon-tabler-star`"
9
- width="14"
10
- height="14"
11
- viewBox="0 0 24 24"
12
- stroke-width="2"
13
- stroke="currentColor"
14
- fill="none"
15
- stroke-linecap="round"
16
- stroke-linejoin="round"
17
- :style="{ color }"
18
- >
19
- <path stroke="none" d="M0 0h24v24H0z" fill="none" />
20
- <path
21
- :d="stars[index] ? 'M8.243 7.34l-6.38 .925l-.113 .023a1 1 0 0 0 -.44 1.684l4.622 4.499l-1.09 6.355l-.013 .11a1 1 0 0 0 1.464 .944l5.706 -3l5.693 3l.1 .046a1 1 0 0 0 1.352 -1.1l-1.091 -6.355l4.624 -4.5l.078 -.085a1 1 0 0 0 -.633 -1.62l-6.38 -.926l-2.852 -5.78a1 1 0 0 0 -1.794 0l-2.853 5.78z' : 'M12 17.75l-6.172 3.245l1.179 -6.873l-5 -4.867l6.9 -1l3.086 -6.253l3.086 6.253l6.9 1l-5 4.867l1.179 6.873z'"
22
- :fill="stars[index] ? 'currentColor' : 'none'" />
23
- </svg>
24
- </span>
25
- </template>
26
-
27
- <script>
28
- export default {
29
- name: 'Rating',
30
-
31
- props: {
32
- rating: {
33
- type: Number,
34
- default: 5
35
- },
36
-
37
- color: {
38
- type: String,
39
- default: "#000000"
40
- },
41
- },
42
-
43
- data() {
44
- return {
45
- stars: Array(5).fill(false)
46
- };
47
- },
48
-
49
- mounted() {
50
- this.updateStars();
51
- },
52
-
53
- methods: {
54
- updateStars() {
55
- const filledStars = Math.floor(this.rating);
56
- this.stars = this.stars.map((star, index) => index < filledStars);
57
- }
58
- },
59
-
60
- watch: {
61
- rating: 'updateStars'
62
- }
63
- };
64
- </script>
65
-
66
- <style lang="css">
67
- .martan-rating {
68
- display: flex;
69
- gap: 4px;
70
- }
71
- </style>
@@ -1,311 +0,0 @@
1
- <template>
2
- <div
3
- id="mt-snippet"
4
- ref="wrapper"
5
- class="glide martan-snippets d-none"
6
- style="margin-bottom: 1rem; height: 85px"
7
- >
8
- <div class="glide__track" data-glide-el="track">
9
- <ul class="glide__slides">
10
- <li class="glide__slide" v-for="review in list" :key="review.id">
11
- <div class="martan-snippets__galery" v-if="getImageUrl(review)">
12
- <img
13
- :alt="`Foto da avaliação do produto feita por ${review.display_name}`"
14
- :src="getImageUrl(review)"
15
- />
16
- </div>
17
-
18
- <div class="martan-snippets__reviews snippet-review">
19
- <div class="martan-snippets__reviews-info snippet-review__info">
20
- <span>{{ review.display_name }}</span>
21
- <rating :rating="review.rating" :color="starColor" />
22
- </div>
23
-
24
- <div
25
- class="martan-snippets__reviews-body snippet-review__body"
26
- v-if="review.body"
27
- >
28
- <span>{{ review.body.substring(0, 115) }}...</span>
29
- </div>
30
- </div>
31
- </li>
32
- </ul>
33
- </div>
34
-
35
- <div class="martan-snippets__controls" data-glide-el="controls">
36
- <button
37
- v-if="glide && glide.index > 0"
38
- :title="i19previous"
39
- :aria-label="i19previous"
40
- class="left"
41
- data-glide-dir="<"
42
- v-on:click="glide.go('<')"
43
- >
44
- <i class="i-chevron-left"></i>
45
- </button>
46
-
47
- <button
48
- v-if="glide && glide.index !== list.length - 1"
49
- :title="i19next"
50
- :aria-label="i19next"
51
- class="right"
52
- data-glide-dir=">"
53
- v-on:click="glide.go('>')"
54
- :data-glide="glide.index"
55
- >
56
- <i class="i-chevron-right"></i>
57
- </button>
58
- </div>
59
- </div>
60
- </template>
61
-
62
- <script>
63
- import axios from "axios";
64
- import Glide, { Breakpoints } from "@glidejs/glide";
65
- import { i19next, i19previous } from "@ecomplus/i18n";
66
- import { i18n } from "@ecomplus/utils";
67
-
68
- import Rating from "./Rating.vue";
69
- import Quickview from "../reviews/Quickview.vue";
70
- import { MARTAN_API } from "../..";
71
-
72
- export default {
73
- name: "SnippetWidget",
74
-
75
- components: {
76
- Rating,
77
- Quickview,
78
- },
79
-
80
- data: function () {
81
- return {
82
- list: [],
83
- glide: null,
84
- isVisible: false,
85
- isOpenQuickView: false,
86
- selectedReview: null,
87
- };
88
- },
89
-
90
- computed: {
91
- i19next: () => i18n(i19next),
92
- i19previous: () => i18n(i19previous),
93
- },
94
-
95
- props: {
96
- storeId: {
97
- type: Number,
98
- required: true,
99
- },
100
- webId: {
101
- type: String,
102
- required: true,
103
- },
104
- product: {
105
- type: String,
106
- required: true,
107
- },
108
- starColor: {
109
- type: String,
110
- required: true,
111
- },
112
- backgroundColor: {
113
- type: String,
114
- default: "#f8f9fa",
115
- },
116
- textColor: {
117
- type: String,
118
- default: "#212529",
119
- },
120
- border: {
121
- type: Boolean,
122
- default: false,
123
- },
124
- borderColor: {
125
- type: String,
126
- default: "#212529",
127
- },
128
- },
129
-
130
- methods: {
131
- openQuickview: function ({ review, slide }) {
132
- this.selectedReview = review;
133
- this.isOpenQuickView = true;
134
- },
135
-
136
- onCloseQuickview: function () {
137
- this.isOpenQuickView = false;
138
- this.selectedReview = null;
139
- },
140
-
141
- fetch() {
142
- axios({
143
- url: MARTAN_API + "/reviews.json",
144
- headers: {
145
- "X-Store-Id": this.storeId,
146
- "X-Web-Id": this.webId,
147
- },
148
- params: {
149
- sku: this.product,
150
- limit: 10,
151
- offset: 0,
152
- },
153
- })
154
- .then(({ data }) => {
155
- if (data && data.result) {
156
- const filted = data.result.filter((r) => r.body);
157
- this.list = filted || [];
158
-
159
- this.glide = new Glide("#mt-snippet", {
160
- keyboard: false,
161
- rewind: false,
162
- type: "slider",
163
- startAt: 0,
164
- perView: 1,
165
- touchAngle: 0,
166
- breakpoints: {
167
- 1900: {
168
- perView: 1,
169
- },
170
- 1024: {
171
- perView: 1,
172
- },
173
- 600: {
174
- perView: 1,
175
- },
176
- },
177
- });
178
-
179
- return filted;
180
- }
181
-
182
- return []
183
- })
184
- .then((data) => {
185
- if (data.length >= 2) {
186
- this.$refs.wrapper.classList.remove("d-none");
187
- this.glide.mount();
188
- this.isVisible = true;
189
- }
190
-
191
- return this;
192
- })
193
- .then((t) => {
194
- if (t.isVisible) {
195
- this.glide.update({ perView: 1 });
196
- }
197
- });
198
- },
199
-
200
- getImageUrl(review) {
201
- if (
202
- review &&
203
- review.pictures &&
204
- review.pictures.length &&
205
- review.pictures[0].thumb
206
- ) {
207
- return review.pictures[0].thumb;
208
- }
209
- return null;
210
- },
211
-
212
- loadWidgetOptions() {
213
- this.$refs.wrapper.style.color = this.textColor;
214
- this.$refs.wrapper.style.backgroundColor = this.backgroundColor;
215
- if (this.border) {
216
- this.$refs.wrapper.style.border = `1px solid ${this.borderColor}`;
217
- }
218
- },
219
- },
220
-
221
- mounted: function () {
222
- if (this.storeId && this.webId && this.product) {
223
- this.fetch();
224
- this.loadWidgetOptions();
225
- }
226
- },
227
- };
228
- </script>
229
-
230
- <style scoped lang="scss">
231
- .martan-snippets {
232
- max-width: 525px;
233
- border-radius: 8px;
234
- display: flex;
235
- overflow: hidden;
236
- background-color: #e3e3e3;
237
- box-shadow: none;
238
-
239
- &__galery {
240
- img {
241
- border-radius: 6px;
242
- aspect-ratio: 1 / 1;
243
- width: 60px;
244
- object-fit: cover;
245
- }
246
- }
247
-
248
- &__reviews {
249
- height: 60px;
250
- max-width: fit-content;
251
- flex: 1 1 0%;
252
- display: flex;
253
- flex-direction: column;
254
- // overflow: hidden;
255
-
256
- &-info {
257
- font-weight: 500;
258
- display: flex;
259
- align-items: center;
260
- gap: 10px;
261
- }
262
- }
263
-
264
- &__controls {
265
- button {
266
- background: #fff;
267
- border-radius: 50%;
268
- border: none;
269
- color: var(--secondary);
270
- cursor: pointer;
271
- display: block;
272
- font-size: 10px;
273
- line-height: 1;
274
- opacity: 0.9;
275
- position: absolute;
276
- top: 50%;
277
- transform: translateY(-50%);
278
- transition: opacity 0.2s;
279
- z-index: 2;
280
- height: 20px;
281
- width: 20px;
282
- box-shadow: 0px -2px 12px rgba(0, 0, 0, 0.08);
283
- transition: all ease-in-out 0.3s;
284
- &:hover {
285
- opacity: 0.7;
286
- }
287
- &.left {
288
- left: -5px;
289
- }
290
-
291
- &.right {
292
- right: -5px;
293
- }
294
- }
295
- }
296
-
297
- .glide__slide {
298
- margin-left: 5px;
299
- margin-right: 5px;
300
- font-size: 14px;
301
- line-height: 1.5;
302
- font-weight: normal;
303
- scroll-snap-align: start;
304
- display: flex;
305
- align-items: center;
306
- justify-content: stretch;
307
- padding: 12px;
308
- gap: 12px;
309
- }
310
- }
311
- </style>
@@ -1,45 +0,0 @@
1
- import Vue from 'vue'
2
- import Snippets from './Snippets.vue'
3
-
4
- export default (options = {}, elId = 'snippet_widget') => {
5
- const $el = document.getElementById(elId)
6
-
7
- if (!options || !$el || !$el.dataset || !$el.dataset.sku) {
8
- return
9
- }
10
-
11
- const { sku } = $el.dataset
12
-
13
- const storeId = options.store_id
14
- const webId = options.web_id
15
- const widgetOptions = options.widget_snippet || {}
16
-
17
- const starColor = widgetOptions.star_color || null
18
- const border = widgetOptions.border || false
19
- const backgroundColor = widgetOptions.background_color || null
20
- const textColor = widgetOptions.text_color || null
21
- const borderColor = widgetOptions.border_color || null
22
-
23
- const obs = new IntersectionObserver((_, observe) => {
24
- new Vue({
25
- render(h) {
26
- return h(Snippets, {
27
- props: {
28
- product: sku,
29
- storeId,
30
- webId,
31
- starColor,
32
- border,
33
- borderColor,
34
- backgroundColor,
35
- textColor
36
- }
37
- })
38
- }
39
- }).$mount($el)
40
-
41
- observe.disconnect()
42
- })
43
-
44
- obs.observe($el)
45
- }