Skip to content

Commit

Permalink
fix: fixes FAQs on pages that use ContentfulPage
Browse files Browse the repository at this point in the history
* Adds a wrapper component that can be used in conjunction with KvFrequentlyAskedQuestions for contentful pages

VUE-790
  • Loading branch information
Eddie Ferrer authored and ryan-ludwig committed Oct 26, 2021
1 parent 399339f commit d49caab
Show file tree
Hide file tree
Showing 7 changed files with 105 additions and 53 deletions.
53 changes: 53 additions & 0 deletions src/components/Contentful/FrequentlyAskedQuestions.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<template>
<section-with-background-classic
:background-content="background"
:vertical-padding="verticalPadding"
>
<template #content>
<kv-page-container>
<kv-frequently-asked-questions
:headline="frequentlyAskedQuestionsHeadline"
:questions="frequentlyAskedQuestions"
/>
</kv-page-container>
</template>
</section-with-background-classic>
</template>

<script>
import contentfulStylesMixin from '@/plugins/contentful-ui-setting-styles-mixin';
import SectionWithBackgroundClassic from '@/components/Contentful/SectionWithBackgroundClassic';
import KvFrequentlyAskedQuestions from '@/components/Kv/KvFrequentlyAskedQuestions';
import KvPageContainer from '~/@kiva/kv-components/vue/KvPageContainer';
export default {
components: {
KvFrequentlyAskedQuestions,
KvPageContainer,
SectionWithBackgroundClassic,
},
mixins: [contentfulStylesMixin],
props: {
/**
* Content group content from Contentful
* */
content: {
type: Object,
default: () => {},
},
},
computed: {
frequentlyAskedQuestionsHeadline() {
return this.content?.title ?? null;
},
frequentlyAskedQuestions() {
return this.content?.contents ?? null;
},
background() {
return this.content?.contents?.find(({ contentType }) => {
return contentType ? contentType === 'background' : false;
});
},
},
};
</script>
1 change: 0 additions & 1 deletion src/components/Kv/KvExpandableQuestion.vue
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ export default {
},
methods: {
toggleFaq() {
console.log('toggle');
if (!this.open) {
this.$kvTrackEvent(this.analyticsCategory, 'click-faq-expand', this.title);
}
Expand Down
73 changes: 26 additions & 47 deletions src/components/Kv/KvFrequentlyAskedQuestions.vue
Original file line number Diff line number Diff line change
@@ -1,67 +1,46 @@
<template>
<section-with-background-classic
:background-content="background"
:vertical-padding="verticalPadding"
>
<template #content>
<kv-grid>
<div v-if="frequentlyAskedQuestionsHeadline">
<h2 class="tw-text-h2">
{{ frequentlyAskedQuestionsHeadline }}
</h2>
</div>
<div v-if="frequentlyAskedQuestions" class="tw-divide-y">
<kv-expandable-question
v-for="(question, index) in frequentlyAskedQuestions"
:key="index"
:title="question.name"
:content="convertFromRichTextToHtml(question.richText)"
:id="question.name | changeCase('paramCase')"
/>
</div>
</kv-grid>
</template>
</section-with-background-classic>
<kv-grid>
<div v-if="headline">
<h2 class="tw-text-h2">
{{ headline }}
</h2>
</div>
<div v-if="questions" class="tw-divide-y">
<kv-expandable-question
v-for="(question, index) in questions"
:key="index"
:title="question.name"
:content="convertFromRichTextToHtml(question.richText)"
:id="question.name | changeCase('paramCase')"
/>
</div>
</kv-grid>
</template>

<script>
import contentfulStylesMixin from '@/plugins/contentful-ui-setting-styles-mixin';
import KvExpandableQuestion from '@/components/Kv/KvExpandableQuestion';
import SectionWithBackgroundClassic from '@/components/Contentful/SectionWithBackgroundClassic';
import { richTextRenderer } from '@/util/contentful/richTextRenderer';
import KvGrid from '~/@kiva/kv-components/vue/KvGrid';
export default {
components: {
KvExpandableQuestion,
KvGrid,
SectionWithBackgroundClassic,
},
mixins: [contentfulStylesMixin],
props: {
/**
* Content group content from Contentful
* FAQ Headline
* */
content: {
type: Object,
default: () => {},
headline: {
type: String,
default: '',
},
},
data() {
return {
};
},
computed: {
frequentlyAskedQuestionsHeadline() {
return this.content?.title ?? null;
},
frequentlyAskedQuestions() {
return this.content?.contents ?? null;
},
background() {
return this.content?.contents?.find(({ contentType }) => {
return contentType ? contentType === 'background' : false;
});
/**
* Array of questions - output of contentful content field. each questions is a contentful rich text object
* */
questions: {
type: Array,
default: () => [],
},
},
methods: {
Expand Down
9 changes: 8 additions & 1 deletion src/pages/AutoDeposit/AutoDepositLandingPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@
<div class="kv-tailwind row">
<kv-frequently-asked-questions
class="span-12 column"
:content="faqContentGroup"
:headline="frequentlyAskedQuestionsHeadline"
:questions="frequentlyAskedQuestions"
/>
</div>
</www-page>
Expand Down Expand Up @@ -158,6 +159,12 @@ export default {
return type ? type === 'frequentlyAskedQuestions' : false;
});
},
frequentlyAskedQuestionsHeadline() {
return this.faqContentGroup?.title ?? null;
},
frequentlyAskedQuestions() {
return this.faqContentGroup?.contents ?? null;
},
ctaContentGroup() {
return this.contentGroups?.find(({ key }) => {
return key ? key === 'auto-deposit-cta' : false;
Expand Down
4 changes: 2 additions & 2 deletions src/pages/ContentfulPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ const LoansByCategoryCarousel = () => import('@/components/Contentful/LoansByCat
const MonthlyGoodSelectorWrapper = () => import('@/components/MonthlyGood/MonthlyGoodSelectorWrapper');
const KvFrequentlyAskedQuestions = () => import('@/components/Kv/KvFrequentlyAskedQuestions');
const FrequentlyAskedQuestions = () => import('@/components/Contentful/FrequentlyAskedQuestions');
const TestimonialCards = () => import('@/components/Contentful/TestimonialCards');
Expand Down Expand Up @@ -169,7 +169,7 @@ const getComponentFromType = type => {
case 'monthlyGoodSelector':
return MonthlyGoodSelectorWrapper;
case 'frequentlyAskedQuestions':
return KvFrequentlyAskedQuestions;
return FrequentlyAskedQuestions;
case 'testimonialCards':
return TestimonialCards;
case 'cardRow':
Expand Down
9 changes: 8 additions & 1 deletion src/pages/Donate/DonateSupportUs.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
<div class="small-12 columns donation-faq-holder">
<div class="kv-tailwind">
<kv-frequently-asked-questions
:content="faqContentGroup"
:headline="frequentlyAskedQuestionsHeadline"
:questions="frequentlyAskedQuestions"
/>
</div>
</div>
Expand Down Expand Up @@ -137,6 +138,12 @@ export default {
faqContentGroup() {
return this.page?.contentGroups?.frequentlyAskedQuestions || {};
},
frequentlyAskedQuestionsHeadline() {
return this.faqContentGroup?.title ?? null;
},
frequentlyAskedQuestions() {
return this.faqContentGroup?.contents ?? null;
},
donationCalloutsCG() {
return this.page?.contentGroups?.webDonateSupportUsDonationCallouts || {};
}
Expand Down
9 changes: 8 additions & 1 deletion src/pages/MonthlyGood/MonthlyGoodLandingPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@
<div class="kv-tailwind row">
<kv-frequently-asked-questions
class="span-12 column"
:content="faqContentGroup"
:headline="frequentlyAskedQuestionsHeadline"
:questions="frequentlyAskedQuestions"
/>
</div>
</www-page>
Expand Down Expand Up @@ -228,6 +229,12 @@ export default {
return type ? type === 'frequentlyAskedQuestions' : false;
});
},
frequentlyAskedQuestionsHeadline() {
return this.faqContentGroup?.title ?? null;
},
frequentlyAskedQuestions() {
return this.faqContentGroup?.contents ?? null;
},
heroContentGroup() {
return this.contentGroups?.find(({ key }) => {
return key ? key === 'monthlygood-landing-hero' : false;
Expand Down

0 comments on commit d49caab

Please sign in to comment.