Modal.vue 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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. th {
  59. color: var(--light-grey-2) !important;
  60. }
  61. h1,
  62. h2,
  63. h3,
  64. h4,
  65. h5,
  66. h6 {
  67. color: var(--white) !important;
  68. }
  69. }
  70. .modal-card {
  71. width: 800px;
  72. font-size: 16px;
  73. }
  74. p {
  75. font-size: 17px;
  76. }
  77. .modal-card-title {
  78. font-size: 27px;
  79. }
  80. .modal-card-foot {
  81. *:not(:last-child) {
  82. margin-right: 10px;
  83. }
  84. & > div {
  85. display: flex;
  86. flex-grow: 1;
  87. div:not(:first-of-type) {
  88. margin-left: 10px;
  89. }
  90. }
  91. .right {
  92. margin-left: auto;
  93. justify-content: flex-end;
  94. *:not(:last-child) {
  95. margin-right: 5px;
  96. }
  97. }
  98. }
  99. </style>