-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathAlert.vue
More file actions
150 lines (127 loc) · 2.64 KB
/
Alert.vue
File metadata and controls
150 lines (127 loc) · 2.64 KB
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
<template>
<PageHeader>
Alert
<template #description>
Light and beautiful codex alert
<code>click the button to see for yourself </code>
</template>
</PageHeader>
<p>The following outlines options for alert to display </p>
<div class="flex-content">
<div>
Message - message of the alert to be displayed (string)
</div>
<div>
Position - position of alert (bottom-center)
</div>
<div>
Type - alert type (success, error, warning, info and default)
</div>
<div>
Timeout - visibility duration in milliseconds, set timeout to keep alert visible
</div>
</div>
<div class="flex-type">
<div class="flex">
<span>Success</span>
<Button
@click="showSuccessAlert"
>
Show success alert
</Button>
</div>
<div class="flex">
<span>Error</span>
<Button
@click="showErrorAlert"
>
Show error alert
</Button>
</div>
<div class="flex">
<span>Warning</span>
<Button
@click="showWarningAlert"
>
Show warning alert
</Button>
</div>
<div class="flex">
<span>Info</span>
<Button
@click="showInfoAlert"
>
Show info alert
</Button>
</div>
<div class="flex">
<span>Default</span>
<Button
@click="showDefaultAlert"
>
Show default alert
</Button>
</div>
</div>
<AlertContainer />
</template>
<script setup lang="ts">
import PageHeader from '../../components/PageHeader.vue';
import { Button, useAlert, AlertContainer } from '../../../src/vue';
const { success, error, warning, info, alert } = useAlert();
const showSuccessAlert = () => {
success({
message: '1st alert',
timeout: 5000,
});
};
const showErrorAlert = () => {
error({
message: '2nd alert',
timeout: 5000,
});
};
const showWarningAlert = () => {
warning({
message: '3rd alert',
timeout: 5000,
});
};
const showInfoAlert = () => {
info({
message: '4th alert',
timeout: 5000,
});
};
const showDefaultAlert = () => {
alert({
message: '5th alert',
timeout: 5000,
});
};
</script>
<style lang="postcss">
.flex-content {
display: grid;
grid-template-columns: 1fr;
gap: var(--spacing-l);
align-items: center;
}
.flex-type {
display: grid;
grid-template-columns: repeat(1, 2fr);
gap: var(--spacing-l);
align-items: center;
margin-top: 2rem;
.flex {
display: grid;
grid-template-columns: repeat(5, 1fr);
align-items: center;
gap: var(--spacing-l);
button {
display: grid;
grid-column: span 1;
}
}
}
</style>