You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

105 lines
3.8 KiB

2 years ago
  1. <template>
  2. <client-only>
  3. <notifications position="top center" class="my-notification tw-top-[84px] xl:tw-top-[144px] tw-w-max">
  4. <template slot="body" slot-scope="props">
  5. <div :class="[
  6. 'custom-template tw-flex tw-items-center tw-px-[20px] tw-py-[14px] tw-rounded-[16px]',
  7. props.item.type == 'error' ?'tw-bg-error-background':'',
  8. props.item.type == 'warn' ?'tw-bg-warning-background':'',
  9. props.item.type == 'success' ?'tw-bg-success-background':''
  10. ]">
  11. <div v-if="props.item.type == 'error'" class="custom-template-icon tw-flex tw-items-center tw-mr-[18px]">
  12. <img src="~/assets/svg/notification-error.svg" />
  13. <div class="tw-ml-[12px] tw-text-error-default t16">Oops!</div>
  14. </div>
  15. <div v-if="props.item.type == 'warn'" class="custom-template-icon tw-flex tw-items-center tw-mr-[25px]">
  16. <img src="~/assets/svg/notification-warn.svg" />
  17. <div class="tw-ml-[12px] tw-text-warning-default t16">Ohh,</div>
  18. </div>
  19. <div v-if="props.item.type == 'success'" class="custom-template-icon tw-mr-[18px]">
  20. <img src="~/assets/svg/notification-success.svg" />
  21. </div>
  22. <div class="custom-template-content tw-flex tw-items-center">
  23. <div :class="[
  24. 'tw-font-bold tw-bg-transparent custom-template-title tw-mr-[16px]',
  25. props.item.type == 'error' ?'tw-text-error-default':'',
  26. props.item.type == 'warn' ?'tw-text-warning-default':'',
  27. props.item.type == 'success' ?'tw-text-success-default':''
  28. ]">
  29. {{ $t(props.item.title) }}
  30. </div>
  31. <div :class="[
  32. 'custom-template-text tw-bg-transparent',
  33. props.item.type == 'error' ?'tw-text-error-default':'',
  34. props.item.type == 'warn' ?'tw-text-warning-default':'',
  35. props.item.type == 'success' ?'tw-text-success-default':''
  36. ]" v-html="$t(props.item.text)"></div>
  37. </div>
  38. <div class="custom-template-close tw-ml-[20px]" @click="props.close">
  39. <div v-if="props.item.type == 'error'">
  40. <img src="~/assets/svg/close-error.svg" width="10" height="10" />
  41. </div>
  42. <div v-if="props.item.type == 'warn'">
  43. <img src="~/assets/svg/close-warn.svg" width="10" height="10" />
  44. </div>
  45. <div v-if="props.item.type == 'success'">
  46. <img src="~/assets/svg/close-success.svg" width="10" height="10" />
  47. </div>
  48. </div>
  49. </div>
  50. </template>
  51. </notifications>
  52. </client-only>
  53. </template>
  54. <script>
  55. export default {};
  56. </script>
  57. <style lang="scss" scoped>
  58. // style of the notification itself
  59. :deep() {
  60. .my-notification {
  61. // style for title line
  62. .notification-title {}
  63. // style for content
  64. .notification-content {}
  65. // additional styling hook when using`type` parameter, i.e. this.$notify({ type: 'success', message: 'Yay!' })
  66. .custom-template {
  67. &.success {
  68. background-color: #f1fffb !important;
  69. box-shadow: 0px 2px 2px rgba(137, 138, 141, 0.1) !important;
  70. }
  71. &.warn {
  72. background-color: #fffaee !important;
  73. box-shadow: 0px 2px 2px rgba(137, 138, 141, 0.1) !important;
  74. }
  75. &.error {
  76. background-color: #fff7f4 !important;
  77. box-shadow: 0px 2px 2px rgba(137, 138, 141, 0.1) !important;
  78. }
  79. }
  80. .custom-template-text {
  81. &.success {
  82. color: #2dc695;
  83. background-color: transparent !important;
  84. }
  85. &.warn {
  86. color: #ffb70a;
  87. background-color: transparent !important;
  88. }
  89. &.error {
  90. color: #ef5a5a;
  91. background-color: transparent !important;
  92. }
  93. }
  94. }
  95. }
  96. </style>