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
|
<script>
export default {
props: {
text: {
type: String,
required: false,
default: '',
},
show: {
type: Boolean,
required: false,
default: true,
},
},
data() {
return {
isVisible: this.show,
};
},
mounted() {
this.toggleBanner(this.isVisible);
},
methods: {
toggleBanner(isVisible) {
this.$emit('toggle', isVisible);
this.isVisible = isVisible;
},
},
};
</script>
<template>
<div v-if="isVisible" class="banner position-fixed w-100 text-center">
<span v-if="text">{{ text }}</span>
<slot></slot>
<!-- TODO: Replace the 'x' below with a gl-icon component once gitlab-ui becomes available in the docs -->
<button class="btn btn-close pull-right" @click="toggleBanner(false)">x</button>
</div>
</template>
|