-
Notifications
You must be signed in to change notification settings - Fork 8
feat: [MP-2376] - impact insights modal feature #6599
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
91bee78
feat: [MP-2376] - done events and impact insights modal feature
cristhianDt d361e0b
feat: [MP-2376] - use carousel ref instead of prop drilling
cristhianDt aeaa463
feat: [MP-2376] - clean code
cristhianDt c5f22f1
feat: [MP-2375] - fixed mobile design
cristhianDt ab2dd81
feat: [MP-2376] - better option to locate secondary buttons
cristhianDt fa3c0c1
Merge branch 'main' into feature/mp-2376
cristhianDt 238cb58
feat: [MP-2375] - remove comments
cristhianDt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| import MyKivaImpactInsightModal from '#src/components/MyKiva/ImpactInsight/MyKivaImpactInsightModal.vue'; | ||
|
|
||
| export default { | ||
| title: 'MyKiva/ImpactInsight/ImpactInsightModal', | ||
| component: MyKivaImpactInsightModal, | ||
| }; | ||
|
|
||
| const story = (args) => { | ||
| const template = (_args, { argTypes }) => ({ | ||
| props: Object.keys(argTypes), | ||
| components: { MyKivaImpactInsightModal }, | ||
| setup() { return { args }; }, | ||
| template: ` | ||
| <div> | ||
| <MyKivaImpactInsightModal | ||
| v-bind="args" | ||
| /> | ||
| </div> | ||
| `, | ||
| }); | ||
| template.args = args; | ||
| return template; | ||
| }; | ||
|
|
||
| export const Default = story({ | ||
| visible: true, | ||
| latestLoan: { | ||
| id: 1975833, | ||
| name: 'Mayram', | ||
| image: { | ||
| hash: '9673d0722a7675b9b8d11f90849d9b44', | ||
| }, | ||
| geocode: { | ||
| country: { | ||
| geocode:{ | ||
| latitude: -16, | ||
| longitude: 167 | ||
| }, | ||
| id: 231, | ||
| isoCode: 'VU', | ||
| name: 'Vanuatu', | ||
| ppp: '$89,599' | ||
| } | ||
| }, | ||
| amount: 100, | ||
| whySpecial: 'She is a community leader.', | ||
| gender: 'female', | ||
| otherLoans: [], | ||
| amount: '-75.00' | ||
| }, | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
226 changes: 226 additions & 0 deletions
226
src/components/MyKiva/ImpactInsight/MyKivaImpactInsightModal.vue
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,226 @@ | ||
| <template> | ||
| <KvLightbox | ||
| :visible="show" | ||
| title="" | ||
| @lightbox-closed="handleClose" | ||
| class="impact-insight-modal" | ||
| > | ||
| <template #header> | ||
| <h2 | ||
| v-if="!isMobile" | ||
| class="tw-mb-3 !tw-text-left" | ||
| > | ||
| A closer look at <u>{{ borrowerName }} world</u> | ||
| </h2> | ||
| </template> | ||
| <h2 | ||
| v-if="isMobile" | ||
| class="tw-mb-3 !tw-text-left" | ||
| > | ||
| A closer look at <u>{{ borrowerName }} world</u> | ||
| </h2> | ||
| <div class="tw-flex tw-flex-col tw-items-center tw-w-full md:!tw-relative"> | ||
| <KvCarousel | ||
| ref="carouselRef" | ||
| :is-dotted="true" | ||
| :new-index="carouselIndex" | ||
| :slide-max-width="''" | ||
| :controls-top-right="false" | ||
| :multiple-slides-visible="false" | ||
| :embla-options="{ loop: false, startIndex: 0 }" | ||
| class="impact-insight-carousel" | ||
| @change="handleUserInteraction" | ||
| > | ||
| <template #slide1> | ||
| <MyKivaImpactInsightScreen1 :latest-loan="latestLoan" /> | ||
| </template> | ||
| <template #slide2> | ||
| <MyKivaImpactInsightScreen2 :latest-loan="latestLoan" /> | ||
| </template> | ||
| <template #slide3> | ||
| <MyKivaImpactInsightScreen3 :latest-loan="latestLoan" /> | ||
| </template> | ||
| <template #slide4> | ||
| <MyKivaImpactInsightScreen4 :latest-loan="latestLoan" /> | ||
| </template> | ||
| </KvCarousel> | ||
|
|
||
| <div | ||
| class="tw-static tw-w-full md:tw-w-auto md:tw-absolute tw-self-end tw-bottom-0" | ||
| > | ||
| <div | ||
| class="tw-relative tw-justify-end tw-items-end tw-gap-1.5 tw-w-xs impact-insight-footer" | ||
| > | ||
| <div | ||
| class="tw-flex tw-justify-self-end tw-w-full tw-h-6 | ||
| tw-gap-2 tw-float-end secondary-navigation-buttons" | ||
| > | ||
| <button | ||
| v-if="currentSlide > 0 && !isMobile" | ||
| class="tw-w-11 tw-text-center tw-border tw-rounded-lg | ||
| tw-bg-white tw-text-gray-900 tw-font-medium" | ||
| :disabled="currentSlide === 0" | ||
| @click="goToPrev" | ||
| > | ||
| Back | ||
| </button> | ||
| <button | ||
| class="tw-w-full md:tw-w-11 tw-text-center tw-rounded-lg tw-bg-action tw-text-white | ||
| tw-font-medium hover:tw-bg-action-highlight" | ||
| @click="handleNextOrDone" | ||
| > | ||
| {{ isLastSlide ? 'Done' : 'Next' }} | ||
| </button> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| </KvLightbox> | ||
| </template> | ||
|
|
||
| <script setup lang="ts"> | ||
| import { | ||
| ref, computed, defineProps, defineEmits, | ||
| inject, onMounted | ||
| } from 'vue'; | ||
|
|
||
| import { KvLightbox, KvCarousel } from '@kiva/kv-components'; | ||
|
|
||
| import useBreakpoints from '#src/composables/useBreakpoints'; | ||
| import { formatPossessiveName } from '#src/util/stringParserUtils'; | ||
| import MyKivaImpactInsightScreen1 from './MyKivaImpactInsightScreen1'; | ||
| import MyKivaImpactInsightScreen2 from './MyKivaImpactInsightScreen2'; | ||
| import MyKivaImpactInsightScreen3 from './MyKivaImpactInsightScreen3'; | ||
| import MyKivaImpactInsightScreen4 from './MyKivaImpactInsightScreen4'; | ||
|
|
||
| const props = defineProps({ | ||
| show: { | ||
| type: Boolean, | ||
| default: false, | ||
| }, | ||
| latestLoan: { | ||
| type: Object, | ||
| default: null, | ||
| }, | ||
| }); | ||
|
|
||
| const emit = defineEmits(['close']); | ||
| const $kvTrackEvent = inject('$kvTrackEvent'); | ||
|
|
||
| const currentSlide = ref(0); | ||
| const carouselRef = ref(null); | ||
|
|
||
| const totalSlides = 4; | ||
| const { isMobile } = useBreakpoints(); | ||
|
|
||
| const borrowerName = computed(() => { | ||
| return formatPossessiveName(props.latestLoan?.name) || ''; | ||
| }); | ||
|
|
||
| const isLastSlide = computed(() => currentSlide.value === totalSlides - 1); | ||
|
|
||
| const handleTrackEvent = () => { | ||
| $kvTrackEvent('portfolio', 'view', `impact-education-screen-${currentSlide.value + 1}`); | ||
| }; | ||
|
|
||
| const handleClose = () => { | ||
| emit('close'); | ||
| currentSlide.value = 0; | ||
| }; | ||
|
|
||
| const goToPrev = () => { | ||
| if (currentSlide.value > 0) { | ||
| const newIndex = currentSlide.value - 1; | ||
| carouselRef.value?.goToSlide(newIndex); | ||
| currentSlide.value = newIndex; | ||
| $kvTrackEvent('portfolio', 'click', 'next-step-impact-education-back'); | ||
| handleTrackEvent(); | ||
| } | ||
| }; | ||
|
|
||
| const goToNext = () => { | ||
| if (currentSlide.value < totalSlides - 1) { | ||
| const newIndex = currentSlide.value + 1; | ||
| carouselRef.value?.goToSlide(newIndex); | ||
| currentSlide.value = newIndex; | ||
| } | ||
| }; | ||
|
|
||
| const handleNextOrDone = () => { | ||
| if (isLastSlide.value) { | ||
| handleClose(); | ||
| } else { | ||
| goToNext(); | ||
| $kvTrackEvent('portfolio', 'click', 'next-step-impact-education-next'); | ||
| handleTrackEvent(); | ||
| } | ||
| }; | ||
|
|
||
| const handleUserInteraction = interaction => { | ||
| const newIndex = interaction.value; | ||
| if (typeof newIndex === 'number' && newIndex !== currentSlide.value) { | ||
| currentSlide.value = newIndex; | ||
| handleTrackEvent(); | ||
| } | ||
| }; | ||
|
|
||
| onMounted(() => { | ||
| $kvTrackEvent('portfolio', 'view', 'impact-education-screen-1'); | ||
| }); | ||
|
|
||
| </script> | ||
|
|
||
| <style lang="postcss"> | ||
| .impact-insight-modal ::v-deep #kvLightboxBody { | ||
| height: 771px; | ||
| width: 100%; | ||
|
|
||
| @screen md { | ||
| height: 384px; | ||
| width: 952px; | ||
| } | ||
| } | ||
|
|
||
| .impact-insight-modal { | ||
| .impact-insight-carousel { | ||
| @apply md:!tw-mb-2 | ||
| } | ||
|
|
||
| .tw-bg-primary:has(#kvLightboxBody) { | ||
| max-height: 528px; | ||
| } | ||
|
|
||
| .impact-insight-carousel div:has(.impact-insight-slide) { | ||
| @apply tw-self-start md:tw-self-auto; | ||
| } | ||
|
|
||
| .impact-insight-carousel div:first-child { | ||
| @apply !tw-items-center; | ||
| } | ||
|
|
||
| .kv-carousel__controls { | ||
| gap: 10px; | ||
| flex-wrap: wrap; | ||
|
|
||
| @apply !tw-flex tw-items-center tw-gap-1 tw-mb-1.5 tw-z-sticky md:!tw-mt-5 md:!tw-mb-0; | ||
|
|
||
| @screen md { | ||
| max-width: 50%; | ||
| } | ||
| } | ||
|
|
||
| .impact-insight-footer { | ||
| max-height: 48px; | ||
|
|
||
| .secondary-navigation-buttons { | ||
| @apply md:!tw-absolute; | ||
|
|
||
| @screen md { | ||
| width: auto; | ||
| bottom: 21%; | ||
| } | ||
|
|
||
| } | ||
| } | ||
| } | ||
| </style> | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.