@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,397 +0,0 @@
1
- <template>
2
- <div
3
- class="modal fade"
4
- id="martan-quickview"
5
- tabindex="-1"
6
- role="dialog"
7
- aria-labelledby="quickviewModal"
8
- aria-hidden="true"
9
- >
10
- <div class="modal-dialog modal-dialog-centered modal-xl" role="document">
11
- <div class="modal-content">
12
- <div class="modal-header" v-show="false">
13
- <h5 class="modal-title" id="quickviewModal">{{ i19quickview }}</h5>
14
- <button type="button" class="close" data-dismiss="modal" aria-label="Close">
15
- <span aria-hidden="true">&times;</span>
16
- </button>
17
- </div>
18
-
19
- <div class="modal-body mt-quickview">
20
- <button type="button" class="close" data-dismiss="modal" aria-label="Close">
21
- <span aria-hidden="true">&times;</span>
22
- </button>
23
-
24
- <div
25
- class="glide mt-quickview__galery"
26
- v-if="pictures.length || video"
27
- ref="galery"
28
- >
29
- <div
30
- class="mt-quickview__controls"
31
- data-glide-el="controls"
32
- :style="`--button--hover-color:${starColor || '#eeeeee'}`"
33
- >
34
- <button
35
- :title="i19previous"
36
- :aria-label="i19previous"
37
- class="left"
38
- data-glide-dir="<"
39
- v-on:click="back"
40
- v-if="glide && glide.index > 0"
41
- >
42
- <i class="i-chevron-left"></i>
43
- </button>
44
- </div>
45
-
46
- <div class="glide__track" data-glide-el="track">
47
- <ul class="glide__slides">
48
- <li v-for="picture in pictures" :key="picture.id" class="glide__slide">
49
- <img
50
- :alt="`Foto da avaliação do produto feita por ${author}`"
51
- :src="picture.big"
52
- />
53
- </li>
54
-
55
- <li v-if="video" class="lazy-image video-wrapper" :key="video">
56
- <VideoPlayer :video="video" />
57
- </li>
58
- </ul>
59
- </div>
60
-
61
- <div
62
- class="mt-quickview__controls"
63
- data-glide-el="controls"
64
- :style="`--button--hover-color:${starColor || '#eeeeee'}`"
65
- >
66
- <button
67
- :title="i19next"
68
- :aria-label="i19next"
69
- data-glide-dir=">"
70
- v-on:click="next"
71
- >
72
- <i class="i-chevron-right"></i>
73
- </button>
74
- </div>
75
- </div>
76
-
77
- <div class="mt-review">
78
- <div class="mt-rating__group">
79
- <AuthorAndRating
80
- :author="author"
81
- :isAnonymous="review.is_anonymous"
82
- :rating="rating"
83
- :starColor="starColor"
84
- v-if="review"
85
- />
86
-
87
- <isRecommended :recommended="recommended" v-if="review" />
88
-
89
- <VerifiedPurchase :showVerified="true" v-if="isVerified" />
90
- </div>
91
-
92
- <ThumbsPictures v-if="review" :review="review" @onClick="goToSlide" />
93
-
94
- <ReviewBody :body="body" :createdAt="review.created_at" v-if="review" />
95
-
96
- <ReviewReply :reply="reply" />
97
- </div>
98
- </div>
99
- </div>
100
- </div>
101
- </div>
102
- </template>
103
-
104
- <script>
105
- import Glide from "@glidejs/glide";
106
- import { i19next, i19previous } from "@ecomplus/i18n";
107
- import { i18n, formatDate } from "@ecomplus/utils";
108
- import { $ } from "@ecomplus/storefront-twbs";
109
- import { timeAgo } from "./../../utils/time-ago";
110
- import ThumbsPictures from "./ThumbsPictures.vue";
111
- import VerifiedPurchase from "./VerifiedPurchase.vue";
112
- import AuthorAndRating from "./AuthorAndRating.vue";
113
- import IsRecommended from "./isRecommended.vue";
114
- import ReviewBody from "./ReviewBody.vue";
115
- import ReviewReply from "./ReviewReply.vue";
116
- import VideoPlayer from "./VideoPlayer.vue";
117
- import Rating from "../snippets/Rating.vue";
118
-
119
- export default {
120
- name: "Quickview",
121
-
122
- components: {
123
- ThumbsPictures,
124
- Rating,
125
- VerifiedPurchase,
126
- AuthorAndRating,
127
- IsRecommended,
128
- ReviewBody,
129
- ReviewReply,
130
- VideoPlayer,
131
- },
132
-
133
- props: {
134
- review: Object,
135
- isOpen: {
136
- type: Boolean,
137
- default: false,
138
- },
139
- starColor: String,
140
- },
141
-
142
- data() {
143
- return {
144
- glide: null,
145
- };
146
- },
147
-
148
- computed: {
149
- i19quickview: () => "Quickview",
150
- i19next: () => i18n(i19next),
151
- i19previous: () => i18n(i19previous),
152
-
153
- reviewId: function () {
154
- if (this.review && this.review.id) {
155
- return this.review.id;
156
- }
157
-
158
- return null;
159
- },
160
-
161
- pictures: function () {
162
- if (this.review && this.review.pictures) {
163
- return this.review.pictures;
164
- }
165
- return [];
166
- },
167
-
168
- video: function () {
169
- if (this.review && this.review.video_url) {
170
- return this.review.video_url;
171
- }
172
- return null;
173
- },
174
-
175
- title: function () {
176
- if (this.review && this.review.title) {
177
- return this.review.title;
178
- }
179
- return null;
180
- },
181
-
182
- author: function () {
183
- if (this.review && this.review.display_name) {
184
- return this.review.display_name;
185
- }
186
- return null;
187
- },
188
-
189
- rating: function () {
190
- if (this.review && this.review.rating) {
191
- return this.review.rating;
192
- }
193
- return null;
194
- },
195
-
196
- recommended: function () {
197
- if (this.review && this.review.is_recommended) {
198
- return this.review.is_recommended;
199
- }
200
- return null;
201
- },
202
-
203
- isVerified: function () {
204
- if (this.review && this.review.verified_purchase) {
205
- return this.review.verified_purchase;
206
- }
207
- return null;
208
- },
209
-
210
- reply: function () {
211
- if (this.review && this.review.reply) {
212
- return this.review.reply;
213
- }
214
- return null;
215
- },
216
-
217
- created: function () {
218
- if (this.review && this.review.created_at) {
219
- return this.review.created_at;
220
- }
221
- return null;
222
- },
223
-
224
- body: function () {
225
- if (this.review && this.review.body) {
226
- return this.review.body;
227
- }
228
- return null;
229
- },
230
- },
231
-
232
- watch: {
233
- isOpen: function (isOpened) {
234
- if (isOpened) {
235
- $("#martan-quickview").modal("show");
236
- }
237
- },
238
- },
239
-
240
- mounted() {
241
- $("#martan-quickview").on("hidden.bs.modal", this.close);
242
- $("#martan-quickview").on("shown.bs.modal", this.mount);
243
-
244
- this.glide = new Glide(".mt-quickview__galery", {
245
- keyboard: false,
246
- rewind: true,
247
- type: "carousel",
248
- dragThreshold: false,
249
- startAt: 0,
250
- perView: 1,
251
- perViewLg: 1,
252
- perViewSm: 1,
253
- });
254
- },
255
-
256
- beforeDestroy() {
257
- if (this.glide) {
258
- this.glide.destroy();
259
- }
260
- },
261
-
262
- methods: {
263
- mount: function () {
264
- if (
265
- (this.review && this.review.pictures) ||
266
- (this.review && this.review.video_url)
267
- ) {
268
- setTimeout(() => {
269
- try {
270
- this.glide.mount();
271
- this.glide.update({ perView: 1 });
272
- } catch (error) {}
273
- }, 5);
274
- }
275
- },
276
-
277
- close: function () {
278
- this.$emit("onClose", true);
279
- try {
280
- this.glide.destroy();
281
- } catch (error) {}
282
- },
283
-
284
- next: function () {
285
- try {
286
- this.glide.go(">");
287
- this.glide.update({ perView: 1 });
288
- } catch (error) {}
289
- },
290
-
291
- back: function () {
292
- try {
293
- this.glide.go("<");
294
- this.glide.update({ perView: 1 });
295
- } catch (error) {}
296
- },
297
-
298
- goToSlide: function ({ slide }) {
299
- try {
300
- if (this.glide) this.glide.go(`=${slide}`).update({ perView: 1 });
301
- } catch (error) {}
302
- },
303
-
304
- formatDate,
305
- timeAgo,
306
- },
307
- };
308
- </script>
309
-
310
- <style lang="scss">
311
- .mt-quickview {
312
- padding: 0;
313
-
314
- @media (min-width: 992px) {
315
- display: flex;
316
- }
317
-
318
- @media (min-width: 1200px) {
319
- display: flex;
320
- }
321
-
322
- .close {
323
- position: absolute;
324
- z-index: 1;
325
- padding: 8px 1rem;
326
- }
327
-
328
- &__galery {
329
- max-width: 500px;
330
- min-height: 500px;
331
- width: 100%;
332
- display: flex;
333
- align-items: center;
334
-
335
- img {
336
- max-width: 500px;
337
- max-height: 500px;
338
- height: 100%;
339
- object-fit: contain;
340
- width: 100%;
341
- }
342
-
343
- .glide__slides {
344
- align-items: center;
345
- }
346
- }
347
-
348
- &__info {
349
- display: flex;
350
- align-items: center;
351
- gap: 10px;
352
- padding-bottom: 10px;
353
- }
354
-
355
- &__review {
356
- padding: 1rem;
357
-
358
- @media (min-width: 992px) {
359
- max-height: 500px;
360
- overflow: auto;
361
- }
362
-
363
- @media (min-width: 1200px) {
364
- max-height: 500px;
365
- overflow: auto;
366
- }
367
- }
368
-
369
- &__controls {
370
- padding: 5px;
371
-
372
- button {
373
- width: 30px;
374
- height: 30px;
375
- border: none;
376
- border-radius: 50%;
377
- transition: all ease-in-out 0.5s;
378
- display: flex;
379
- align-items: center;
380
- justify-content: center;
381
-
382
- &:hover {
383
- background-color: var(--button--hover-color);
384
- }
385
- }
386
- }
387
-
388
- .mt-review {
389
- padding: 10px 20px;
390
- }
391
-
392
- .video-wrapper {
393
- display: flex;
394
- align-items: center;
395
- }
396
- }
397
- </style>
@@ -1,39 +0,0 @@
1
- <template>
2
- <div class="body-wrapper">
3
- <div class="mt-review__body">{{ body }}</div>
4
- <span class="mt-review__date" :title="formatDate(createdAt)">
5
- {{ i19published }}
6
- {{ timeAgo(createdAt) }}
7
- </span>
8
- </div>
9
- </template>
10
-
11
- <script>
12
- import { formatDate } from "@ecomplus/utils";
13
- import { timeAgo } from "../../utils/time-ago";
14
-
15
- export default {
16
-
17
- name: "ReviewBody",
18
-
19
- props: {
20
- body: {
21
- type: String,
22
- required: true
23
- },
24
- createdAt: {
25
- type: String,
26
- required: true
27
- },
28
- },
29
-
30
- computed: {
31
- i19published: () => 'Publicado'
32
- },
33
-
34
- methods: {
35
- formatDate,
36
- timeAgo
37
- }
38
- };
39
- </script>
@@ -1,135 +0,0 @@
1
- <template>
2
- <div class="media">
3
- <ul v-if="pictures.length || video" class="media__list">
4
- <li
5
- v-if="pictures.length"
6
- class="mt-lazy-image"
7
- v-for="(picture, index) in pictures"
8
- :key="picture.thumb"
9
- @click="onClick(index)"
10
- >
11
- <img
12
- :alt="title"
13
- :data-src="picture.thumb"
14
- data-loaded="false"
15
- class="media__preview"
16
- />
17
- </li>
18
-
19
- <li
20
- v-if="video"
21
- class="lazy-image"
22
- @click="onClick(pictures.length)"
23
- :key="video"
24
- title="Abrir vídeo"
25
- >
26
- <svg
27
- xmlns="http://www.w3.org/2000/svg"
28
- width="30"
29
- height="30"
30
- viewBox="0 0 24 24"
31
- stroke-width="2"
32
- stroke="#ffffff"
33
- fill="none"
34
- stroke-linecap="round"
35
- stroke-linejoin="round"
36
- >
37
- <path stroke="none" d="M0 0h24v24H0z" fill="none"></path>
38
- <path d="M7 4v16l13 -8z"></path>
39
- </svg>
40
- </li>
41
- </ul>
42
- </div>
43
- </template>
44
-
45
- <script>
46
- export default {
47
- name: "ThumbsPictures",
48
-
49
- props: {
50
- review: {
51
- type: Object,
52
- required: true
53
- },
54
- },
55
-
56
- computed: {
57
- pictures: function () {
58
- return this.review.pictures || [];
59
- },
60
-
61
- video: function () {
62
- return this.review.video_url || null;
63
- },
64
-
65
- title: function () {
66
- return this.review.title || null;
67
- },
68
- },
69
-
70
- mounted() {
71
- const images = Array.from(document.querySelectorAll(".mt-lazy-image img"));
72
- const imageObserver = new IntersectionObserver((entries, observer) => {
73
- entries.forEach((entry) => {
74
- if (entry.isIntersecting && entry.target.dataset.loaded === "false") {
75
- const image = entry.target;
76
- image.dataset.loaded = true;
77
- image.src = image.dataset.src;
78
- imageObserver.unobserve(image);
79
- }
80
- });
81
- });
82
-
83
- images.forEach((img) => imageObserver.observe(img));
84
- },
85
-
86
- methods: {
87
- onClick(slide) {
88
- const { review } = this;
89
- this.$emit("onClick", { review, slide });
90
- },
91
- },
92
- };
93
- </script>
94
-
95
- <style lang="css">
96
- .media--open {
97
- width: 500px;
98
- }
99
-
100
- .media__preview {
101
- object-fit: cover;
102
- width: 100%;
103
- height: 100%;
104
- display: block;
105
- }
106
-
107
- .media__list {
108
- list-style: none;
109
- padding: 0;
110
- display: flex;
111
- padding-top: 0.75rem;
112
- }
113
-
114
- .media__list li {
115
- -webkit-tap-highlight-color: transparent;
116
- box-sizing: border-box;
117
- position: relative;
118
- user-select: none;
119
- overflow: hidden;
120
- border-radius: 5px;
121
- text-decoration: none;
122
- border: 0.125rem solid #383a3e;
123
- background-color: #383a3e;
124
- padding: 0;
125
- width: 2.375rem;
126
- min-width: 2.375rem;
127
- height: 2.375rem;
128
- margin-right: 0.25rem;
129
- transition: all ease 0.3s;
130
- display: flex;
131
- align-items: center;
132
- justify-content: center;
133
- cursor: pointer;
134
- }
135
- </style>
@@ -1,79 +0,0 @@
1
- <template>
2
- <div class="mt-rating__average__sort">
3
- <span class="mt-rating__count" v-if="!!reviews.orderRating">{{ Array.isArray(reviews.list) ? reviews.list.length : 0
4
- }}
5
- {{
6
- Array.isArray(reviews.list) && reviews.list.length > 1 || reviews.list.length === 0
7
- ? i19reviews
8
- : i19review
9
- }}
10
- <span>{{ reviews.orderRating }} {{
11
- Array.isArray(reviews.list) && reviews.list.length > 1 || reviews.list.length === 0
12
- ? i19stars
13
- : i19star
14
- }}</span>
15
- </span>
16
-
17
- <span class="mt-rating__count" v-else>
18
- {{ reviews.total }}
19
- {{
20
- reviews.total > 1 || reviews.total === 0
21
- ? i19reviews
22
- : i19review
23
- }}
24
- </span>
25
-
26
- <sort @onSort="onSort"/>
27
- </div>
28
- </template>
29
-
30
- <script>
31
- import Sort from './Sort.vue';
32
-
33
- export default {
34
- name: 'Total',
35
-
36
- props: {
37
- reviews: {
38
- type: Object,
39
- default: {
40
- list: [],
41
- orderRating: null,
42
- total: 0
43
- }
44
- }
45
- },
46
-
47
- computed: {
48
-
49
- i19stars: () => 'Estrelas',
50
- i19star: () => 'Estrela',
51
- i19reviews: () => 'Avaliações',
52
- i19review: () => 'Avaliação',
53
- orderRating () {
54
- return reviews.orderRating;
55
- },
56
- },
57
-
58
- components: { Sort },
59
-
60
- methods: {
61
- onSort(value) {
62
- this.$emit('onSort', value)
63
- }
64
- }
65
- };
66
- </script>
67
-
68
- <style lang="css">
69
- .mt-rating__average__sort {
70
- display: flex;
71
- justify-content: space-between;
72
- align-items: center;
73
- padding: 15px 00;
74
- }
75
-
76
- .mt-rating__count {
77
- color: #6b6d76;
78
- }
79
- </style>