-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathslds-scoped-notification.vue
75 lines (57 loc) · 1.93 KB
/
slds-scoped-notification.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
<template>
<div :class="scopedNotificationClass" role="status">
<div class="slds-media__figure">
<slds-icon :icon-name="iconName || fallbackIconName" :inverse="inverse" small/>
</div>
<div class="slds-media__body">
<slot/>
</div>
</div>
</template>
<script lang="ts">
import SldsIcon from "../slds-icon/slds-icon.vue"
import { ICONS } from "../../constants"
import { defineComponent } from "vue"
export default defineComponent({
name: "SldsScopedNotification",
components: { SldsIcon },
props: {
error: Boolean,
iconName: String,
info: Boolean,
success: Boolean,
warning: Boolean,
},
computed: {
/**
* Scoped notification icon name.
*/
fallbackIconName(): string {
let iconName = ""
if (this.error) iconName += ICONS.UTILITY.ERROR
else if (this.success) iconName += ICONS.UTILITY.SUCCESS
else if (this.warning) iconName += ICONS.UTILITY.WARNING
else iconName += ICONS.UTILITY.INFO
return iconName
},
/**
* Indicates whether this scoped notification has the inverse theme.
*/
inverse(): boolean {
return Boolean(this.error || this.info || this.success)
},
/**
* The CSS class names for the scoped notification.
*/
scopedNotificationClass(): string {
let classNames = "slds-scoped-notification slds-media slds-media_center"
if (this.error) classNames += " slds-theme_error"
else if (this.info) classNames += " slds-theme_info"
else if (this.success) classNames += " slds-theme_success"
else if (this.warning) classNames += " slds-theme_warning"
else classNames += " slds-scoped-notification_light"
return classNames
},
},
})
</script>