@kiva/kv-components 3.27.0 → 3.29.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
CHANGED
|
@@ -3,6 +3,29 @@
|
|
|
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.29.0](https://github.com/kiva/kv-ui-elements/compare/@kiva/kv-components@3.28.0...@kiva/kv-components@3.29.0) (2023-07-14)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* created generic countdown component ([a321379](https://github.com/kiva/kv-ui-elements/commit/a321379aee166c3f8e91def8e2be42b4d42d5896))
|
|
12
|
+
* custom countdown for vue 2 + 3 ([2bafad9](https://github.com/kiva/kv-ui-elements/commit/2bafad90df469b447d472926fa82d119711f2885))
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
# [3.28.0](https://github.com/kiva/kv-ui-elements/compare/@kiva/kv-components@3.27.0...@kiva/kv-components@3.28.0) (2023-07-06)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
### Features
|
|
22
|
+
|
|
23
|
+
* avoid image bug for tiny screens ([#270](https://github.com/kiva/kv-ui-elements/issues/270)) ([d59aa72](https://github.com/kiva/kv-ui-elements/commit/d59aa72fa49605bcf5b7d88ed9efed28bc804d14))
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
6
29
|
# [3.27.0](https://github.com/kiva/kv-ui-elements/compare/@kiva/kv-components@3.26.0...@kiva/kv-components@3.27.0) (2023-06-27)
|
|
7
30
|
|
|
8
31
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kiva/kv-components",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.29.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -53,7 +53,6 @@
|
|
|
53
53
|
"build": "echo No build needed for @kiva/kv-components."
|
|
54
54
|
},
|
|
55
55
|
"dependencies": {
|
|
56
|
-
"@chenfengyuan/vue-countdown": "^1.1.5",
|
|
57
56
|
"@kiva/kv-tokens": "^2.8.0",
|
|
58
57
|
"@mdi/js": "^5.9.55",
|
|
59
58
|
"@vueuse/integrations": "^7.6.0",
|
|
@@ -62,6 +61,7 @@
|
|
|
62
61
|
"date-fns": "^2.30.0",
|
|
63
62
|
"embla-carousel": "^4.5.3",
|
|
64
63
|
"focus-trap": "^6.7.2",
|
|
64
|
+
"moment": "^2.29.4",
|
|
65
65
|
"nanoid": "^3.1.23",
|
|
66
66
|
"numeral": "^2.0.6",
|
|
67
67
|
"vue-demi": "^0.12.1"
|
|
@@ -75,5 +75,5 @@
|
|
|
75
75
|
"optional": true
|
|
76
76
|
}
|
|
77
77
|
},
|
|
78
|
-
"gitHead": "
|
|
78
|
+
"gitHead": "c6cb925341942eed7b7e89a469e1b6bd0878af27"
|
|
79
79
|
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<span v-if="timeLeft">
|
|
3
|
+
{{ timeLeft.hours() }}h {{ timeLeft.minutes() }}m {{ timeLeft.seconds() }}s
|
|
4
|
+
</span>
|
|
5
|
+
</template>
|
|
6
|
+
|
|
7
|
+
<script>
|
|
8
|
+
import {
|
|
9
|
+
ref,
|
|
10
|
+
toRefs,
|
|
11
|
+
onBeforeUnmount,
|
|
12
|
+
onMounted,
|
|
13
|
+
} from 'vue-demi';
|
|
14
|
+
import moment from 'moment';
|
|
15
|
+
|
|
16
|
+
export default {
|
|
17
|
+
props: {
|
|
18
|
+
msLeft: {
|
|
19
|
+
type: Number,
|
|
20
|
+
required: true,
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
setup(props) {
|
|
24
|
+
const { msLeft } = toRefs(props);
|
|
25
|
+
|
|
26
|
+
const interval = ref(null);
|
|
27
|
+
const timeLeft = ref(null);
|
|
28
|
+
|
|
29
|
+
onMounted(() => {
|
|
30
|
+
timeLeft.value = moment.duration(msLeft.value > 0 ? msLeft.value : 0, 'milliseconds');
|
|
31
|
+
|
|
32
|
+
const countdownInterval = 1000;
|
|
33
|
+
|
|
34
|
+
interval.value = setInterval(() => {
|
|
35
|
+
timeLeft.value = moment.duration(timeLeft.value - countdownInterval, 'milliseconds');
|
|
36
|
+
|
|
37
|
+
if (timeLeft.value <= 0) {
|
|
38
|
+
clearInterval(interval.value);
|
|
39
|
+
}
|
|
40
|
+
}, countdownInterval);
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
onBeforeUnmount(() => {
|
|
44
|
+
clearInterval(interval.value);
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
return { timeLeft };
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
</script>
|
package/vue/KvLoanTag.vue
CHANGED
|
@@ -1,36 +1,27 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div
|
|
3
|
-
v-if="!!variation
|
|
3
|
+
v-if="!!variation"
|
|
4
4
|
class="tw-text-small tw-font-medium tw-pt-0.5 tw-line-clamp-1"
|
|
5
5
|
style="color: #CE4A00;"
|
|
6
6
|
>
|
|
7
7
|
{{ tagText }}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
:emit-events="false"
|
|
13
|
-
:transform="transform"
|
|
14
|
-
>
|
|
15
|
-
<template slot-scope="props">
|
|
16
|
-
{{ props.hours }}h {{ props.minutes }}m {{ props.seconds }}s
|
|
17
|
-
</template>
|
|
18
|
-
</vue-countdown> -->
|
|
8
|
+
<kv-countdown-timer
|
|
9
|
+
v-if="variation === 'ending-soon'"
|
|
10
|
+
:ms-left="msLeft"
|
|
11
|
+
/>
|
|
19
12
|
</div>
|
|
20
13
|
</template>
|
|
21
14
|
|
|
22
15
|
<script>
|
|
23
16
|
import { differenceInDays, parseISO } from 'date-fns';
|
|
24
|
-
// TODO: ensure countdown works in Vue 3 apps
|
|
25
|
-
// import VueCountdown from '@chenfengyuan/vue-countdown';
|
|
26
17
|
import numeral from 'numeral';
|
|
18
|
+
import KvCountdownTimer from './KvCountdownTimer.vue';
|
|
27
19
|
|
|
28
20
|
export default {
|
|
29
21
|
name: 'KvLoanTag',
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
// },
|
|
22
|
+
components: {
|
|
23
|
+
KvCountdownTimer,
|
|
24
|
+
},
|
|
34
25
|
props: {
|
|
35
26
|
loan: {
|
|
36
27
|
type: Object,
|
|
@@ -43,7 +34,8 @@ export default {
|
|
|
43
34
|
},
|
|
44
35
|
data() {
|
|
45
36
|
return {
|
|
46
|
-
|
|
37
|
+
interval: null,
|
|
38
|
+
msLeft: parseISO(this.loan?.plannedExpirationDate).getTime() - new Date().getTime(),
|
|
47
39
|
};
|
|
48
40
|
},
|
|
49
41
|
computed: {
|
|
@@ -66,48 +58,12 @@ export default {
|
|
|
66
58
|
switch (this.variation) {
|
|
67
59
|
case 'almost-funded': return 'Almost funded';
|
|
68
60
|
case 'matched-loan': return `${this.matchRatio + 1}x matching by ${this.loan?.matchingText}`;
|
|
69
|
-
default: return 'Ending soon';
|
|
70
|
-
// TODO: ensure countdown works in Vue 3 apps
|
|
71
|
-
// default: return 'Ending soon: ';
|
|
61
|
+
default: return 'Ending soon: ';
|
|
72
62
|
}
|
|
73
63
|
},
|
|
74
|
-
timeLeftMs() {
|
|
75
|
-
const msLeft = parseISO(this.loan?.plannedExpirationDate).getTime() - new Date().getTime();
|
|
76
|
-
return msLeft > 0 ? msLeft : 0;
|
|
77
|
-
},
|
|
78
64
|
matchRatio() {
|
|
79
65
|
return this.loan?.matchRatio;
|
|
80
66
|
},
|
|
81
67
|
},
|
|
82
|
-
mounted() {
|
|
83
|
-
this.isMounted = true;
|
|
84
|
-
|
|
85
|
-
if (this.variation) {
|
|
86
|
-
this.kvTrackFunction(
|
|
87
|
-
'loan-card',
|
|
88
|
-
'show',
|
|
89
|
-
`tag-${this.variation}`,
|
|
90
|
-
);
|
|
91
|
-
}
|
|
92
|
-
},
|
|
93
|
-
methods: {
|
|
94
|
-
transform(props) {
|
|
95
|
-
Object.entries(props).forEach(([key, value]) => {
|
|
96
|
-
// Adds leading zero
|
|
97
|
-
if (value < 10) {
|
|
98
|
-
// eslint-disable-next-line no-param-reassign
|
|
99
|
-
props[key] = `0${value}`;
|
|
100
|
-
} else {
|
|
101
|
-
// eslint-disable-next-line no-param-reassign
|
|
102
|
-
props[key] = value;
|
|
103
|
-
}
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
// Adds days to hours
|
|
107
|
-
// eslint-disable-next-line radix, no-param-reassign
|
|
108
|
-
props.hours = parseInt(props.hours) + parseInt(props.days) * 24;
|
|
109
|
-
return props;
|
|
110
|
-
},
|
|
111
|
-
},
|
|
112
68
|
};
|
|
113
69
|
</script>
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import KvCountdownTimer from '../KvCountdownTimer.vue';
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
title: 'KvCountdownTimer',
|
|
5
|
+
component: KvCountdownTimer,
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
const story = (args) => {
|
|
9
|
+
const template = (_args, { argTypes }) => ({
|
|
10
|
+
props: Object.keys(argTypes),
|
|
11
|
+
components: {
|
|
12
|
+
KvCountdownTimer,
|
|
13
|
+
},
|
|
14
|
+
template: `
|
|
15
|
+
<kv-countdown-timer
|
|
16
|
+
:ms-left="msLeft"
|
|
17
|
+
/>
|
|
18
|
+
`,
|
|
19
|
+
});
|
|
20
|
+
template.args = args;
|
|
21
|
+
return template;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export const Seconds = story({ msLeft: 1000 * 10 });
|
|
25
|
+
|
|
26
|
+
// One second less than 24 hours (since we don't show days in timer)
|
|
27
|
+
export const Tomorrow = story({ msLeft: 1000 * 60 * 60 * 24 - 1000 });
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import KvLoanTag from '../KvLoanTag.vue';
|
|
2
|
+
import KvCountdownTimer from '../KvCountdownTimer.vue';
|
|
2
3
|
|
|
3
4
|
export default {
|
|
4
5
|
title: 'KvLoanTag',
|
|
@@ -8,7 +9,10 @@ export default {
|
|
|
8
9
|
const story = (args) => {
|
|
9
10
|
const template = (_args, { argTypes }) => ({
|
|
10
11
|
props: Object.keys(argTypes),
|
|
11
|
-
components: {
|
|
12
|
+
components: {
|
|
13
|
+
KvLoanTag,
|
|
14
|
+
KvCountdownTimer,
|
|
15
|
+
},
|
|
12
16
|
template: `
|
|
13
17
|
<kv-loan-tag
|
|
14
18
|
:loan="loan"
|
|
@@ -26,7 +30,7 @@ tomorrow.setDate(tomorrow.getDate() + 1);
|
|
|
26
30
|
const nextWeek = new Date();
|
|
27
31
|
nextWeek.setDate(new Date().getDate() + 7);
|
|
28
32
|
|
|
29
|
-
const kvTrackFunction = () => {};
|
|
33
|
+
const kvTrackFunction = () => { };
|
|
30
34
|
|
|
31
35
|
export const EndingSoon = story({ loan: { plannedExpirationDate: tomorrow.toISOString() }, kvTrackFunction });
|
|
32
36
|
|