@kiva/kv-components 3.107.0 → 3.107.1
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 +11 -0
- package/dist/components/.storybook/main.js +85 -0
- package/dist/components/.storybook/package.json +3 -0
- package/dist/components/.storybook/preview.js +61 -0
- package/dist/components/.storybook/tailwind.css +5 -0
- package/dist/components/KvAccordionItem.vue +130 -0
- package/dist/components/KvActivityRow.vue +33 -0
- package/dist/components/KvBorrowerImage.vue +179 -0
- package/dist/components/KvButton.vue +287 -0
- package/dist/components/KvCarousel.vue +297 -0
- package/dist/components/KvCartModal.vue +365 -0
- package/dist/components/KvCheckbox.vue +203 -0
- package/dist/components/KvChip.vue +54 -0
- package/dist/components/KvClassicLoanCard.vue +527 -0
- package/dist/components/KvCommentsAdd.vue +135 -0
- package/dist/components/KvCommentsContainer.vue +84 -0
- package/dist/components/KvCommentsHeartButton.vue +70 -0
- package/dist/components/KvCommentsList.vue +68 -0
- package/dist/components/KvCommentsListItem.vue +241 -0
- package/dist/components/KvCommentsReplyButton.vue +52 -0
- package/dist/components/KvContentfulImg.vue +273 -0
- package/dist/components/KvCountdownTimer.vue +59 -0
- package/dist/components/KvExpandable.vue +84 -0
- package/dist/components/KvExpandableQuestion.vue +120 -0
- package/dist/components/KvFlag.vue +120 -0
- package/dist/components/KvGrid.vue +28 -0
- package/dist/components/KvImpactDashboardHeader.vue +40 -0
- package/dist/components/KvInlineActivityCard.vue +55 -0
- package/dist/components/KvInlineActivityFeed.vue +38 -0
- package/dist/components/KvIntroductionLoanCard.vue +446 -0
- package/dist/components/KvLendAmountButton.vue +65 -0
- package/dist/components/KvLendCta.vue +451 -0
- package/dist/components/KvLightbox.vue +334 -0
- package/dist/components/KvLineGraph.vue +128 -0
- package/dist/components/KvLoadingPlaceholder.vue +38 -0
- package/dist/components/KvLoadingSpinner.vue +81 -0
- package/dist/components/KvLoanActivities.vue +268 -0
- package/dist/components/KvLoanBookmark.vue +39 -0
- package/dist/components/KvLoanCallouts.vue +53 -0
- package/dist/components/KvLoanProgressGroup.vue +76 -0
- package/dist/components/KvLoanTag.vue +88 -0
- package/dist/components/KvLoanTeamPick.vue +44 -0
- package/dist/components/KvLoanUse.vue +92 -0
- package/dist/components/KvMap.vue +599 -0
- package/dist/components/KvMaterialIcon.vue +47 -0
- package/dist/components/KvPageContainer.vue +15 -0
- package/dist/components/KvPagination.vue +198 -0
- package/dist/components/KvPieChart.vue +257 -0
- package/dist/components/KvPopper.vue +178 -0
- package/dist/components/KvProgressBar.vue +149 -0
- package/dist/components/KvRadio.vue +198 -0
- package/dist/components/KvSelect.vue +114 -0
- package/dist/components/KvSideSheet.vue +134 -0
- package/dist/components/KvSwitch.vue +143 -0
- package/dist/components/KvTab.vue +90 -0
- package/dist/components/KvTabPanel.vue +64 -0
- package/dist/components/KvTabs.vue +182 -0
- package/dist/components/KvTextInput.vue +247 -0
- package/dist/components/KvTextLink.vue +138 -0
- package/dist/components/KvThemeProvider.vue +122 -0
- package/dist/components/KvToast.vue +221 -0
- package/dist/components/KvTooltip.vue +168 -0
- package/dist/components/KvTreeMapChart.vue +229 -0
- package/dist/components/KvUserAvatar.vue +132 -0
- package/dist/components/KvVerticalCarousel.vue +156 -0
- package/dist/components/KvVotingCard.vue +160 -0
- package/dist/components/KvVotingCardV2.vue +154 -0
- package/dist/components/KvWideLoanCard.vue +432 -0
- package/dist/components/stories/Forms.stories.js +62 -0
- package/dist/components/stories/KvAccordionItem.stories.js +24 -0
- package/dist/components/stories/KvActivityRow.stories.js +25 -0
- package/dist/components/stories/KvBorrowerImage.stories.js +68 -0
- package/dist/components/stories/KvButton.stories.js +144 -0
- package/dist/components/stories/KvCarousel.stories.js +426 -0
- package/dist/components/stories/KvCartModal.stories.js +54 -0
- package/dist/components/stories/KvCheckbox.stories.js +163 -0
- package/dist/components/stories/KvChip.stories.js +43 -0
- package/dist/components/stories/KvClassicLoanCard.stories.js +480 -0
- package/dist/components/stories/KvCommentsAdd.stories.js +32 -0
- package/dist/components/stories/KvCommentsContainer.stories.js +42 -0
- package/dist/components/stories/KvCommentsHeartButton.stories.js +25 -0
- package/dist/components/stories/KvCommentsList.stories.js +39 -0
- package/dist/components/stories/KvCommentsListItem.stories.js +45 -0
- package/dist/components/stories/KvCommentsReplyButton.stories.js +21 -0
- package/dist/components/stories/KvContentfulImg.stories.js +196 -0
- package/dist/components/stories/KvCountdownTimer.stories.js +30 -0
- package/dist/components/stories/KvExpandableQuestion.stories.js +129 -0
- package/dist/components/stories/KvFlag.stories.js +36 -0
- package/dist/components/stories/KvGrid.stories.js +97 -0
- package/dist/components/stories/KvImpactDashboardHeader.stories.js +22 -0
- package/dist/components/stories/KvInlineActivityCard.stories.js +69 -0
- package/dist/components/stories/KvInlineActivityFeed.stories.js +76 -0
- package/dist/components/stories/KvIntroductionLoanCard.stories.js +208 -0
- package/dist/components/stories/KvLendAmountButton.stories.js +31 -0
- package/dist/components/stories/KvLendCta.stories.js +177 -0
- package/dist/components/stories/KvLightbox.stories.js +304 -0
- package/dist/components/stories/KvLineGraph.stories.js +52 -0
- package/dist/components/stories/KvLoadingPlaceholder.stories.js +17 -0
- package/dist/components/stories/KvLoadingSpinner.stories.js +52 -0
- package/dist/components/stories/KvLoanActivities.stories.js +104 -0
- package/dist/components/stories/KvLoanBookmark.stories.js +22 -0
- package/dist/components/stories/KvLoanCallouts.stories.js +22 -0
- package/dist/components/stories/KvLoanProgressGroup.stories.js +29 -0
- package/dist/components/stories/KvLoanTag.stories.js +61 -0
- package/dist/components/stories/KvLoanTeamPick.stories.js +20 -0
- package/dist/components/stories/KvLoanUse.stories.js +60 -0
- package/dist/components/stories/KvMap.stories.js +121 -0
- package/dist/components/stories/KvMaterialIcon.stories.js +201 -0
- package/dist/components/stories/KvPageContainer.stories.js +50 -0
- package/dist/components/stories/KvPagination.stories.js +70 -0
- package/dist/components/stories/KvPieChart.stories.js +47 -0
- package/dist/components/stories/KvProgressBar.stories.js +53 -0
- package/dist/components/stories/KvRadio.stories.js +140 -0
- package/dist/components/stories/KvSelect.stories.js +125 -0
- package/dist/components/stories/KvSideSheet.stories.js +50 -0
- package/dist/components/stories/KvSwitch.stories.js +66 -0
- package/dist/components/stories/KvTabs.stories.js +106 -0
- package/dist/components/stories/KvTextInput.stories.js +194 -0
- package/dist/components/stories/KvTextLink.stories.js +55 -0
- package/dist/components/stories/KvThemeProvider.stories.js +178 -0
- package/dist/components/stories/KvToast.stories.js +117 -0
- package/dist/components/stories/KvTooltip.stories.js +26 -0
- package/dist/components/stories/KvTreeMapChart.stories.js +42 -0
- package/dist/components/stories/KvUserAvatar.stories.js +47 -0
- package/dist/components/stories/KvVerticalCarousel.stories.js +168 -0
- package/dist/components/stories/KvVotingCard.stories.js +33 -0
- package/dist/components/stories/KvVotingCardV2.stories.js +89 -0
- package/dist/components/stories/KvWideLoanCard.stories.js +292 -0
- package/dist/components/stories/StyleguidePrimitives.stories.js +499 -0
- package/dist/components/stories/StyleguideProse.stories.js +215 -0
- package/dist/data/countries-borders.json +1 -0
- package/dist/data/ne_110m_admin_0_countries.json +1 -0
- package/dist/utils/Alea.js +9 -0
- package/dist/utils/attrs.js +7 -0
- package/dist/utils/carousels.js +8 -0
- package/dist/{attrs.js → utils/chunk-3HK4G4NT.js} +1 -0
- package/dist/{loanCard.js → utils/chunk-55HF2ORX.js} +1 -0
- package/dist/{expander.js → utils/chunk-AY3PR5S4.js} +3 -2
- package/dist/{carousels.js → utils/chunk-AZPWOFD5.js} +1 -0
- package/dist/{printing.js → utils/chunk-B5J5WLAH.js} +1 -0
- package/dist/{Alea.js → utils/chunk-GPSH6OPA.js} +2 -1
- package/dist/{scrollLock.js → utils/chunk-HIY5IW65.js} +2 -1
- package/dist/{treemap.js → utils/chunk-MSMZIN54.js} +1 -0
- package/dist/{imageUtils.js → utils/chunk-OXJCCNNW.js} +1 -0
- package/dist/{touchEvents.js → utils/chunk-S3MABILA.js} +3 -2
- package/dist/{mapUtils.js → utils/chunk-VIGEMAKO.js} +5 -4
- package/dist/utils/chunk-YCNMJ4YV.js +37 -0
- package/dist/{loanUtils.js → utils/chunk-YFEC5ODJ.js} +7 -6
- package/dist/utils/expander.js +9 -0
- package/dist/utils/imageUtils.js +9 -0
- package/dist/utils/index.cjs +1118 -0
- package/dist/utils/index.js +166 -0
- package/dist/utils/loanCard.js +9 -0
- package/dist/utils/loanUtils.js +23 -0
- package/dist/utils/mapUtils.js +15 -0
- package/dist/utils/printing.js +9 -0
- package/dist/utils/scrollLock.js +13 -0
- package/dist/{throttle.js → utils/throttle.js} +1 -0
- package/dist/utils/touchEvents.js +11 -0
- package/dist/utils/treemap.js +7 -0
- package/package.json +7 -7
- package/utils/index.js +14 -0
- package/index.js +0 -3
- /package/dist/{Alea.cjs → utils/Alea.cjs} +0 -0
- /package/dist/{attrs.cjs → utils/attrs.cjs} +0 -0
- /package/dist/{carousels.cjs → utils/carousels.cjs} +0 -0
- /package/dist/{chunk-HV3AUBFT.js → utils/chunk-HV3AUBFT.js} +0 -0
- /package/dist/{expander.cjs → utils/expander.cjs} +0 -0
- /package/dist/{imageUtils.cjs → utils/imageUtils.cjs} +0 -0
- /package/dist/{loanCard.cjs → utils/loanCard.cjs} +0 -0
- /package/dist/{loanUtils.cjs → utils/loanUtils.cjs} +0 -0
- /package/dist/{mapUtils.cjs → utils/mapUtils.cjs} +0 -0
- /package/dist/{printing.cjs → utils/printing.cjs} +0 -0
- /package/dist/{scrollLock.cjs → utils/scrollLock.cjs} +0 -0
- /package/dist/{throttle.cjs → utils/throttle.cjs} +0 -0
- /package/dist/{touchEvents.cjs → utils/touchEvents.cjs} +0 -0
- /package/dist/{treemap.cjs → utils/treemap.cjs} +0 -0
|
@@ -0,0 +1,68 @@
|
|
|
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);
|
|
63
|
+
|
|
64
|
+
export const Square = story({
|
|
65
|
+
...props,
|
|
66
|
+
aspectRatio: 1,
|
|
67
|
+
defaultImage: { width: 300 },
|
|
68
|
+
});
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import KvButton from '../KvButton.vue';
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
title: 'KvButton',
|
|
5
|
+
component: KvButton,
|
|
6
|
+
argTypes: {
|
|
7
|
+
variant: {
|
|
8
|
+
control: {
|
|
9
|
+
type: 'select',
|
|
10
|
+
options: ['primary', 'secondary', 'link', 'danger', 'ghost', 'caution'],
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
state: {
|
|
14
|
+
control: {
|
|
15
|
+
type: 'select',
|
|
16
|
+
options: ['', 'disabled', 'loading'],
|
|
17
|
+
defaultValue: null,
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const Template = (args, { argTypes }) => ({
|
|
24
|
+
props: Object.keys(argTypes),
|
|
25
|
+
components: { KvButton },
|
|
26
|
+
template: `
|
|
27
|
+
<kv-button
|
|
28
|
+
:variant="variant"
|
|
29
|
+
:state="state"
|
|
30
|
+
:to="to"
|
|
31
|
+
:href="href"
|
|
32
|
+
@click="onClick"
|
|
33
|
+
>
|
|
34
|
+
Find a borrower
|
|
35
|
+
</kv-button>`,
|
|
36
|
+
methods: {
|
|
37
|
+
onClick(e) { console.log(e); },
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
const VariantTemplate = (args, { argTypes }) => ({
|
|
42
|
+
props: Object.keys(argTypes),
|
|
43
|
+
components: { KvButton },
|
|
44
|
+
template: `
|
|
45
|
+
<ul>
|
|
46
|
+
<li
|
|
47
|
+
v-for="variant in ['primary', 'secondary', 'link', 'danger', 'ghost', 'caution']"
|
|
48
|
+
:key="variant"
|
|
49
|
+
class="tw-mb-2"
|
|
50
|
+
>
|
|
51
|
+
<kv-button
|
|
52
|
+
:variant="variant"
|
|
53
|
+
:state="state"
|
|
54
|
+
:to="to"
|
|
55
|
+
:href="href"
|
|
56
|
+
>
|
|
57
|
+
Find a borrower
|
|
58
|
+
</kv-button>
|
|
59
|
+
</li>
|
|
60
|
+
</ul>`,
|
|
61
|
+
methods: {
|
|
62
|
+
onClick(e) { console.log(e); },
|
|
63
|
+
},
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
// Variants
|
|
67
|
+
export const VariantPrimary = Template.bind({});
|
|
68
|
+
VariantPrimary.args = {
|
|
69
|
+
variant: 'primary',
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
export const VariantSecondary = Template.bind({});
|
|
73
|
+
VariantSecondary.args = {
|
|
74
|
+
variant: 'secondary',
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
export const VariantDanger = Template.bind({});
|
|
78
|
+
VariantDanger.args = {
|
|
79
|
+
variant: 'danger',
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
export const VariantLink = Template.bind({});
|
|
83
|
+
VariantLink.args = {
|
|
84
|
+
variant: 'link',
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
export const VariantGhost = Template.bind({});
|
|
88
|
+
VariantGhost.args = {
|
|
89
|
+
variant: 'ghost',
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
export const VariantCaution = Template.bind({});
|
|
93
|
+
VariantCaution.args = {
|
|
94
|
+
variant: 'caution',
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
// States
|
|
98
|
+
export const StateLoading = VariantTemplate.bind({});
|
|
99
|
+
StateLoading.args = {
|
|
100
|
+
state: 'loading',
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
export const StateActive = VariantTemplate.bind({});
|
|
104
|
+
StateActive.args = {
|
|
105
|
+
state: 'active',
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
export const StateDisabled = VariantTemplate.bind({});
|
|
109
|
+
StateDisabled.args = {
|
|
110
|
+
state: 'disabled',
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
// Misc
|
|
114
|
+
export const WithHref = VariantTemplate.bind({});
|
|
115
|
+
WithHref.args = {
|
|
116
|
+
href: 'https://www.google.com',
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
export const FullWidth = (args, { argTypes }) => ({
|
|
120
|
+
props: Object.keys(argTypes),
|
|
121
|
+
components: { KvButton },
|
|
122
|
+
template: `
|
|
123
|
+
<ul>
|
|
124
|
+
<li
|
|
125
|
+
v-for="variant in ['primary', 'secondary', 'link', 'danger', 'ghost', 'caution']"
|
|
126
|
+
:key="variant"
|
|
127
|
+
class="tw-mb-2"
|
|
128
|
+
>
|
|
129
|
+
<kv-button
|
|
130
|
+
class="tw-w-full"
|
|
131
|
+
:variant="variant"
|
|
132
|
+
:state="state"
|
|
133
|
+
:to="to"
|
|
134
|
+
:href="href"
|
|
135
|
+
@click="onClick"
|
|
136
|
+
>
|
|
137
|
+
Find a borrower
|
|
138
|
+
</kv-button>
|
|
139
|
+
</li>
|
|
140
|
+
</ul>`,
|
|
141
|
+
methods: {
|
|
142
|
+
onClick(e) { console.log(e); },
|
|
143
|
+
},
|
|
144
|
+
});
|
|
@@ -0,0 +1,426 @@
|
|
|
1
|
+
import KvCarousel from '../KvCarousel.vue';
|
|
2
|
+
import KvLoadingSpinner from '../KvLoadingSpinner.vue';
|
|
3
|
+
import KvButton from '../KvButton.vue';
|
|
4
|
+
|
|
5
|
+
const randomHexColor = (index) => {
|
|
6
|
+
const defaultColor = '96d4b3';
|
|
7
|
+
const colorArray = [
|
|
8
|
+
'D5573B',
|
|
9
|
+
'885053',
|
|
10
|
+
'777DA7',
|
|
11
|
+
'94C9A9',
|
|
12
|
+
'C6ECAE',
|
|
13
|
+
'C490D1',
|
|
14
|
+
'A0D2DB',
|
|
15
|
+
'7D8CC4',
|
|
16
|
+
'726DA8',
|
|
17
|
+
];
|
|
18
|
+
return colorArray?.[index] || defaultColor;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
// This is not an actual loan card template, just a vague
|
|
22
|
+
// approximation to make testing in the stories nicer
|
|
23
|
+
const generateLoanCardTemplate = (index) => {
|
|
24
|
+
const amounts = [
|
|
25
|
+
'100',
|
|
26
|
+
'2,255',
|
|
27
|
+
'50',
|
|
28
|
+
'41,900',
|
|
29
|
+
];
|
|
30
|
+
const cardCopy = [
|
|
31
|
+
'A loan of $5,450 helps a member to buy flour, eggs, lard, sugar, sweets and other...',
|
|
32
|
+
'A loan of $1,125 helps to face the financial problem of covering tuition fees.',
|
|
33
|
+
'A loan of $450 helps to purchase store goods for resale.',
|
|
34
|
+
];
|
|
35
|
+
|
|
36
|
+
return `
|
|
37
|
+
<div style="width: 336px">
|
|
38
|
+
<img src="https://placehold.co/336x252/${randomHexColor(index)}/000000" class="tw-w-full tw-rounded tw-mb-2">
|
|
39
|
+
<h3>Card Title</h3>
|
|
40
|
+
<h4 class="tw-my-1">$${amounts?.[index] || amounts?.[1]} to go</h4>
|
|
41
|
+
<p class="tw-mt-1 tw-mb-9">${cardCopy?.[index] || cardCopy?.[1]}</p>
|
|
42
|
+
<kv-button
|
|
43
|
+
variant="primary"
|
|
44
|
+
>
|
|
45
|
+
Read more
|
|
46
|
+
</kv-button>
|
|
47
|
+
</div>`;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
const defaultCarouselSlides = `
|
|
51
|
+
<template #slide1>
|
|
52
|
+
<img src="https://placehold.co/300x220/${randomHexColor(1)}/000000" class="tw-w-full">
|
|
53
|
+
</template>
|
|
54
|
+
<template #slide2>
|
|
55
|
+
<img src="https://placehold.co/300x220/${randomHexColor(2)}/000000" class="tw-w-full">
|
|
56
|
+
</template>
|
|
57
|
+
<template #slide3>
|
|
58
|
+
<img src="https://placehold.co/300x220/${randomHexColor(3)}/000000" class="tw-w-full">
|
|
59
|
+
</template>
|
|
60
|
+
<template #slide4>
|
|
61
|
+
<img src="https://placehold.co/300x220/${randomHexColor(4)}/000000" class="tw-w-full">
|
|
62
|
+
</template>
|
|
63
|
+
`;
|
|
64
|
+
|
|
65
|
+
export default {
|
|
66
|
+
title: 'KvCarousel',
|
|
67
|
+
component: KvCarousel,
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
export const Default = () => ({
|
|
71
|
+
components: {
|
|
72
|
+
KvCarousel,
|
|
73
|
+
},
|
|
74
|
+
template: `
|
|
75
|
+
<kv-carousel style="max-width: 400px;">
|
|
76
|
+
${defaultCarouselSlides}
|
|
77
|
+
</kv-carousel>
|
|
78
|
+
`,
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
export const LoopFalse = () => ({
|
|
82
|
+
components: {
|
|
83
|
+
KvCarousel,
|
|
84
|
+
},
|
|
85
|
+
template: `
|
|
86
|
+
<kv-carousel style="max-width: 400px;" :embla-options="{ loop: false }">
|
|
87
|
+
${defaultCarouselSlides}
|
|
88
|
+
</kv-carousel>
|
|
89
|
+
`,
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
export const MultipleLoanCards = () => ({
|
|
93
|
+
components: {
|
|
94
|
+
KvCarousel,
|
|
95
|
+
KvButton,
|
|
96
|
+
},
|
|
97
|
+
template: `
|
|
98
|
+
<kv-carousel
|
|
99
|
+
:embla-options="{ loop: false }"
|
|
100
|
+
:multiple-slides-visible="true"
|
|
101
|
+
style="max-width: 600px;"
|
|
102
|
+
class="tw-w-full"
|
|
103
|
+
>
|
|
104
|
+
<template #slide1>
|
|
105
|
+
${generateLoanCardTemplate(1)}
|
|
106
|
+
</template>
|
|
107
|
+
<template #slide2>
|
|
108
|
+
${generateLoanCardTemplate(2)}
|
|
109
|
+
</template>
|
|
110
|
+
<template #slide3>
|
|
111
|
+
${generateLoanCardTemplate(3)}
|
|
112
|
+
</template>
|
|
113
|
+
<template #slide4>
|
|
114
|
+
${generateLoanCardTemplate(4)}
|
|
115
|
+
</template>
|
|
116
|
+
<template #slide5>
|
|
117
|
+
${generateLoanCardTemplate(5)}
|
|
118
|
+
</template>
|
|
119
|
+
</kv-carousel>
|
|
120
|
+
`,
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
export const MultipleLoanCards2 = () => ({
|
|
124
|
+
components: {
|
|
125
|
+
KvCarousel,
|
|
126
|
+
KvButton,
|
|
127
|
+
},
|
|
128
|
+
template: `
|
|
129
|
+
<kv-carousel
|
|
130
|
+
:embla-options="{ loop: false }"
|
|
131
|
+
:multiple-slides-visible="true"
|
|
132
|
+
slides-to-scroll="visible"
|
|
133
|
+
style="max-width: 1072px;"
|
|
134
|
+
class="tw-w-full"
|
|
135
|
+
>
|
|
136
|
+
<template #slide1>
|
|
137
|
+
${generateLoanCardTemplate(1)}
|
|
138
|
+
</template>
|
|
139
|
+
<template #slide2>
|
|
140
|
+
${generateLoanCardTemplate(2)}
|
|
141
|
+
</template>
|
|
142
|
+
<template #slide3>
|
|
143
|
+
${generateLoanCardTemplate(3)}
|
|
144
|
+
</template>
|
|
145
|
+
<template #slide4>
|
|
146
|
+
${generateLoanCardTemplate(4)}
|
|
147
|
+
</template>
|
|
148
|
+
<template #slide5>
|
|
149
|
+
${generateLoanCardTemplate(5)}
|
|
150
|
+
</template>
|
|
151
|
+
<template #slide6>
|
|
152
|
+
${generateLoanCardTemplate(6)}
|
|
153
|
+
</template>
|
|
154
|
+
<template #slide7>
|
|
155
|
+
${generateLoanCardTemplate(7)}
|
|
156
|
+
</template>
|
|
157
|
+
<template #slide8>
|
|
158
|
+
${generateLoanCardTemplate(8)}
|
|
159
|
+
</template>
|
|
160
|
+
<template #slide9>
|
|
161
|
+
${generateLoanCardTemplate(9)}
|
|
162
|
+
</template>
|
|
163
|
+
</kv-carousel>
|
|
164
|
+
`,
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
export const MultipleLoanCardsReInit = () => ({
|
|
168
|
+
components: {
|
|
169
|
+
KvCarousel,
|
|
170
|
+
KvButton,
|
|
171
|
+
},
|
|
172
|
+
template: `
|
|
173
|
+
<div data-testid="carousel-container">
|
|
174
|
+
<kv-carousel
|
|
175
|
+
ref="myCarouselRef"
|
|
176
|
+
:multiple-slides-visible="true"
|
|
177
|
+
slides-to-scroll="visible"
|
|
178
|
+
style="max-width: 800px;"
|
|
179
|
+
>
|
|
180
|
+
<template #slide1>
|
|
181
|
+
${generateLoanCardTemplate(1)}
|
|
182
|
+
</template>
|
|
183
|
+
<template #slide2>
|
|
184
|
+
${generateLoanCardTemplate(2)}
|
|
185
|
+
</template>
|
|
186
|
+
<template #slide3>
|
|
187
|
+
${generateLoanCardTemplate(3)}
|
|
188
|
+
</template>
|
|
189
|
+
<template #slide4>
|
|
190
|
+
${generateLoanCardTemplate(4)}
|
|
191
|
+
</template>
|
|
192
|
+
<template #slide5>
|
|
193
|
+
${generateLoanCardTemplate(5)}
|
|
194
|
+
</template>
|
|
195
|
+
<template #slide6>
|
|
196
|
+
${generateLoanCardTemplate(6)}
|
|
197
|
+
</template>
|
|
198
|
+
<template #slide7>
|
|
199
|
+
${generateLoanCardTemplate(7)}
|
|
200
|
+
</template>
|
|
201
|
+
<template #slide8>
|
|
202
|
+
${generateLoanCardTemplate(8)}
|
|
203
|
+
</template>
|
|
204
|
+
</kv-carousel>
|
|
205
|
+
<kv-button @click.native.prevent="removeSlide()" role="removeSlideButton">Remove Slide</kv-button>
|
|
206
|
+
<p>Slide Count: {{ slideCount }} | Indicator Count: {{ slideIndicatorCount }} | Removed Slides: {{ removedSlides.length }}</p>
|
|
207
|
+
</div>
|
|
208
|
+
`,
|
|
209
|
+
data() {
|
|
210
|
+
return {
|
|
211
|
+
removedSlides: [],
|
|
212
|
+
slideCount: null,
|
|
213
|
+
slideIndicatorCount: null,
|
|
214
|
+
};
|
|
215
|
+
},
|
|
216
|
+
mounted() {
|
|
217
|
+
this.$nextTick(() => {
|
|
218
|
+
this.slideCount = this.$refs?.myCarouselRef?.slides?.length;
|
|
219
|
+
this.slideIndicatorCount = this.$refs?.myCarouselRef?.slideIndicatorCount;
|
|
220
|
+
});
|
|
221
|
+
},
|
|
222
|
+
methods: {
|
|
223
|
+
removeSlide() {
|
|
224
|
+
// Fetch slides + remove one
|
|
225
|
+
const slides = this.$refs?.myCarouselRef?.embla?.slideNodes();
|
|
226
|
+
const slideToRemove = slides.pop();
|
|
227
|
+
this.removedSlides.push(slideToRemove);
|
|
228
|
+
this.$refs?.myCarouselRef?.embla?.containerNode()?.removeChild(slideToRemove);
|
|
229
|
+
// Call our component reInit method
|
|
230
|
+
this.$refs?.myCarouselRef?.reInit();
|
|
231
|
+
// Update values for reflection in story
|
|
232
|
+
this.slideCount = this.$refs?.myCarouselRef?.slides?.length;
|
|
233
|
+
this.selectedIndexCheck = this.$refs?.myCarouselRef?.currentIndex;
|
|
234
|
+
this.slideIndicatorCount = this.$refs?.myCarouselRef?.slideIndicatorCount;
|
|
235
|
+
},
|
|
236
|
+
},
|
|
237
|
+
});
|
|
238
|
+
|
|
239
|
+
export const loadingLoanCardExample = () => ({
|
|
240
|
+
components: {
|
|
241
|
+
KvCarousel,
|
|
242
|
+
KvLoadingSpinner,
|
|
243
|
+
KvButton,
|
|
244
|
+
},
|
|
245
|
+
data() {
|
|
246
|
+
return {
|
|
247
|
+
loan2Loaded: false,
|
|
248
|
+
loan3Loaded: false,
|
|
249
|
+
};
|
|
250
|
+
},
|
|
251
|
+
template: `
|
|
252
|
+
<kv-carousel
|
|
253
|
+
:embla-options="{ loop: false }"
|
|
254
|
+
:multiple-slides-visible="false"
|
|
255
|
+
style="max-width: 336px;"
|
|
256
|
+
@change="onCarouselSlideChange"
|
|
257
|
+
>
|
|
258
|
+
<template #slide1>
|
|
259
|
+
${generateLoanCardTemplate(1)}
|
|
260
|
+
</template>
|
|
261
|
+
<template #slide2>
|
|
262
|
+
<div style="width: 336px">
|
|
263
|
+
<div v-if="loan2Loaded">
|
|
264
|
+
Loan card goes here
|
|
265
|
+
</div>
|
|
266
|
+
<div v-else
|
|
267
|
+
style="display: flex; align-items: center; justify-content: center; position: absolute; top: 0; bottom: 0; right: 0; left: 0;"
|
|
268
|
+
>
|
|
269
|
+
<kv-loading-spinner color="black" size="small" />
|
|
270
|
+
</div>
|
|
271
|
+
</div>
|
|
272
|
+
</template>
|
|
273
|
+
<template #slide3>
|
|
274
|
+
<div style="width: 336px">
|
|
275
|
+
<div v-if="loan3Loaded">
|
|
276
|
+
Loan card goes here
|
|
277
|
+
</div>
|
|
278
|
+
<div v-else
|
|
279
|
+
style="display: flex; align-items: center; justify-content: center; position: absolute; top: 0; bottom: 0; right: 0; left: 0;"
|
|
280
|
+
>
|
|
281
|
+
<kv-loading-spinner color="black" size="small" />
|
|
282
|
+
</div>
|
|
283
|
+
</div>
|
|
284
|
+
</template>
|
|
285
|
+
</kv-carousel>
|
|
286
|
+
`,
|
|
287
|
+
methods: {
|
|
288
|
+
onCarouselSlideChange(slideIndex) {
|
|
289
|
+
console.log(`carousel changed to slide: ${slideIndex}`);
|
|
290
|
+
console.log('start fetching the next indexes loan data now');
|
|
291
|
+
},
|
|
292
|
+
},
|
|
293
|
+
});
|
|
294
|
+
|
|
295
|
+
export const ResponsiveSlides = () => ({
|
|
296
|
+
components: {
|
|
297
|
+
KvCarousel,
|
|
298
|
+
KvButton,
|
|
299
|
+
},
|
|
300
|
+
template: `
|
|
301
|
+
<kv-carousel
|
|
302
|
+
:embla-options="{ loop: false }"
|
|
303
|
+
:multiple-slides-visible="true"
|
|
304
|
+
slides-to-scroll="visible"
|
|
305
|
+
style="max-width: 1072px;"
|
|
306
|
+
class="tw-w-full"
|
|
307
|
+
slide-max-width="32.5rem"
|
|
308
|
+
>
|
|
309
|
+
${defaultCarouselSlides}
|
|
310
|
+
</kv-carousel>
|
|
311
|
+
`,
|
|
312
|
+
});
|
|
313
|
+
|
|
314
|
+
export const CustomStartIndex = () => ({
|
|
315
|
+
components: {
|
|
316
|
+
KvCarousel,
|
|
317
|
+
KvButton,
|
|
318
|
+
},
|
|
319
|
+
template: `
|
|
320
|
+
<kv-carousel
|
|
321
|
+
:embla-options="{ loop: false, align: 'center', startIndex: 1 }"
|
|
322
|
+
:multiple-slides-visible="true"
|
|
323
|
+
slides-to-scroll="visible"
|
|
324
|
+
style="max-width: 1072px;"
|
|
325
|
+
>
|
|
326
|
+
<template #slide1>
|
|
327
|
+
${generateLoanCardTemplate(1)}
|
|
328
|
+
</template>
|
|
329
|
+
<template #slide2>
|
|
330
|
+
${generateLoanCardTemplate(2)}
|
|
331
|
+
</template>
|
|
332
|
+
<template #slide3>
|
|
333
|
+
${generateLoanCardTemplate(3)}
|
|
334
|
+
</template>
|
|
335
|
+
<template #slide4>
|
|
336
|
+
${generateLoanCardTemplate(4)}
|
|
337
|
+
</template>
|
|
338
|
+
<template #slide5>
|
|
339
|
+
${generateLoanCardTemplate(5)}
|
|
340
|
+
</template>
|
|
341
|
+
<template #slide6>
|
|
342
|
+
${generateLoanCardTemplate(6)}
|
|
343
|
+
</template>
|
|
344
|
+
<template #slide7>
|
|
345
|
+
${generateLoanCardTemplate(7)}
|
|
346
|
+
</template>
|
|
347
|
+
<template #slide8>
|
|
348
|
+
${generateLoanCardTemplate(8)}
|
|
349
|
+
</template>
|
|
350
|
+
<template #slide9>
|
|
351
|
+
${generateLoanCardTemplate(9)}
|
|
352
|
+
</template>
|
|
353
|
+
</kv-carousel>
|
|
354
|
+
`,
|
|
355
|
+
});
|
|
356
|
+
|
|
357
|
+
export const AsideControls = () => ({
|
|
358
|
+
components: {
|
|
359
|
+
KvCarousel,
|
|
360
|
+
KvButton,
|
|
361
|
+
},
|
|
362
|
+
template: `
|
|
363
|
+
<kv-carousel
|
|
364
|
+
:embla-options="{ loop: false }"
|
|
365
|
+
:multiple-slides-visible="true"
|
|
366
|
+
:aside-controls="true"
|
|
367
|
+
slides-to-scroll="visible"
|
|
368
|
+
class="tw-w-full"
|
|
369
|
+
>
|
|
370
|
+
<template #slide1>
|
|
371
|
+
${generateLoanCardTemplate(1)}
|
|
372
|
+
</template>
|
|
373
|
+
<template #slide2>
|
|
374
|
+
${generateLoanCardTemplate(2)}
|
|
375
|
+
</template>
|
|
376
|
+
<template #slide3>
|
|
377
|
+
${generateLoanCardTemplate(3)}
|
|
378
|
+
</template>
|
|
379
|
+
<template #slide4>
|
|
380
|
+
${generateLoanCardTemplate(4)}
|
|
381
|
+
</template>
|
|
382
|
+
<template #slide5>
|
|
383
|
+
${generateLoanCardTemplate(5)}
|
|
384
|
+
</template>
|
|
385
|
+
<template #slide6>
|
|
386
|
+
${generateLoanCardTemplate(6)}
|
|
387
|
+
</template>
|
|
388
|
+
<template #slide7>
|
|
389
|
+
${generateLoanCardTemplate(7)}
|
|
390
|
+
</template>
|
|
391
|
+
<template #slide8>
|
|
392
|
+
${generateLoanCardTemplate(8)}
|
|
393
|
+
</template>
|
|
394
|
+
</kv-carousel>
|
|
395
|
+
`,
|
|
396
|
+
});
|
|
397
|
+
|
|
398
|
+
export const Dotted = () => ({
|
|
399
|
+
components: {
|
|
400
|
+
KvCarousel,
|
|
401
|
+
},
|
|
402
|
+
template: `
|
|
403
|
+
<kv-carousel
|
|
404
|
+
style="max-width: 400px;"
|
|
405
|
+
:is-dotted="true"
|
|
406
|
+
>
|
|
407
|
+
${defaultCarouselSlides}
|
|
408
|
+
</kv-carousel>
|
|
409
|
+
`,
|
|
410
|
+
});
|
|
411
|
+
|
|
412
|
+
export const ThreeDimensional = () => ({
|
|
413
|
+
components: {
|
|
414
|
+
KvCarousel,
|
|
415
|
+
},
|
|
416
|
+
template: `
|
|
417
|
+
<kv-carousel
|
|
418
|
+
:embla-options="{ loop: false, align: 'center' }"
|
|
419
|
+
style="max-width: 600px;"
|
|
420
|
+
:is-dotted="true"
|
|
421
|
+
:in-circle="true"
|
|
422
|
+
>
|
|
423
|
+
${defaultCarouselSlides}
|
|
424
|
+
</kv-carousel>
|
|
425
|
+
`,
|
|
426
|
+
});
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import KvCartModal from '../KvCartModal.vue';
|
|
2
|
+
import KvButton from '../KvButton.vue';
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
title: 'KvCartModal',
|
|
6
|
+
component: KvCartModal,
|
|
7
|
+
parameters: {
|
|
8
|
+
layout: 'fullscreen',
|
|
9
|
+
},
|
|
10
|
+
args: {
|
|
11
|
+
visible: true,
|
|
12
|
+
title: '',
|
|
13
|
+
preventClose: false,
|
|
14
|
+
addedLoan: {
|
|
15
|
+
name: 'This is a Loan with a very long name',
|
|
16
|
+
amount: 100,
|
|
17
|
+
country: 'Kenya',
|
|
18
|
+
imageHash: '9673d0722a7675b9b8d11f90849d9b44',
|
|
19
|
+
},
|
|
20
|
+
photoPath: 'https://www-kiva-org.freetls.fastly.net/img/',
|
|
21
|
+
basketCount: 1,
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const DefaultTemplate = (args, { argTypes }) => ({
|
|
26
|
+
props: Object.keys(argTypes),
|
|
27
|
+
components: { KvCartModal, KvButton },
|
|
28
|
+
template: `
|
|
29
|
+
<div>
|
|
30
|
+
<kv-button @click="isVisible = true;">Show cart modal</kv-button>
|
|
31
|
+
<p>The lightbox is visible: {{isVisible}}</p>
|
|
32
|
+
|
|
33
|
+
<kv-cart-modal
|
|
34
|
+
:visible="isVisible"
|
|
35
|
+
:prevent-close="preventClose"
|
|
36
|
+
:added-loan="addedLoan"
|
|
37
|
+
:photo-path="photoPath"
|
|
38
|
+
:basket-count="basketCount"
|
|
39
|
+
@cart-modal-closed="isVisible = false"
|
|
40
|
+
>
|
|
41
|
+
</kv-cart-modal>
|
|
42
|
+
</div>
|
|
43
|
+
`,
|
|
44
|
+
data() {
|
|
45
|
+
return {
|
|
46
|
+
isVisible: args.visible,
|
|
47
|
+
};
|
|
48
|
+
},
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
export const Lightbox = DefaultTemplate.bind({});
|
|
52
|
+
Lightbox.args = {
|
|
53
|
+
title: 'Added to Basket',
|
|
54
|
+
};
|