aboutsummaryrefslogtreecommitdiff
path: root/resources/vue/components/courseware/CoursewareTab.vue
blob: 5c5217283f811f4a9d1a5fe264f09e66b153353c (plain)
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
<template>
    <div
        role="tabpanel"
        class="cw-tab"
        :id="id"
        :class="{ 'cw-tab-active': isActive }"
        :aria-labelledby="selectorId"
    >
        <slot></slot>
    </div>
</template>

<script>
export default {
    name: 'courseware-tab',
    props: {
        name: {type: String, required: true },
        alias: {type: String, default: ''},
        selected: { type: Boolean, default: false },
        index: {type: Number, required: true },
        icon: {type: String, default: ''},
    },
    data() {
        return {
            isActive: false,
        };
    },
    computed: {
        selectorId() {
            return '#' +this.index + '-' + this.name.toLowerCase().replace(/ /g, '-');
        },
        id() {
            return this.index + '-' + this.name.toLowerCase().replace(/ /g, '-') + '-tabpanel';
        },
    },
    mounted() {
        this.isActive = this.selected;
    },
    watch: {
        selected(newValue) {
            this.isActive = newValue;
        }
    }
};
</script>