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
|
<template>
<div class="cw-call-to-action">
<button class="action-button" :title="unfold ? titleOpen : titleClosed" @click="buttonAction">
<studip-icon :shape="unfold ? 'arr_1down' : iconShape" :size="24"/>
{{ actionTitle }}
</button>
<div v-if="unfold" class="cw-call-to-action-content">
<slot name="content"></slot>
</div>
</div>
</template>
<script>
import StudipIcon from '../../StudipIcon.vue';
export default {
name: 'courseware-call-to-action-box',
components: {
StudipIcon
},
emits: ['click'],
props: {
iconShape: {
type: String,
default: 'arr_1right'
},
titleClosed: {
type: String,
required: true
},
titleOpen: {
type: String,
required: true
},
actionTitle: {
type: String,
required: true
},
foldable: {
type: Boolean,
default: false
},
open: {
type: Boolean,
default: true
}
},
data() {
return {
unfold: true
}
},
methods: {
buttonAction() {
this.$emit('click');
if (this.foldable) {
this.unfold = !this.unfold;
}
}
},
mounted() {
this.unfold = this.open;
},
watch: {
open(newState) {
this.unfold = newState;
}
}
}
</script>
|