@kiva/kv-components 3.16.0 → 3.17.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.
@@ -0,0 +1,62 @@
1
+ import KvBorrowerImage from '../KvBorrowerImage.vue';
2
+
3
+ export default {
4
+ title: 'KvBorrowerImage',
5
+ component: KvBorrowerImage,
6
+ };
7
+
8
+ const story = (args) => {
9
+ const template = (_args, { argTypes }) => ({
10
+ props: Object.keys(argTypes),
11
+ components: { KvBorrowerImage },
12
+ template: `
13
+ <div style="width: 336px;">
14
+ <kv-borrower-image
15
+ :alt="alt"
16
+ :aspect-ratio="aspectRatio"
17
+ :default-image="defaultImage"
18
+ :hash="hash"
19
+ :images="images"
20
+ :photo-path="photoPath"
21
+ />
22
+ </div>
23
+ `,
24
+ });
25
+ template.args = args;
26
+ return template;
27
+ };
28
+
29
+ const props = {
30
+ alt: 'Photo of Borrower',
31
+ aspectRatio: 0.75,
32
+ defaultImage: { width: 336 },
33
+ hash: '9673d0722a7675b9b8d11f90849d9b44',
34
+ images: [
35
+ {
36
+ width: 336,
37
+ viewSize: 1024,
38
+ },
39
+ {
40
+ width: 336,
41
+ viewSize: 768,
42
+ },
43
+ {
44
+ width: 416,
45
+ viewSize: 480,
46
+ },
47
+ {
48
+ width: 374,
49
+ viewSize: 414,
50
+ },
51
+ {
52
+ width: 335,
53
+ viewSize: 375,
54
+ },
55
+ {
56
+ width: 300,
57
+ },
58
+ ],
59
+ photoPath: 'https://www-kiva-org.freetls.fastly.net/img/',
60
+ };
61
+
62
+ export const Default = story(props);
@@ -0,0 +1,206 @@
1
+ import KvClassicLoanCard from '../KvClassicLoanCard.vue';
2
+
3
+ export default {
4
+ title: 'KvClassicLoanCard',
5
+ component: KvClassicLoanCard,
6
+ };
7
+
8
+ const story = (args) => {
9
+ const template = (_args, { argTypes }) => ({
10
+ props: Object.keys(argTypes),
11
+ components: { KvClassicLoanCard },
12
+ template: `
13
+ <div style="width: 600px;">
14
+ <kv-classic-loan-card
15
+ :loanId="loanId"
16
+ :loan="loan"
17
+ :custom-loan-details="customLoanDetails"
18
+ :use-full-width="useFullWidth"
19
+ :show-tags="showTags"
20
+ :category-page-name="categoryPageName"
21
+ :enable-five-dollars-notes="enableFiveDollarsNotes"
22
+ :large-card="largeCard"
23
+ :is-adding="isAdding"
24
+ :is-visitor="isVisitor"
25
+ :basket-items="basketItems"
26
+ :is-bookmarked="isBookmarked"
27
+ :kv-track-function="kvTrackFunction"
28
+ :photo-path="photoPath"
29
+ />
30
+ </div>
31
+ `,
32
+ });
33
+ template.args = args;
34
+ return template;
35
+ };
36
+
37
+ const nextWeek = new Date();
38
+ nextWeek.setDate(new Date().getDate() + 7);
39
+
40
+ const loan = {
41
+ id: 1,
42
+ name: 'Alan',
43
+ geocode: {
44
+ city: 'Lyantonde',
45
+ state: 'Central Region',
46
+ country: {
47
+ isoCode: 'UG',
48
+ name: 'Uganda',
49
+ region: 'Africa',
50
+ __typename: 'Country',
51
+ },
52
+ __typename: 'Geocode',
53
+ },
54
+ image: { hash: '9673d0722a7675b9b8d11f90849d9b44' },
55
+ fundraisingPercent: 0.5,
56
+ unreservedAmount: '500.00',
57
+ use: 'to purchase heifers to increase headcount of cattle and sales of organic milk.',
58
+ status: 'fundraising',
59
+ loanAmount: '1000.00',
60
+ borrowerCount: 1,
61
+ activity: {
62
+ id: 61,
63
+ name: 'Dairy',
64
+ __typename: 'Activity',
65
+ },
66
+ sector: {
67
+ id: 1,
68
+ name: 'Agriculture',
69
+ __typename: 'Sector',
70
+ },
71
+ plannedExpirationDate: nextWeek.toISOString(),
72
+ };
73
+
74
+ const kvTrackFunction = () => { };
75
+
76
+ const photoPath = 'https://www-kiva-org.freetls.fastly.net/img/';
77
+
78
+ export const Loading = story({
79
+ loanId: loan.id,
80
+ loan: undefined,
81
+ kvTrackFunction,
82
+ photoPath,
83
+ });
84
+
85
+ export const PartialLoading = story({
86
+ loanId: loan.id,
87
+ loan: {
88
+ ...loan,
89
+ unreservedAmount: undefined,
90
+ fundraisingPercent: undefined,
91
+ },
92
+ kvTrackFunction,
93
+ photoPath,
94
+ });
95
+
96
+ export const UseFullWidth = story({
97
+ loanId: loan.id,
98
+ loan,
99
+ kvTrackFunction,
100
+ photoPath,
101
+ useFullWidth: true,
102
+ });
103
+
104
+ export const ShowTags = story({
105
+ loanId: loan.id,
106
+ loan: {
107
+ ...loan,
108
+ loanFundraisingInfo: {
109
+ fundedAmount: '950.00',
110
+ isExpiringSoon: false,
111
+ reservedAmount: '0.00',
112
+ },
113
+ },
114
+ kvTrackFunction,
115
+ photoPath,
116
+ showTags: true,
117
+ });
118
+
119
+ export const Matched = story({
120
+ loanId: loan.id,
121
+ loan: {
122
+ ...loan,
123
+ matchingText: 'Matched by Ebay',
124
+ matchRatio: 1,
125
+ loanFundraisingInfo: {
126
+ fundedAmount: '200.00',
127
+ isExpiringSoon: false,
128
+ reservedAmount: '0.00',
129
+ },
130
+ },
131
+ kvTrackFunction,
132
+ photoPath,
133
+ showTags: true,
134
+ });
135
+
136
+ export const AllSharesReserved = story({
137
+ loanId: loan.id,
138
+ loan: {
139
+ ...loan,
140
+ unreservedAmount: '0.00',
141
+ fundraisingPercent: 1,
142
+ },
143
+ kvTrackFunction,
144
+ photoPath,
145
+ }, false, { unreservedAmount: '0.00', fundraisingPercent: 1 });
146
+
147
+ export const InBasket = story({
148
+ loanId: loan.id,
149
+ loan,
150
+ kvTrackFunction,
151
+ photoPath,
152
+ basketItems: [{ id: loan.id, __typename: 'LoanReservation' }],
153
+ });
154
+
155
+ export const LargeCardLoading = story({
156
+ loanId: loan.id,
157
+ loan: undefined,
158
+ kvTrackFunction,
159
+ photoPath,
160
+ largeCard: true,
161
+ });
162
+
163
+ export const LargeCard = story({
164
+ loanId: loan.id,
165
+ loan,
166
+ showTags: true,
167
+ largeCard: true,
168
+ kvTrackFunction,
169
+ photoPath,
170
+ });
171
+
172
+ export const LongCallouts = story({
173
+ loanId: loan.id,
174
+ loan: {
175
+ ...loan,
176
+ activity: { id: 1, name: 'Longer activity name test that will be longer than 50% of the card' },
177
+ },
178
+ showTags: true,
179
+ kvTrackFunction,
180
+ photoPath,
181
+ });
182
+
183
+ export const Bookmarked = story({
184
+ loanId: loan.id,
185
+ loan,
186
+ isBookmarked: true,
187
+ isVisitor: false,
188
+ kvTrackFunction,
189
+ photoPath,
190
+ });
191
+
192
+ export const Adding = story({
193
+ loanId: loan.id,
194
+ loan,
195
+ isAdding: true,
196
+ kvTrackFunction,
197
+ photoPath,
198
+ });
199
+
200
+ export const FiveDollarNotes = story({
201
+ loanId: loan.id,
202
+ loan,
203
+ enableFiveDollarsNotes: true,
204
+ kvTrackFunction,
205
+ photoPath,
206
+ });
@@ -0,0 +1,34 @@
1
+ import KvLendAmountButton from '../KvLendAmountButton.vue';
2
+
3
+ export default {
4
+ title: 'KvLendAmountButton',
5
+ component: KvLendAmountButton,
6
+ };
7
+
8
+ const story = (args) => {
9
+ const template = (_args, { argTypes }) => ({
10
+ props: Object.keys(argTypes),
11
+ components: { KvLendAmountButton },
12
+ template: `
13
+ <kv-lend-amount-button
14
+ :loan-id="loanId"
15
+ :show-now="showNow"
16
+ :amount-left="amountLeft"
17
+ :complete-loan="completeLoan"
18
+ :is-adding="isAdding"
19
+ />
20
+ `,
21
+ });
22
+ template.args = args;
23
+ return template;
24
+ };
25
+
26
+ export const Default = story();
27
+
28
+ export const ShowNow = story({ showNow: true });
29
+
30
+ export const AmountLeft = story({ amountLeft: 5 });
31
+
32
+ export const CompleteLoan = story({ completeLoan: true });
33
+
34
+ export const IsAdding = story({ isAdding: true });
@@ -0,0 +1,104 @@
1
+ import KvLendCta from '../KvLendCta.vue';
2
+
3
+ export default {
4
+ title: 'KvLendCta',
5
+ component: KvLendCta,
6
+ };
7
+
8
+ const story = (args) => {
9
+ const template = (_args, { argTypes }) => ({
10
+ props: Object.keys(argTypes),
11
+ components: { KvLendCta },
12
+ template: `
13
+ <div style="width: 300px;">
14
+ <kv-lend-cta
15
+ :loan="loan"
16
+ :basket-items="basketItems"
17
+ :is-loading="isLoading"
18
+ :is-adding="isAdding"
19
+ :enable-five-dollars-notes="enableFiveDollarsNotes"
20
+ :kv-track-function="kvTrackFunction"
21
+ />
22
+ </div>
23
+ `,
24
+ });
25
+ template.args = args;
26
+ return template;
27
+ };
28
+
29
+ const kvTrackFunction = () => { };
30
+
31
+ export const Loading = story({ isLoading: true, kvTrackFunction });
32
+
33
+ export const Adding = story({ isLoading: false, isAdding: true, kvTrackFunction });
34
+
35
+ export const Basketed = story({
36
+ isLoading: false,
37
+ loan: { id: 1 },
38
+ basketItems: [
39
+ {
40
+ __typename: 'LoanReservation',
41
+ id: 1,
42
+ },
43
+ ],
44
+ kvTrackFunction,
45
+ });
46
+
47
+ export const Funded = story({
48
+ isLoading: false,
49
+ loan: { status: 'funded' },
50
+ kvTrackFunction,
51
+ });
52
+
53
+ export const NonActionable = story({
54
+ isLoading: false,
55
+ loan: { status: 'refunded' },
56
+ kvTrackFunction,
57
+ });
58
+
59
+ export const Dropdown = story({
60
+ isLoading: false,
61
+ loan: {
62
+ id: 1,
63
+ unreservedAmount: '150.00',
64
+ },
65
+ kvTrackFunction,
66
+ });
67
+
68
+ export const FiveDollar = story({
69
+ isLoading: false,
70
+ loan: {
71
+ id: 1,
72
+ unreservedAmount: '150.00',
73
+ },
74
+ enableFiveDollarsNotes: true,
75
+ kvTrackFunction,
76
+ });
77
+
78
+ export const LessThan25 = story({
79
+ isLoading: false,
80
+ loan: {
81
+ id: 1,
82
+ unreservedAmount: '20.00',
83
+ },
84
+ kvTrackFunction,
85
+ });
86
+
87
+ export const Non25Increments = story({
88
+ isLoading: false,
89
+ loan: {
90
+ id: 1,
91
+ unreservedAmount: '30.00',
92
+ },
93
+ kvTrackFunction,
94
+ });
95
+
96
+ export const LendAgain = story({
97
+ isLoading: false,
98
+ loan: {
99
+ id: 1,
100
+ unreservedAmount: '150.00',
101
+ userProperties: { lentTo: true },
102
+ },
103
+ kvTrackFunction,
104
+ });
@@ -0,0 +1,22 @@
1
+ import KvLoanBookmark from '../KvLoanBookmark.vue';
2
+
3
+ export default {
4
+ title: 'KvLoanBookmark',
5
+ component: KvLoanBookmark,
6
+ };
7
+
8
+ const story = (args) => {
9
+ const template = (_args, { argTypes }) => ({
10
+ props: Object.keys(argTypes),
11
+ components: { KvLoanBookmark },
12
+ template: `
13
+ <kv-loan-bookmark :is-bookmarked="isBookmarked" />
14
+ `,
15
+ });
16
+ template.args = args;
17
+ return template;
18
+ };
19
+
20
+ export const Bookmarked = story({ isBookmarked: true });
21
+
22
+ export const NotBookmarked = story();
@@ -0,0 +1,22 @@
1
+ import KvLoanCallouts from '../KvLoanCallouts.vue';
2
+
3
+ export default {
4
+ title: 'KvLoanCallouts',
5
+ component: KvLoanCallouts,
6
+ };
7
+
8
+ const story = (args) => {
9
+ const template = (_args, { argTypes }) => ({
10
+ props: Object.keys(argTypes),
11
+ components: { KvLoanCallouts },
12
+ template: `
13
+ <kv-loan-callouts
14
+ :callouts="callouts"
15
+ />
16
+ `,
17
+ });
18
+ template.args = args;
19
+ return template;
20
+ };
21
+
22
+ export const Default = story({ callouts: ['callout 1', 'callout 2', 'callout 3'] });
@@ -0,0 +1,29 @@
1
+ import KvLoanProgressGroup from '../KvLoanProgressGroup.vue';
2
+
3
+ export default {
4
+ title: 'KvLoanProgressGroup',
5
+ component: KvLoanProgressGroup,
6
+ };
7
+
8
+ const story = (args) => {
9
+ const template = (_args, { argTypes }) => ({
10
+ props: Object.keys(argTypes),
11
+ components: { KvLoanProgressGroup },
12
+ template: `
13
+ <div style="width: 200px">
14
+ <kv-loan-progress-group
15
+ :money-left="moneyLeft"
16
+ :progress-percent="progressPercent"
17
+ />
18
+ </div>
19
+ `,
20
+ });
21
+ template.args = args;
22
+ return template;
23
+ };
24
+
25
+ export const Default = story();
26
+
27
+ export const LowAmount = story({ moneyLeft: 5, progressPercent: 0.9 });
28
+
29
+ export const HighAmount = story({ moneyLeft: 150, progressPercent: 0.5 });
@@ -0,0 +1,51 @@
1
+ import KvLoanTag from '../KvLoanTag.vue';
2
+
3
+ export default {
4
+ title: 'KvLoanTag',
5
+ component: KvLoanTag,
6
+ };
7
+
8
+ const story = (args) => {
9
+ const template = (_args, { argTypes }) => ({
10
+ props: Object.keys(argTypes),
11
+ components: { KvLoanTag },
12
+ template: `
13
+ <kv-loan-tag
14
+ :loan="loan"
15
+ :kv-track-function="kvTrackFunction"
16
+ />
17
+ `,
18
+ });
19
+ template.args = args;
20
+ return template;
21
+ };
22
+
23
+ const tomorrow = new Date();
24
+ tomorrow.setDate(tomorrow.getDate() + 1);
25
+
26
+ const nextWeek = new Date();
27
+ nextWeek.setDate(new Date().getDate() + 7);
28
+
29
+ const kvTrackFunction = () => {};
30
+
31
+ export const EndingSoon = story({ loan: { plannedExpirationDate: tomorrow.toISOString() }, kvTrackFunction });
32
+
33
+ export const AlmostFunded = story({
34
+ loan: {
35
+ loanAmount: 199,
36
+ plannedExpirationDate: nextWeek.toISOString(),
37
+ loanFundraisingInfo: { fundedAmount: 50, reservedAmount: 50 },
38
+ },
39
+ kvTrackFunction,
40
+ });
41
+
42
+ export const Matched = story({
43
+ loan: {
44
+ matchingText: 'Ebay',
45
+ matchRatio: 1,
46
+ plannedExpirationDate: nextWeek.toISOString(),
47
+ loanAmount: 199,
48
+ loanFundraisingInfo: { fundedAmount: 0, reservedAmount: 0 },
49
+ },
50
+ kvTrackFunction,
51
+ });
@@ -0,0 +1,51 @@
1
+ import KvLoanUse from '../KvLoanUse.vue';
2
+
3
+ export default {
4
+ title: 'KvLoanUse',
5
+ component: KvLoanUse,
6
+ };
7
+
8
+ const story = (args) => {
9
+ const template = (_args, { argTypes }) => ({
10
+ props: Object.keys(argTypes),
11
+ components: { KvLoanUse },
12
+ template: `
13
+ <kv-loan-use
14
+ :anonymization-level="anonymizationLevel"
15
+ :use="use"
16
+ :loan-amount="loanAmount"
17
+ :status="status"
18
+ :borrower-count="borrowerCount"
19
+ :name="name"
20
+ :distribution-model="distributionModel"
21
+ />
22
+ `,
23
+ });
24
+ template.args = args;
25
+ return template;
26
+ };
27
+
28
+ export const Anonymous = story({ anonymizationLevel: 'full' });
29
+
30
+ export const Partner = story({
31
+ use: 'buy supplies.',
32
+ loanAmount: '1000.00',
33
+ status: 'fundraising',
34
+ name: 'Bob Smith',
35
+ distributionModel: 'partner',
36
+ });
37
+
38
+ export const Direct = story({
39
+ use: 'buy supplies.',
40
+ loanAmount: '1000.00',
41
+ status: 'fundraising',
42
+ name: 'Bob Smith',
43
+ });
44
+
45
+ export const Group = story({
46
+ use: 'buy supplies.',
47
+ loanAmount: '1000.00',
48
+ status: 'fundraising',
49
+ name: 'Farm Organization',
50
+ borrowerCount: 2,
51
+ });
@@ -1,33 +0,0 @@
1
- const path = require('path');
2
-
3
- module.exports = {
4
- stories: [
5
- '../stories/Styleguide.stories.js', // show the base styleguide first
6
- '../stories/**/*.stories.mdx',
7
- '../stories/**/*.stories.@(js|jsx|ts|tsx)'
8
- ],
9
- addons: [
10
- '@storybook/addon-links',
11
- '@storybook/addon-essentials',
12
- '@storybook/addon-a11y',
13
- '@storybook/addon-storysource',
14
- 'storybook-dark-mode',
15
- {
16
- name: '@storybook/addon-postcss',
17
- options: {
18
- postcssLoaderOptions: {
19
- implementation: require('postcss'),
20
- },
21
- },
22
- },
23
- ],
24
- webpackFinal: async (config) => {
25
- config.module.rules.push({
26
- test: /\.mjs$/,
27
- include: /node_modules/,
28
- type: 'javascript/auto'
29
- });
30
- return config;
31
- },
32
- "framework": "@storybook/vue"
33
- }