@kiva/kv-components 3.78.2 → 3.80.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 +35 -0
- package/package.json +2 -2
- package/vue/KvClassicLoanCard.vue +38 -0
- package/vue/KvLendCta.vue +30 -6
- package/vue/stories/KvClassicLoanCard.stories.js +49 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,41 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [3.80.0](https://github.com/kiva/kv-ui-elements/compare/@kiva/kv-components@3.79.0...@kiva/kv-components@3.80.0) (2024-05-22)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* add showContributors condition ([2fe0be3](https://github.com/kiva/kv-ui-elements/commit/2fe0be34ea8cb18fdce37a0eba979d089a850426))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
### Features
|
|
15
|
+
|
|
16
|
+
* show contributors section of loan card ([e65e80f](https://github.com/kiva/kv-ui-elements/commit/e65e80f1862c93e45b9f3a05a3a01d3585b4fc7c))
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
# [3.79.0](https://github.com/kiva/kv-ui-elements/compare/@kiva/kv-components@3.78.2...@kiva/kv-components@3.79.0) (2024-05-21)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
### Bug Fixes
|
|
26
|
+
|
|
27
|
+
* change cta2ButtonText to loanInBasketButtonText ([f052b7b](https://github.com/kiva/kv-ui-elements/commit/f052b7bdee874b5e2447b437cd90c7751ced4bce))
|
|
28
|
+
* remove button story edits ([9dfbf98](https://github.com/kiva/kv-ui-elements/commit/9dfbf981adc2f90384650044f35e6179dbbd851f))
|
|
29
|
+
* remove showSecondaryButton in favor of condition to make code more readable ([8223460](https://github.com/kiva/kv-ui-elements/commit/8223460d56480267b2d4f16e99c7becc1e72b40e))
|
|
30
|
+
* set consistent default values for buttons ([041fef2](https://github.com/kiva/kv-ui-elements/commit/041fef2cc21b11b4b4d11f342c8fb7a7dcee222f))
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
### Features
|
|
34
|
+
|
|
35
|
+
* loan card primary and secondary button customization options ([77ecb2e](https://github.com/kiva/kv-ui-elements/commit/77ecb2e90c1df81201029ba8906f217cf9f9d6b2))
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
6
41
|
## [3.78.2](https://github.com/kiva/kv-ui-elements/compare/@kiva/kv-components@3.78.1...@kiva/kv-components@3.78.2) (2024-05-20)
|
|
7
42
|
|
|
8
43
|
**Note:** Version bump only for package @kiva/kv-components
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kiva/kv-components",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.80.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -75,5 +75,5 @@
|
|
|
75
75
|
"optional": true
|
|
76
76
|
}
|
|
77
77
|
},
|
|
78
|
-
"gitHead": "
|
|
78
|
+
"gitHead": "3dbb81161c861155a392916f6bf297caea902e86"
|
|
79
79
|
}
|
|
@@ -223,12 +223,26 @@
|
|
|
223
223
|
:set-cookie="setCookie"
|
|
224
224
|
:enable-huge-amount="enableHugeAmount"
|
|
225
225
|
:is-visitor="isVisitor"
|
|
226
|
+
:primary-button-text="primaryButtonText"
|
|
227
|
+
:secondary-button-text="secondaryButtonText"
|
|
228
|
+
:secondary-button-handler="secondaryButtonHandler"
|
|
226
229
|
class="tw-mt-auto"
|
|
227
230
|
:class="{ 'tw-w-full' : unreservedAmount <= 0 }"
|
|
228
231
|
@add-to-basket="$emit('add-to-basket', $event)"
|
|
229
232
|
@show-loan-details="clickReadMore('ViewLoan')"
|
|
233
|
+
@remove-from-basket="$emit('remove-from-basket', $event)"
|
|
230
234
|
/>
|
|
231
235
|
</div>
|
|
236
|
+
|
|
237
|
+
<div
|
|
238
|
+
v-if="showContributors && lendersNumber && amountLent"
|
|
239
|
+
class="tw-text-center tw-w-full tw-mt-1 tw-font-medium "
|
|
240
|
+
>
|
|
241
|
+
<p>
|
|
242
|
+
{{ lendersNumber }} people contributed {{ amountLent }}
|
|
243
|
+
</p>
|
|
244
|
+
</div>
|
|
245
|
+
|
|
232
246
|
<div
|
|
233
247
|
v-if="combinedActivities.length > 0"
|
|
234
248
|
class="tw-pt-1.5"
|
|
@@ -259,6 +273,7 @@
|
|
|
259
273
|
</template>
|
|
260
274
|
|
|
261
275
|
<script>
|
|
276
|
+
import numeral from 'numeral';
|
|
262
277
|
import { loanCardComputedProperties, loanCardMethods } from '../utils/loanCard';
|
|
263
278
|
|
|
264
279
|
import KvLoanUse from './KvLoanUse.vue';
|
|
@@ -397,6 +412,22 @@ export default {
|
|
|
397
412
|
type: Boolean,
|
|
398
413
|
default: false,
|
|
399
414
|
},
|
|
415
|
+
primaryButtonText: {
|
|
416
|
+
type: String,
|
|
417
|
+
default: 'Lend',
|
|
418
|
+
},
|
|
419
|
+
secondaryButtonHandler: {
|
|
420
|
+
type: Function,
|
|
421
|
+
default: undefined,
|
|
422
|
+
},
|
|
423
|
+
secondaryButtonText: {
|
|
424
|
+
type: String,
|
|
425
|
+
default: 'Checkout now',
|
|
426
|
+
},
|
|
427
|
+
showContributors: {
|
|
428
|
+
type: Boolean,
|
|
429
|
+
default: false,
|
|
430
|
+
},
|
|
400
431
|
},
|
|
401
432
|
setup(props) {
|
|
402
433
|
const {
|
|
@@ -477,6 +508,13 @@ export default {
|
|
|
477
508
|
{ width: 335, viewSize: 375 },
|
|
478
509
|
];
|
|
479
510
|
},
|
|
511
|
+
lendersNumber() {
|
|
512
|
+
return this.loan?.lenders?.totalCount ?? 0;
|
|
513
|
+
},
|
|
514
|
+
amountLent() {
|
|
515
|
+
const amount = this.loan?.loanFundraisingInfo?.fundedAmount ?? 0;
|
|
516
|
+
return numeral(parseFloat(amount)).format('$0,0');
|
|
517
|
+
},
|
|
480
518
|
},
|
|
481
519
|
};
|
|
482
520
|
</script>
|
package/vue/KvLendCta.vue
CHANGED
|
@@ -8,9 +8,9 @@
|
|
|
8
8
|
data-testid="bp-lend-cta-checkout-button"
|
|
9
9
|
:to="!externalLinks ? '/basket' : undefined"
|
|
10
10
|
:href="externalLinks ? '/basket' : undefined"
|
|
11
|
-
@click.native="
|
|
11
|
+
@click.native="clickSecondaryButton"
|
|
12
12
|
>
|
|
13
|
-
|
|
13
|
+
{{ loanInBasketButtonText }}
|
|
14
14
|
</kv-ui-button>
|
|
15
15
|
|
|
16
16
|
<!-- Refunded, allSharesReserved button -->
|
|
@@ -98,7 +98,7 @@
|
|
|
98
98
|
data-testid="bp-lend-cta-lend-again-button"
|
|
99
99
|
type="submit"
|
|
100
100
|
>
|
|
101
|
-
Lend again
|
|
101
|
+
{{ primaryButtonText || 'Lend' }} again
|
|
102
102
|
</kv-ui-button>
|
|
103
103
|
</div>
|
|
104
104
|
|
|
@@ -206,6 +206,18 @@ export default {
|
|
|
206
206
|
type: Boolean,
|
|
207
207
|
default: true,
|
|
208
208
|
},
|
|
209
|
+
primaryButtonText: {
|
|
210
|
+
type: String,
|
|
211
|
+
default: 'Lend',
|
|
212
|
+
},
|
|
213
|
+
secondaryButtonText: {
|
|
214
|
+
type: String,
|
|
215
|
+
default: 'Checkout now',
|
|
216
|
+
},
|
|
217
|
+
secondaryButtonHandler: {
|
|
218
|
+
type: Function,
|
|
219
|
+
default: undefined,
|
|
220
|
+
},
|
|
209
221
|
},
|
|
210
222
|
data() {
|
|
211
223
|
return {
|
|
@@ -261,7 +273,7 @@ export default {
|
|
|
261
273
|
},
|
|
262
274
|
ctaButtonText() {
|
|
263
275
|
if (this.isCompleteLoanActive) {
|
|
264
|
-
return 'Lend';
|
|
276
|
+
return this.primaryButtonText || 'Lend';
|
|
265
277
|
}
|
|
266
278
|
switch (this.state) {
|
|
267
279
|
case 'loading':
|
|
@@ -269,9 +281,12 @@ export default {
|
|
|
269
281
|
case 'refunded':
|
|
270
282
|
case 'expired':
|
|
271
283
|
default:
|
|
272
|
-
return 'Lend';
|
|
284
|
+
return this.primaryButtonText || 'Lend';
|
|
273
285
|
}
|
|
274
286
|
},
|
|
287
|
+
loanInBasketButtonText() {
|
|
288
|
+
return this.secondaryButtonText;
|
|
289
|
+
},
|
|
275
290
|
useFormSubmit() {
|
|
276
291
|
if (this.hideShowLendDropdown
|
|
277
292
|
|| this.lendButtonVisibility
|
|
@@ -392,7 +407,16 @@ export default {
|
|
|
392
407
|
clickDropdown() {
|
|
393
408
|
this.kvTrackFunction('Lending', 'click-Modify loan amount', 'open dialog', this.loanId, this.loanId);
|
|
394
409
|
},
|
|
395
|
-
|
|
410
|
+
clickSecondaryButton() {
|
|
411
|
+
if (this.secondaryButtonHandler) {
|
|
412
|
+
// Custom secondary button behavior
|
|
413
|
+
this.secondaryButtonHandler();
|
|
414
|
+
} else {
|
|
415
|
+
// Default secondary button behavior
|
|
416
|
+
this.handleCheckout();
|
|
417
|
+
}
|
|
418
|
+
},
|
|
419
|
+
handleCheckout() {
|
|
396
420
|
this.kvTrackFunction(
|
|
397
421
|
'Lending',
|
|
398
422
|
'click-Continue-to-checkout',
|
|
@@ -33,6 +33,9 @@ const story = (args) => {
|
|
|
33
33
|
:combined-activities="combinedActivities"
|
|
34
34
|
:enable-huge-amount="enableHugeAmount"
|
|
35
35
|
:enable-clickable-tags="enableClickableTags"
|
|
36
|
+
:primary-button-text="primaryButtonText"
|
|
37
|
+
:secondary-button-text="secondaryButtonText"
|
|
38
|
+
:secondary-button-handler="secondaryButtonHandler"
|
|
36
39
|
/>
|
|
37
40
|
</div>
|
|
38
41
|
`,
|
|
@@ -397,3 +400,49 @@ export const ClickableTags = story({
|
|
|
397
400
|
photoPath,
|
|
398
401
|
enableClickableTags: true,
|
|
399
402
|
});
|
|
403
|
+
|
|
404
|
+
export const SupportButton = story({
|
|
405
|
+
loanId: loan.id,
|
|
406
|
+
loan,
|
|
407
|
+
primaryButtonText: 'Support',
|
|
408
|
+
kvTrackFunction,
|
|
409
|
+
photoPath,
|
|
410
|
+
});
|
|
411
|
+
|
|
412
|
+
export const SupportAgain = story({
|
|
413
|
+
loanId: loan.id,
|
|
414
|
+
loan: {
|
|
415
|
+
...loan,
|
|
416
|
+
userProperties: { lentTo: true },
|
|
417
|
+
},
|
|
418
|
+
primaryButtonText: 'Support',
|
|
419
|
+
kvTrackFunction,
|
|
420
|
+
photoPath,
|
|
421
|
+
});
|
|
422
|
+
|
|
423
|
+
export const RemoveButton = story({
|
|
424
|
+
loanId: loan.id,
|
|
425
|
+
loan,
|
|
426
|
+
kvTrackFunction,
|
|
427
|
+
photoPath,
|
|
428
|
+
basketItems: [{ id: loan.id, __typename: 'LoanReservation' }],
|
|
429
|
+
secondaryButtonText: 'Remove Loan',
|
|
430
|
+
secondaryButtonHandler: () => {},
|
|
431
|
+
});
|
|
432
|
+
|
|
433
|
+
export const ContributorsAndAmount = story({
|
|
434
|
+
loanId: loan.id,
|
|
435
|
+
loan: {
|
|
436
|
+
...loan,
|
|
437
|
+
loanFundraisingInfo: {
|
|
438
|
+
fundedAmount: '950.00',
|
|
439
|
+
reservedAmount: '0.00',
|
|
440
|
+
isExpiringSoon: false,
|
|
441
|
+
},
|
|
442
|
+
lenders: {
|
|
443
|
+
totalCount: 7,
|
|
444
|
+
},
|
|
445
|
+
},
|
|
446
|
+
kvTrackFunction,
|
|
447
|
+
photoPath,
|
|
448
|
+
});
|