Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 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 | 1x 1x 5x 5x 1x 1x 1x 1x 5x 1x 1x 1x 1x 1x 5x | <template>
<div>
<notifications
data-testid="notification"
classes="my-notification"
position="bottom"
width="412px"
>
<template #body="props">
<div
class="my-notification vue-notification new-style"
v-bind="props"
>
<div class="notification-content">
<v-btn
:icon="(props.item.data as NotificationData).icon"
:color="getButtonColor(props.item.type)"
variant="text"
size="small"
class="icon-btn"
/>
<div class="notification-message ml-3 pr-0">{{
props.item.text
}}</div>
<v-btn
:color="getButtonColor(props.item.type)"
variant="flat"
class="ml-auto"
>
<span>{{ t('labels.undo') }}</span>
</v-btn>
<v-btn
class="shark-400"
icon="close"
variant="text"
size="small"
@click="props.close"
/>
</div>
</div>
</template>
</notifications>
</div>
</template>
<script setup lang="ts">
import { Notifications, useNotification } from '@kyvg/vue3-notification';
import { useI18n } from 'vue-i18n';
interface NotificationData {
icon: string;
}
const { t } = useI18n();
const { notify } = useNotification();
function notifySuccess(): void {
notify({
type: 'success',
text: 'This is a Success message!!',
duration: 300000,
data: { icon: 'check_circle' },
});
}
function notifyError(): void {
notify({
type: 'error',
text: 'This is an Error Message!!',
duration: 300000,
data: { icon: 'error' },
});
}
function notifyWarning(): void {
notify({
type: 'warn',
text: 'This is a warning Message!!',
duration: 300000,
data: { icon: 'warning' },
});
}
function notifyInfo(): void {
notify({
type: 'info',
text: 'This is an informational message!!',
duration: 300000,
data: { icon: 'check_circle' },
});
}
function getButtonColor(type?: string): string {
switch (type) {
case 'success':
return 'rgba(29, 127, 22, 1)';
case 'error':
return 'rgba(202, 52, 74, 1)';
case 'warn':
return 'rgba(166, 103, 2, 1)';
case 'info':
return 'rgba(27, 109, 131, 1)';
default:
return '';
}
}
defineExpose({
notifyInfo,
notifySuccess,
notifyWarning,
notifyError,
getButtonColor,
});
</script>
<style lang="scss">
.vue-notification {
border-radius: 12px;
border-left-color: transparent !important;
background-color: rgba(255, 255, 255, 0.9) !important;
color: #1d1d20 !important;
}
.notification-message {
font-size: 14px;
font-style: normal;
font-weight: 500;
line-height: 20px;
}
.notification-content {
display: flex;
align-items: center;
padding: 0px;
margin: 0px;
}
</style>
|