Modal.vue 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. <template>
  2. <div class="modal is-active">
  3. <div class="modal-background" @click="closeCurrentModal()" />
  4. <div class="modal-card">
  5. <header class="modal-card-head">
  6. <h2 class="modal-card-title is-marginless">
  7. {{ title }}
  8. </h2>
  9. <button class="delete" @click="closeCurrentModal()" />
  10. </header>
  11. <section class="modal-card-body">
  12. <slot name="body" />
  13. </section>
  14. <footer class="modal-card-foot" v-if="$slots['footer'] != null">
  15. <slot name="footer" />
  16. </footer>
  17. </div>
  18. </div>
  19. </template>
  20. <script>
  21. import { mapActions } from "vuex";
  22. export default {
  23. props: {
  24. title: { type: String, default: "Modal" }
  25. },
  26. mounted() {
  27. this.type = this.toCamelCase(this.title);
  28. },
  29. methods: {
  30. toCamelCase: str => {
  31. return str
  32. .toLowerCase()
  33. .replace(/[-_]+/g, " ")
  34. .replace(/[^\w\s]/g, "")
  35. .replace(/ (.)/g, $1 => $1.toUpperCase())
  36. .replace(/ /g, "");
  37. },
  38. ...mapActions("modalVisibility", ["closeCurrentModal"])
  39. }
  40. };
  41. </script>
  42. <style lang="scss" scoped>
  43. .night-mode {
  44. .modal-card-head,
  45. .modal-card-foot {
  46. background-color: var(--dark-grey-3);
  47. border-color: var(--dark-grey-2);
  48. }
  49. .modal-card-body {
  50. background-color: var(--dark-grey-4) !important;
  51. }
  52. .modal-card-title {
  53. color: var(--white);
  54. }
  55. p,
  56. label,
  57. td {
  58. color: var(--light-grey-2) !important;
  59. }
  60. h1,
  61. h2,
  62. h3,
  63. h4,
  64. h5,
  65. h6 {
  66. color: var(--white) !important;
  67. }
  68. }
  69. .modal-card {
  70. width: 800px;
  71. font-size: 16px;
  72. }
  73. p {
  74. font-size: 17px;
  75. }
  76. .modal-card-title {
  77. font-size: 27px;
  78. }
  79. .modal-card-foot {
  80. & > div {
  81. display: flex;
  82. flex-grow: 1;
  83. }
  84. .right {
  85. margin-left: auto;
  86. justify-content: right;
  87. }
  88. }
  89. </style>