@kiva/kv-components 4.5.1 → 4.7.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.
- package/CHANGELOG.md +33 -0
- package/dist/components/KvLendCta.vue +151 -13
- package/dist/components/KvVerticalCarousel.vue +63 -17
- package/dist/components/stories/KvCarousel.stories.js +8 -23
- package/dist/components/stories/KvLendCta.stories.js +166 -0
- package/dist/components/stories/KvVerticalCarousel.stories.js +9 -23
- package/dist/utils/carousels.cjs +19 -11
- package/dist/utils/carousels.js +1 -1
- package/dist/utils/{chunk-P6FXCNYP.js → chunk-WLQNGWMC.js} +19 -11
- package/dist/utils/index.cjs +19 -11
- package/dist/utils/index.js +1 -1
- package/package.json +2 -2
- package/utils/carousels.js +31 -11
- package/vue/KvLendCta.vue +151 -13
- package/vue/KvVerticalCarousel.vue +63 -17
- package/vue/stories/KvCarousel.stories.js +8 -23
- package/vue/stories/KvLendCta.stories.js +166 -0
- package/vue/stories/KvVerticalCarousel.stories.js +9 -23
|
@@ -29,40 +29,69 @@
|
|
|
29
29
|
<!-- Carousel Controls -->
|
|
30
30
|
<div
|
|
31
31
|
class="kv-carousel__controls tw-flex
|
|
32
|
-
tw-
|
|
33
|
-
tw-mt-2 tw-w-full
|
|
32
|
+
tw-items-center tw-gap-2
|
|
33
|
+
tw-mt-2 tw-w-full
|
|
34
|
+
tw-justify-between md:tw-justify-center"
|
|
34
35
|
>
|
|
35
|
-
<
|
|
36
|
-
class="tw-
|
|
36
|
+
<div
|
|
37
|
+
class="tw-flex tw-gap-2 tw-w-full md:tw-w-auto"
|
|
38
|
+
:class="{'tw-justify-between md:tw-justify-center': !hasAutoplay}"
|
|
39
|
+
>
|
|
40
|
+
<button
|
|
41
|
+
class="tw-text-primary
|
|
37
42
|
tw-rounded-full
|
|
38
43
|
tw-border-2 tw-border-primary
|
|
39
44
|
tw-h-4 tw-w-4
|
|
40
45
|
tw-flex tw-items-center tw-justify-center
|
|
41
46
|
disabled:tw-opacity-low disabled:tw-cursor-default"
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
47
|
+
:disabled="embla && !embla.canScrollPrev()"
|
|
48
|
+
@click="handleUserInteraction(previousIndex, 'click-left-arrow')"
|
|
49
|
+
>
|
|
50
|
+
<kv-material-icon
|
|
51
|
+
class="tw-w-4"
|
|
52
|
+
:icon="mdiChevronUp"
|
|
53
|
+
/>
|
|
54
|
+
<span class="tw-sr-only">Show previous slide</span>
|
|
55
|
+
</button>
|
|
56
|
+
<button
|
|
57
|
+
class="tw-text-primary
|
|
58
|
+
tw-rounded-full
|
|
59
|
+
tw-border-2 tw-border-primary
|
|
60
|
+
tw-h-4 tw-w-4
|
|
61
|
+
tw-flex tw-items-center tw-justify-center
|
|
62
|
+
disabled:tw-opacity-low disabled:tw-cursor-default"
|
|
63
|
+
:disabled="embla && !embla.canScrollNext()"
|
|
64
|
+
@click="handleUserInteraction(nextIndex, 'click-right-arrow')"
|
|
65
|
+
>
|
|
66
|
+
<kv-material-icon
|
|
67
|
+
class="tw-w-4"
|
|
68
|
+
:icon="mdiChevronDown"
|
|
69
|
+
/>
|
|
70
|
+
<span class="tw-sr-only">Show next slide</span>
|
|
71
|
+
</button>
|
|
72
|
+
</div>
|
|
73
|
+
|
|
51
74
|
<button
|
|
75
|
+
v-if="hasAutoplay"
|
|
52
76
|
class="tw-text-primary
|
|
53
77
|
tw-rounded-full
|
|
54
78
|
tw-border-2 tw-border-primary
|
|
55
79
|
tw-h-4 tw-w-4
|
|
56
80
|
tw-flex tw-items-center tw-justify-center
|
|
57
81
|
disabled:tw-opacity-low disabled:tw-cursor-default"
|
|
58
|
-
|
|
59
|
-
@click="handleUserInteraction(nextIndex, 'click-right-arrow')"
|
|
82
|
+
@click.native.prevent="toggleAutoPlay()"
|
|
60
83
|
>
|
|
61
84
|
<kv-material-icon
|
|
85
|
+
v-if="isAutoplaying"
|
|
62
86
|
class="tw-w-4"
|
|
63
|
-
:icon="
|
|
87
|
+
:icon="mdiPause"
|
|
64
88
|
/>
|
|
65
|
-
<
|
|
89
|
+
<kv-material-icon
|
|
90
|
+
v-else
|
|
91
|
+
class="tw-w-4"
|
|
92
|
+
:icon="mdiPlay"
|
|
93
|
+
/>
|
|
94
|
+
<span class="tw-sr-only">Show previous slide</span>
|
|
66
95
|
</button>
|
|
67
96
|
</div>
|
|
68
97
|
</div>
|
|
@@ -70,9 +99,15 @@
|
|
|
70
99
|
|
|
71
100
|
<script>
|
|
72
101
|
import {
|
|
102
|
+
toRefs,
|
|
103
|
+
} from 'vue-demi';
|
|
104
|
+
import {
|
|
105
|
+
mdiPause,
|
|
106
|
+
mdiPlay,
|
|
73
107
|
mdiChevronUp,
|
|
74
108
|
mdiChevronDown,
|
|
75
109
|
} from '@mdi/js';
|
|
110
|
+
import { computed } from 'vue';
|
|
76
111
|
import { carouselUtil } from '../utils/carousels';
|
|
77
112
|
import KvMaterialIcon from './KvMaterialIcon.vue';
|
|
78
113
|
|
|
@@ -129,6 +164,10 @@ export default {
|
|
|
129
164
|
'interact-carousel',
|
|
130
165
|
],
|
|
131
166
|
setup(props, { emit, slots }) {
|
|
167
|
+
const {
|
|
168
|
+
autoplayOptions,
|
|
169
|
+
} = toRefs(props);
|
|
170
|
+
|
|
132
171
|
const {
|
|
133
172
|
componentSlotKeys,
|
|
134
173
|
currentIndex,
|
|
@@ -148,7 +187,12 @@ export default {
|
|
|
148
187
|
toggleAutoPlay,
|
|
149
188
|
} = carouselUtil(props, { emit, slots }, { axis: 'y' });
|
|
150
189
|
|
|
190
|
+
const hasAutoplay = computed(() => {
|
|
191
|
+
return Object.keys(autoplayOptions.value).length !== 0;
|
|
192
|
+
});
|
|
193
|
+
|
|
151
194
|
return {
|
|
195
|
+
hasAutoplay,
|
|
152
196
|
componentSlotKeys,
|
|
153
197
|
currentIndex,
|
|
154
198
|
embla,
|
|
@@ -156,6 +200,8 @@ export default {
|
|
|
156
200
|
handleUserInteraction,
|
|
157
201
|
isAriaHidden,
|
|
158
202
|
isAutoplaying,
|
|
203
|
+
mdiPause,
|
|
204
|
+
mdiPlay,
|
|
159
205
|
mdiChevronDown,
|
|
160
206
|
mdiChevronUp,
|
|
161
207
|
nextIndex,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { watch } from 'vue';
|
|
1
2
|
import KvCarousel from '../KvCarousel.vue';
|
|
2
3
|
import KvLoadingSpinner from '../KvLoadingSpinner.vue';
|
|
3
4
|
import KvButton from '../KvButton.vue';
|
|
@@ -444,14 +445,12 @@ export const AutoPlayButton = () => ({
|
|
|
444
445
|
components: {
|
|
445
446
|
KvCarousel,
|
|
446
447
|
},
|
|
447
|
-
data() {
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
};
|
|
451
|
-
},
|
|
448
|
+
data: () => ({
|
|
449
|
+
isAutoplaying: false,
|
|
450
|
+
}),
|
|
452
451
|
mounted() {
|
|
453
|
-
this.$
|
|
454
|
-
this.
|
|
452
|
+
watch(() => this.$refs?.sampleCarousel?.isAutoplaying, (newValue) => {
|
|
453
|
+
this.isAutoplaying = newValue;
|
|
455
454
|
});
|
|
456
455
|
},
|
|
457
456
|
template: `
|
|
@@ -461,34 +460,20 @@ export const AutoPlayButton = () => ({
|
|
|
461
460
|
style="max-width: 400px;"
|
|
462
461
|
:embla-options="{ loop: false }"
|
|
463
462
|
:autoplay-options="{ playOnInit: true, delay: 3000 }"
|
|
464
|
-
@interact-carousel="carouselInteraction"
|
|
465
463
|
>
|
|
466
464
|
${defaultCarouselSlides}
|
|
467
465
|
</kv-carousel>
|
|
468
|
-
<a href="#" @click.native.prevent="toggleAutoPlay()" role="toggleAutoPlayButton">Toggle AutoPlay</a>
|
|
466
|
+
<a href="#" @click.native.prevent="$refs.sampleCarousel.toggleAutoPlay()" role="toggleAutoPlayButton">Toggle AutoPlay</a>
|
|
469
467
|
<br/>
|
|
470
|
-
<p>AutoPlay is: {{
|
|
468
|
+
<p>AutoPlay is: {{ isAutoplaying ? 'ON' : 'OFF' }}</p>
|
|
471
469
|
</div>
|
|
472
470
|
`,
|
|
473
|
-
methods: {
|
|
474
|
-
toggleAutoPlay() {
|
|
475
|
-
this.$refs.sampleCarousel.toggleAutoPlay();
|
|
476
|
-
},
|
|
477
|
-
carouselInteraction() {
|
|
478
|
-
this.isPlaying = this.$refs.sampleCarousel.isAutoplaying();
|
|
479
|
-
},
|
|
480
|
-
},
|
|
481
471
|
});
|
|
482
472
|
|
|
483
473
|
export const Fade = () => ({
|
|
484
474
|
components: {
|
|
485
475
|
KvCarousel,
|
|
486
476
|
},
|
|
487
|
-
mounted() {
|
|
488
|
-
this.$nextTick(() => {
|
|
489
|
-
this.isPlaying = this.$refs.sampleCarousel.isAutoplaying();
|
|
490
|
-
});
|
|
491
|
-
},
|
|
492
477
|
template: `
|
|
493
478
|
<div>
|
|
494
479
|
<kv-carousel
|
|
@@ -164,3 +164,169 @@ export const ViewLoanFunded = story({
|
|
|
164
164
|
kvTrackFunction,
|
|
165
165
|
showViewLoan: true,
|
|
166
166
|
});
|
|
167
|
+
|
|
168
|
+
export const WithPresetOptions = story({
|
|
169
|
+
isLoading: false,
|
|
170
|
+
loan: {
|
|
171
|
+
id: 1,
|
|
172
|
+
name: 'John',
|
|
173
|
+
unreservedAmount: '150.00',
|
|
174
|
+
borrowerCount: 1,
|
|
175
|
+
},
|
|
176
|
+
kvTrackFunction,
|
|
177
|
+
showPresetAmounts: true,
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
export const WithPresetOptionsGroup = story({
|
|
181
|
+
isLoading: false,
|
|
182
|
+
loan: {
|
|
183
|
+
id: 1,
|
|
184
|
+
unreservedAmount: '150.00',
|
|
185
|
+
borrowerCount: 2,
|
|
186
|
+
},
|
|
187
|
+
kvTrackFunction,
|
|
188
|
+
showPresetAmounts: true,
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
export const WithPresetOptionsEqualThanLastAmount = story({
|
|
192
|
+
isLoading: false,
|
|
193
|
+
loan: {
|
|
194
|
+
id: 1,
|
|
195
|
+
unreservedAmount: '75.00',
|
|
196
|
+
borrowerCount: 2,
|
|
197
|
+
},
|
|
198
|
+
kvTrackFunction,
|
|
199
|
+
showPresetAmounts: true,
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
export const WithPresetOptionsLessThanLastAmount = story({
|
|
203
|
+
isLoading: false,
|
|
204
|
+
loan: {
|
|
205
|
+
id: 1,
|
|
206
|
+
unreservedAmount: '50.00',
|
|
207
|
+
borrowerCount: 2,
|
|
208
|
+
},
|
|
209
|
+
kvTrackFunction,
|
|
210
|
+
showPresetAmounts: true,
|
|
211
|
+
});
|
|
212
|
+
|
|
213
|
+
export const WithPresetOptionsLessThan25 = story({
|
|
214
|
+
isLoading: false,
|
|
215
|
+
loan: {
|
|
216
|
+
id: 1,
|
|
217
|
+
unreservedAmount: '10.00',
|
|
218
|
+
borrowerCount: 2,
|
|
219
|
+
},
|
|
220
|
+
kvTrackFunction,
|
|
221
|
+
showPresetAmounts: true,
|
|
222
|
+
});
|
|
223
|
+
|
|
224
|
+
export const WithPresetOptionsLessThan50 = story({
|
|
225
|
+
isLoading: false,
|
|
226
|
+
loan: {
|
|
227
|
+
id: 1,
|
|
228
|
+
unreservedAmount: '40.00',
|
|
229
|
+
borrowerCount: 2,
|
|
230
|
+
},
|
|
231
|
+
kvTrackFunction,
|
|
232
|
+
showPresetAmounts: true,
|
|
233
|
+
});
|
|
234
|
+
|
|
235
|
+
export const WithPresetOptionsLessThan100 = story({
|
|
236
|
+
isLoading: false,
|
|
237
|
+
loan: {
|
|
238
|
+
id: 1,
|
|
239
|
+
unreservedAmount: '80.00',
|
|
240
|
+
borrowerCount: 2,
|
|
241
|
+
},
|
|
242
|
+
kvTrackFunction,
|
|
243
|
+
showPresetAmounts: true,
|
|
244
|
+
});
|
|
245
|
+
|
|
246
|
+
export const WithPresetOptionsLessThan200 = story({
|
|
247
|
+
isLoading: false,
|
|
248
|
+
loan: {
|
|
249
|
+
id: 1,
|
|
250
|
+
unreservedAmount: '190.00',
|
|
251
|
+
borrowerCount: 2,
|
|
252
|
+
},
|
|
253
|
+
kvTrackFunction,
|
|
254
|
+
showPresetAmounts: true,
|
|
255
|
+
});
|
|
256
|
+
|
|
257
|
+
export const WithPresetOptionsHugeAmount = story({
|
|
258
|
+
isLoading: false,
|
|
259
|
+
loan: {
|
|
260
|
+
id: 1,
|
|
261
|
+
unreservedAmount: '12850.00',
|
|
262
|
+
},
|
|
263
|
+
kvTrackFunction,
|
|
264
|
+
enableHugeAmount: true,
|
|
265
|
+
isVisitor: false,
|
|
266
|
+
showPresetAmounts: true,
|
|
267
|
+
});
|
|
268
|
+
|
|
269
|
+
export const WithPresetOptionsLoading = story({
|
|
270
|
+
isLoading: true,
|
|
271
|
+
kvTrackFunction,
|
|
272
|
+
loan: {
|
|
273
|
+
id: 1,
|
|
274
|
+
unreservedAmount: '150.00',
|
|
275
|
+
borrowerCount: 2,
|
|
276
|
+
},
|
|
277
|
+
showPresetAmounts: true,
|
|
278
|
+
});
|
|
279
|
+
|
|
280
|
+
export const WithPresetOptionsAdding = story({
|
|
281
|
+
isLoading: false,
|
|
282
|
+
isAdding: true,
|
|
283
|
+
kvTrackFunction,
|
|
284
|
+
loan: {
|
|
285
|
+
id: 1,
|
|
286
|
+
unreservedAmount: '150.00',
|
|
287
|
+
borrowerCount: 2,
|
|
288
|
+
},
|
|
289
|
+
showPresetAmounts: true,
|
|
290
|
+
});
|
|
291
|
+
|
|
292
|
+
export const WithPresetOptionsBasketed = story({
|
|
293
|
+
isLoading: false,
|
|
294
|
+
loan: { id: 1 },
|
|
295
|
+
basketItems: [
|
|
296
|
+
{
|
|
297
|
+
__typename: 'LoanReservation',
|
|
298
|
+
id: 1,
|
|
299
|
+
},
|
|
300
|
+
],
|
|
301
|
+
showPresetAmounts: true,
|
|
302
|
+
kvTrackFunction,
|
|
303
|
+
});
|
|
304
|
+
|
|
305
|
+
export const WithPresetOptionsBasketedWithSecondaryAction = story({
|
|
306
|
+
isLoading: false,
|
|
307
|
+
loan: { id: 1 },
|
|
308
|
+
basketItems: [
|
|
309
|
+
{
|
|
310
|
+
__typename: 'LoanReservation',
|
|
311
|
+
id: 1,
|
|
312
|
+
},
|
|
313
|
+
],
|
|
314
|
+
externalLinks: true,
|
|
315
|
+
kvTrackFunction,
|
|
316
|
+
secondaryButtonHandler,
|
|
317
|
+
showPresetAmounts: true,
|
|
318
|
+
});
|
|
319
|
+
|
|
320
|
+
export const WithPresetOptionsFunded = story({
|
|
321
|
+
isLoading: false,
|
|
322
|
+
loan: { status: 'funded' },
|
|
323
|
+
kvTrackFunction,
|
|
324
|
+
showPresetAmounts: true,
|
|
325
|
+
});
|
|
326
|
+
|
|
327
|
+
export const WithPresetOptionsNonActionable = story({
|
|
328
|
+
isLoading: false,
|
|
329
|
+
loan: { status: 'refunded' },
|
|
330
|
+
kvTrackFunction,
|
|
331
|
+
showPresetAmounts: true,
|
|
332
|
+
});
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { watch } from 'vue';
|
|
1
2
|
import KvVerticalCarousel from '../KvVerticalCarousel.vue';
|
|
2
3
|
import KvButton from '../KvButton.vue';
|
|
3
4
|
|
|
@@ -186,14 +187,12 @@ export const AutoPlayButton = () => ({
|
|
|
186
187
|
components: {
|
|
187
188
|
KvVerticalCarousel,
|
|
188
189
|
},
|
|
189
|
-
data() {
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
};
|
|
193
|
-
},
|
|
190
|
+
data: () => ({
|
|
191
|
+
isAutoplaying: false,
|
|
192
|
+
}),
|
|
194
193
|
mounted() {
|
|
195
|
-
this.$
|
|
196
|
-
this.
|
|
194
|
+
watch(() => this.$refs?.sampleCarousel?.isAutoplaying, (newValue) => {
|
|
195
|
+
this.isAutoplaying = newValue;
|
|
197
196
|
});
|
|
198
197
|
},
|
|
199
198
|
template: `
|
|
@@ -203,34 +202,21 @@ export const AutoPlayButton = () => ({
|
|
|
203
202
|
style="max-width: 400px;"
|
|
204
203
|
:embla-options="{ loop: false }"
|
|
205
204
|
:autoplay-options="{ playOnInit: true, delay: 3000 }"
|
|
206
|
-
@interact-carousel="carouselInteraction"
|
|
207
205
|
>
|
|
208
206
|
${defaultCarouselSlides}
|
|
209
207
|
</kv-vertical-carousel>
|
|
210
|
-
<a href="#" @click.native.prevent="toggleAutoPlay()" role="toggleAutoPlayButton">Toggle AutoPlay</a>
|
|
208
|
+
<a href="#" @click.native.prevent="$refs.sampleCarousel.toggleAutoPlay()" role="toggleAutoPlayButton">Toggle AutoPlay</a>
|
|
211
209
|
<br/>
|
|
212
|
-
<p>AutoPlay is: {{
|
|
210
|
+
<p>AutoPlay is: {{ isAutoplaying ? 'ON' : 'OFF' }}</p>
|
|
213
211
|
</div>
|
|
214
212
|
`,
|
|
215
|
-
methods: {
|
|
216
|
-
toggleAutoPlay() {
|
|
217
|
-
this.$refs.sampleCarousel.toggleAutoPlay();
|
|
218
|
-
},
|
|
219
|
-
carouselInteraction() {
|
|
220
|
-
this.isPlaying = this.$refs.sampleCarousel.isAutoplaying();
|
|
221
|
-
},
|
|
222
|
-
},
|
|
223
213
|
});
|
|
224
214
|
|
|
215
|
+
/** Fade really only works when the carousel displays 1 slide at a time, this story is wonky as expected */
|
|
225
216
|
export const Fade = () => ({
|
|
226
217
|
components: {
|
|
227
218
|
KvVerticalCarousel,
|
|
228
219
|
},
|
|
229
|
-
mounted() {
|
|
230
|
-
this.$nextTick(() => {
|
|
231
|
-
this.isPlaying = this.$refs.sampleCarousel.isAutoplaying();
|
|
232
|
-
});
|
|
233
|
-
},
|
|
234
220
|
template: `
|
|
235
221
|
<div>
|
|
236
222
|
<kv-vertical-carousel
|