-
Notifications
You must be signed in to change notification settings - Fork 10
/
Alert.vue
138 lines (136 loc) · 2.77 KB
/
Alert.vue
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
<template>
<div class="alert border-l-4 p-4 mb-4 mt-4" :class="`alert-${type}`">
<div class="flex items-start">
<div class="flex-shrink-0">
<component :is="icon" class="alert-icon mt-px w-6 h-6" />
</div>
<div class="flex-grow ml-2 overflow-auto alert-content">
<slot />
</div>
</div>
</div>
</template>
<script>
export default {
props: {
type: {
type: String,
default: 'info',
validator(value) {
return ['info', 'success', 'warning', 'danger'].includes(value)
},
},
},
computed: {
icon() {
return {
info: 'IconInformationCircle',
success: 'IconCheckCircle',
warning: 'IconExclamationCircle',
danger: 'IconXCircle',
}[this.type]
},
},
}
</script>
<style>
.alert p {
@apply m-0 !important;
}
.alert a {
@apply text-gray-700 !important;
}
.dark-mode .alert a {
@apply text-gray-300 !important;
}
.alert strong {
@apply text-current;
}
.alert-danger code {
@apply bg-red-200 shadow-none border-0 text-current;
}
.alert-info code {
@apply bg-blue-200 shadow-none border-0 text-current;
}
.alert-success code {
@apply bg-green-200 shadow-none border-0 text-current;
}
.alert-warning code {
@apply bg-orange-200 shadow-none border-0 text-current;
}
.alert-content pre code {
background-color: inherit !important;
}
.alert-info {
@apply bg-blue-100 border-blue-400;
}
.alert-info .alert-icon {
@apply text-blue-400;
}
.alert-info .alert-content {
@apply text-blue-700;
}
.alert-success .alert-content {
@apply text-green-700;
}
.alert-warning .alert-content {
@apply text-orange-700;
}
.alert-danger .alert-content {
@apply text-red-700;
}
.dark-mode .alert-info {
@apply bg-blue-900 border-blue-700;
}
.dark-mode .alert-info code {
@apply bg-blue-800;
}
.dark-mode .alert-info .alert-content {
@apply text-blue-300;
}
.alert-success {
@apply bg-green-100 border-green-400;
}
.alert-success .alert-icon {
@apply text-green-400;
}
.dark-mode .alert-success {
@apply bg-green-900 border-green-700;
}
.dark-mode .alert-success code {
@apply bg-green-800;
}
.dark-mode .alert-success .alert-content {
@apply text-green-300;
}
.alert-warning {
@apply bg-orange-100 border-orange-400;
}
.alert-warning .alert-icon {
@apply text-orange-400;
}
.dark-mode .alert-warning {
@apply bg-yellow-900 border-yellow-700;
}
.dark-mode .alert-warning code {
@apply bg-yellow-800;
}
.dark-mode .alert-warning .alert-content {
@apply text-orange-300;
}
.alert-danger {
@apply bg-red-100 border-red-400;
}
.alert-danger .alert-icon {
@apply text-red-400;
}
.dark-mode .alert-danger {
@apply bg-red-900 border-red-700;
}
.dark-mode .alert-danger code {
@apply bg-red-800;
}
.dark-mode .alert-danger .alert-content {
@apply text-red-300;
}
</style>