aboutsummaryrefslogtreecommitdiff
path: root/resources/vue/components/StudipTooltipIcon.vue
blob: ac0f59c6cf8e3961ad9d4644f43ccf8372e19c9a (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
<template>
    <span data-tooltip class="tooltip tooltip-icon" :class="cssClass" tabindex="0" :aria-label="cleanText">
        <span class="tooltip-content" v-if="isHtml" v-html="text"></span>
        <span class="tooltip-content" v-else>{{ text }}</span>
    </span>
</template>

<script>
    export default {
        name: 'studip-tooltip-icon',
        props: {
            text: String,
            isHtml: {
                type: Boolean,
                required: false,
                default: false
            },
            isImportant: {
                type: Boolean,
                required: false,
                default: false
            },
            size: {
                type: Number,
                default: 16
            }
        },
        computed: {
            cleanText() {
                const div = document.createElement('div');
                div.innerHTML = this.text;
                return div.innerText.trim();
            },
            cssClass () {
                return this.isImportant ? 'tooltip-important' : '';
            }
        }
    }
</script>