-
Notifications
You must be signed in to change notification settings - Fork 633
/
QuestionList.vue
107 lines (89 loc) · 1.99 KB
/
QuestionList.vue
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
<template>
<section class="question-list">
<h2 class="header">
{{ $tr('questionListHeader', {numOfQuestions:questions.length}) }}
</h2>
<ul class="list">
<!-- technically, these should be buttons -->
<li
v-for="(question, index) in questions"
:key="index"
class="item"
>
<KButton
:class="{selected: index === selectedIndex}"
:style="{ backgroundColor: index === selectedIndex ? $coreGrey300 : '' }"
class="button"
:text="questionLabel(index)"
appearance="flat-button"
@click="$emit('select',index)"
/>
</li>
</ul>
</section>
</template>
<script>
import themeMixin from 'kolibri.coreVue.mixins.themeMixin';
import KButton from 'kolibri.coreVue.components.KButton';
export default {
name: 'QuestionList',
components: {
KButton,
},
mixins: [themeMixin],
$trs: {
questionListHeader: '{numOfQuestions, number} Questions',
questionLabel: 'Question { questionNumber, number }',
},
props: {
questions: {
type: Array,
required: true,
},
selectedIndex: {
type: Number,
required: true,
},
questionLabel: {
type: Function,
required: true,
// simple validator, makes sure the function returns a string
validator: value => typeof value(0) === 'string',
},
},
};
</script>
<style lang="scss" scoped>
.question-list {
background-color: white;
}
.header,
.list,
.item,
.button {
display: block;
width: 100%;
padding: 0;
margin: 0;
}
.list {
list-style: none;
}
// normalize styles for the 2
.button,
.header {
padding-left: 16px;
font-size: 16px;
line-height: 56px;
vertical-align: middle;
}
.button {
font-weight: normal;
text-align: left;
text-transform: none;
border-radius: 0;
&.selected {
font-weight: bold;
}
}
</style>