Skip to content

Commit 5bff8d9

Browse files
committed
Move everything back to vue SFCs
1 parent 7617044 commit 5bff8d9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+2558
-2518
lines changed

resources/assets/scripts/components/Flash.ts

Lines changed: 0 additions & 89 deletions
This file was deleted.
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
<template>
2+
<div v-if="notifications.length > 0" :class="this.container">
3+
<transition-group tag="div" name="fade">
4+
<div v-for="(item, index) in notifications" :key="item.title">
5+
<MessageBox
6+
:class="[item.class, {'mb-2': index < notifications.length - 1}]"
7+
:title="item.title"
8+
:message="item.message"
9+
/>
10+
</div>
11+
</transition-group>
12+
</div>
13+
</template>
14+
15+
<script lang="ts">
16+
import Vue from 'vue';
17+
import MessageBox from './MessageBox.vue';
18+
19+
type DataStructure = {
20+
notifications: Array<{
21+
message: string,
22+
severity: string,
23+
title: string,
24+
class: string,
25+
}>,
26+
}
27+
28+
export default Vue.extend({
29+
name: 'Flash',
30+
components: {
31+
MessageBox
32+
},
33+
props: {
34+
container: {type: String, default: ''},
35+
timeout: {type: Number, default: 0},
36+
types: {
37+
type: Object,
38+
default: function () {
39+
return {
40+
base: 'alert',
41+
success: 'alert success',
42+
info: 'alert info',
43+
warning: 'alert warning',
44+
error: 'alert error',
45+
}
46+
}
47+
}
48+
},
49+
50+
data: function (): DataStructure {
51+
return {
52+
notifications: [],
53+
};
54+
},
55+
56+
/**
57+
* Listen for flash events.
58+
*/
59+
created: function () {
60+
const self = this;
61+
window.events.$on('flash', function (data: any) {
62+
self.flash(data.message, data.title, data.severity);
63+
});
64+
65+
window.events.$on('clear-flashes', function () {
66+
self.clear();
67+
});
68+
},
69+
70+
methods: {
71+
/**
72+
* Flash a message to the screen when a flash event is emitted over
73+
* the global event stream.
74+
*/
75+
flash: function (message: string, title: string, severity: string) {
76+
this.notifications.push({
77+
message, severity, title, class: this.$props.types[severity] || this.$props.types.base,
78+
});
79+
80+
if (this.$props.timeout > 0) {
81+
setTimeout(this.hide, this.$props.timeout);
82+
}
83+
},
84+
85+
/**
86+
* Clear all of the flash messages from the screen.
87+
*/
88+
clear: function () {
89+
this.notifications = [];
90+
window.events.$emit('flashes-cleared');
91+
},
92+
93+
/**
94+
* Hide a notification after a given amount of time.
95+
*/
96+
hide: function (item?: number) {
97+
// @ts-ignore
98+
let key = this.notifications.indexOf(item || this.notifications[0]);
99+
this.notifications.splice(key, 1);
100+
},
101+
},
102+
});
103+
</script>

resources/assets/scripts/components/MessageBox.ts

Lines changed: 0 additions & 14 deletions
This file was deleted.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<template>
2+
<div class="lg:inline-flex" role="alert">
3+
<span class="title" v-html="title" v-if="title && title.length > 0"></span>
4+
<span class="message" v-html="message"></span>
5+
</div>
6+
</template>
7+
8+
<script lang="ts">
9+
import Vue from 'vue';
10+
11+
export default Vue.extend({
12+
name: 'MessageBox',
13+
props: {
14+
title: {type: String, required: false},
15+
message: {type: String, required: true}
16+
},
17+
});
18+
</script>

resources/assets/scripts/components/auth/ForgotPassword.ts

Lines changed: 0 additions & 93 deletions
This file was deleted.

0 commit comments

Comments
 (0)