File size: 1,720 Bytes
71174bc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
<template>
    <span>
        <div :class="classes" :style="'width: 100%;' + extraStyle" role="alert">
            <span v-if="minimal">
                <small><slot></slot></small>
            </span>
            <span v-else>
                <slot></slot>
                <button
                    v-if="dismissible"
                    type="button"
                    class="close"
                    data-dismiss="alert"
                    aria-label="Close"
                >
                    <span aria-hidden="true">&times;</span>
                </button>
            </span>
        </div>
    </span>
</template>

<script lang="ts">
import { Options, Vue } from "vue-class-component";
import { Prop } from "vue-property-decorator";

/**
 * Alert component
 */
@Options({
    components: {},
})
export default class Alert extends Vue {
    @Prop({ default: "primary" }) type!: string;
    @Prop({ default: "" }) extraClasses!: string;
    @Prop({ default: "" }) extraStyle!: string;
    @Prop({ default: false }) minimal!: boolean;

    // NOTE: Dismissable not working/fully implemented. Would require jQuery.
    @Prop({ default: false }) dismissible!: boolean;

    /**
     * The classes for the alert.
     *
     * @returns {string} The classes for the alert.
     */
    get classes(): string {
        let classes = `alert alert-${this.type}`;
        if (this.extraClasses !== "") classes += ` ${this.extraClasses}`;
        if (this.dismissible) classes += " alert-dismissible fade show";
        if (this.minimal) classes += " small p-2 lh-sm";
        return classes;
    }
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped lang="scss"></style>