@kiva/kv-components 3.33.0 → 3.35.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,28 @@
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.35.0](https://github.com/kiva/kv-ui-elements/compare/@kiva/kv-components@3.34.0...@kiva/kv-components@3.35.0) (2023-08-03)
7
+
8
+
9
+ ### Features
10
+
11
+ * adding new option to the loan progress bar bg ([89afa0a](https://github.com/kiva/kv-ui-elements/commit/89afa0ad20cd64a794441d187da534006a3aeef2))
12
+
13
+
14
+
15
+
16
+
17
+ # [3.34.0](https://github.com/kiva/kv-ui-elements/compare/@kiva/kv-components@3.33.0...@kiva/kv-components@3.34.0) (2023-08-02)
18
+
19
+
20
+ ### Features
21
+
22
+ * balance campaign prices added to loan utility ([#277](https://github.com/kiva/kv-ui-elements/issues/277)) ([319707e](https://github.com/kiva/kv-ui-elements/commit/319707e525865077e531ab6f4c378676da7ee53b))
23
+
24
+
25
+
26
+
27
+
6
28
  # [3.33.0](https://github.com/kiva/kv-ui-elements/compare/@kiva/kv-components@3.32.0...@kiva/kv-components@3.33.0) (2023-08-01)
7
29
 
8
30
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kiva/kv-components",
3
- "version": "3.33.0",
3
+ "version": "3.35.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": "44902626bb39de1e3df5c60a7708203319aee81f"
78
+ "gitHead": "4475c2f9110f86d6cc5f743dd2370181c605a4bb"
79
79
  }
@@ -1,6 +1,16 @@
1
1
  export const ERL_COOKIE_NAME = 'kverlfivedollarnotes';
2
2
  export const TOP_UP_CAMPAIGN = 'TOPUP-VB-BALANCE-MPV1';
3
3
  export const BASE_CAMPAIGN = 'BASE-VB_BALANCE_MPV1';
4
+ export const BALANCE_CAMPAIGN = 'REPAYMENT-NOTIFICATION_BALANCE_MPV1';
5
+ export const NO_BALANCE_CAMPAIGN = 'REPAYMENT-NOTIFICATION_NO-BALANCE_MPV1';
6
+
7
+ function balanceCampaignOptions(val) {
8
+ if (val > 20) return 25;
9
+ if (val > 15) return 20;
10
+ if (val > 10) return 15;
11
+ if (val > 5) return 10;
12
+ return 5;
13
+ }
4
14
 
5
15
  /**
6
16
  * Checks if the unreserved amount is between 25 and 50
@@ -42,6 +52,11 @@ export function getLendCtaSelectedOption(
42
52
  userBalance,
43
53
  fiveDollarsSelected,
44
54
  ) {
55
+ // defaulted to $5 for fiveDollarsSelected flag even when users come from email with a different balance
56
+ if (enableFiveDollarsNotes && fiveDollarsSelected) {
57
+ return '5';
58
+ }
59
+
45
60
  // Don't enable the campaign changes when the user balance is undefined (user not logged in)
46
61
  if (enableFiveDollarsNotes && typeof userBalance !== 'undefined') {
47
62
  let currentCampaign = getCookie?.(ERL_COOKIE_NAME);
@@ -56,7 +71,9 @@ export function getLendCtaSelectedOption(
56
71
  // eslint-disable-next-line no-nested-ternary
57
72
  currentCampaign = campaignToCheck.includes(TOP_UP_CAMPAIGN)
58
73
  ? TOP_UP_CAMPAIGN
59
- : (campaignToCheck.includes(BASE_CAMPAIGN) ? BASE_CAMPAIGN : '');
74
+ : campaignToCheck.includes(BASE_CAMPAIGN) ? BASE_CAMPAIGN // eslint-disable-line no-nested-ternary
75
+ : campaignToCheck.includes(BALANCE_CAMPAIGN) ? BALANCE_CAMPAIGN // eslint-disable-line no-nested-ternary
76
+ : (campaignToCheck.includes(NO_BALANCE_CAMPAIGN) ? NO_BALANCE_CAMPAIGN : '');
60
77
 
61
78
  if (currentCampaign && setCookie) {
62
79
  setCookie(ERL_COOKIE_NAME, currentCampaign, { expires });
@@ -64,25 +81,26 @@ export function getLendCtaSelectedOption(
64
81
  }
65
82
 
66
83
  if (currentCampaign) {
84
+ let val = Math.floor(userBalance / 5) * 5;
85
+
67
86
  // Base campaign gets largest increment of $5 under the user's balance up to $25 or the unreserved amount
68
87
  if (currentCampaign === BASE_CAMPAIGN) {
69
- let val = Math.floor(userBalance / 5) * 5;
70
-
71
88
  // eslint-disable-next-line no-nested-ternary
72
89
  val = val === 0 ? 5 : (val > 25 ? 25 : val);
73
90
 
74
91
  return Number(val <= unreservedAmount ? val : unreservedAmount).toFixed();
75
92
  }
76
93
 
77
- // Top up campaign defaults to $5
94
+ if (currentCampaign === BALANCE_CAMPAIGN) {
95
+ val = balanceCampaignOptions(val);
96
+ return Number(val).toFixed();
97
+ }
98
+
99
+ // Top up and no balance campaigns defaults to $5
78
100
  return Number(unreservedAmount > 5 ? 5 : unreservedAmount).toFixed();
79
101
  }
80
102
  }
81
103
 
82
- if (enableFiveDollarsNotes && fiveDollarsSelected) {
83
- return '5';
84
- }
85
-
86
104
  // Handle when $5 notes isn't enabled
87
105
  if (isBetween25And50(unreservedAmount) || isLessThan25(unreservedAmount)) {
88
106
  return Number(unreservedAmount).toFixed();
@@ -2,8 +2,8 @@
2
2
  <div
3
3
  class="
4
4
  tw-h-1 tw-w-full tw-rounded-full tw-overflow-hidden tw-relative
5
- tw-bg-secondary
6
5
  "
6
+ :class="backgroundVariant"
7
7
  role="progressbar"
8
8
  :aria-label="ariaLabel"
9
9
  :aria-valuemin="min"
@@ -77,6 +77,17 @@ export default {
77
77
  return ['primary', 'ghost', 'danger', 'caution'].includes(value);
78
78
  },
79
79
  },
80
+ /**
81
+ * Appearance of the progress bar background
82
+ * `secondary (default), tertiary
83
+ * */
84
+ bgVariant: {
85
+ type: String,
86
+ default: 'secondary',
87
+ validator(value) {
88
+ return ['secondary', 'tertiary'].includes(value);
89
+ },
90
+ },
80
91
  },
81
92
  setup(props) {
82
93
  const {
@@ -84,6 +95,7 @@ export default {
84
95
  max,
85
96
  value,
86
97
  variant,
98
+ bgVariant,
87
99
  } = toRefs(props);
88
100
  const loaded = ref(false);
89
101
 
@@ -107,6 +119,15 @@ export default {
107
119
  }
108
120
  });
109
121
 
122
+ const backgroundVariant = computed(() => {
123
+ switch (bgVariant.value) {
124
+ case 'tertiary':
125
+ return 'tw-bg-tertiary';
126
+ default:
127
+ return 'tw-bg-secondary';
128
+ }
129
+ });
130
+
110
131
  const animateProgressBar = () => {
111
132
  loaded.value = true;
112
133
  };
@@ -121,6 +142,7 @@ export default {
121
142
  percent,
122
143
  animateProgressBar,
123
144
  variantClass,
145
+ backgroundVariant,
124
146
  };
125
147
  },
126
148
  };
@@ -9,6 +9,7 @@ export default {
9
9
  value: 50,
10
10
  ariaLabel: 'Amount the loan has fundraised',
11
11
  variant: 'primary',
12
+ bgVariant: 'secondary',
12
13
  },
13
14
  };
14
15
 
@@ -22,6 +23,7 @@ const Template = (args, { argTypes }) => ({
22
23
  :max="max"
23
24
  :value="value"
24
25
  :variant="variant"
26
+ :bg-variant="bgVariant"
25
27
 
26
28
  ></kv-progress-bar>`,
27
29
  });
@@ -44,3 +46,8 @@ export const VariantGhost = Template.bind({});
44
46
  VariantGhost.args = {
45
47
  variant: 'ghost',
46
48
  };
49
+
50
+ export const BgVariantTertiary = Template.bind({});
51
+ BgVariantTertiary.args = {
52
+ bgVariant: 'tertiary',
53
+ };