This repository was archived by the owner on Mar 9, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathFAQList.vue
More file actions
109 lines (100 loc) · 1.94 KB
/
FAQList.vue
File metadata and controls
109 lines (100 loc) · 1.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
<template>
<div>
<ul :v-if="FAQs.length" class="data-list faq-data-list">
<li
:class="{ isClosed: !item.isOpen }"
:key="index"
class="data-item faq-data-item initBorder"
v-for="(item, index) in FAQs"
>
<TheQuestion :question="item.question" :toggleAccordion="toggleAccordion" />
<TheAnswer :answer="item.answer" />
</li>
</ul>
</div>
</template>
<script>
import { mapActions } from 'vuex';
import TheQuestion from './TheQuestion.vue';
import TheAnswer from './TheAnswer.vue';
export default {
name: 'FAQList',
components: {
TheQuestion,
TheAnswer,
},
props: {
question: String,
answer: String,
},
created() {
this.faq();
},
computed: {
FAQs: {
get() {
return this.$store.state.FAQs.FAQs;
},
set(updated) {
this.$store.state.FAQs.FAQs = updated;
},
},
},
methods: {
toggleAccordion(question) {
this.FAQs = this.FAQs.map(e => {
if (e.question === question) {
return { ...e, isOpen: !e.isOpen };
}
return { ...e, isOpen: false };
});
},
...mapActions({
faq: 'FAQs/addFAQsAction',
}),
},
};
</script>
<style scoped>
.faq-data-list {
display: flex;
flex-wrap: wrap;
}
.faq-data-item {
flex-basis: 100%;
}
@media (min-width: 630px) {
.faq-data-item {
flex-basis: 70%;
}
}
.data-item,
.data-item > div {
border: none;
}
.data-item {
margin-left: auto;
margin-right: auto;
border-bottom: 1px solid #eee;
padding: 12px;
background: #fff;
box-shadow: 0 0 8px -5px #000;
list-style: none;
}
.initBorder {
position: relative;
}
.initBorder:before {
transition: opacity 0.1s linear, transform 0.5s ease-in-out;
position: absolute;
border-bottom: 1px solid currentColor;
content: '';
width: 100%;
left: 0;
bottom: -1px;
}
.initBorder:not(:hover)::before {
transform: scaleX(0);
opacity: 0;
}
</style>