Modal.vue 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  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. str
  32. .toLowerCase()
  33. .replace(/[-_]+/g, " ")
  34. .replace(/[^\w\s]/g, "")
  35. .replace(/ (.)/g, $1 => $1.toUpperCase())
  36. .replace(/ /g, ""),
  37. ...mapActions("modalVisibility", ["closeCurrentModal"])
  38. }
  39. };
  40. </script>
  41. <style lang="scss" scoped>
  42. .night-mode {
  43. .modal-card-head,
  44. .modal-card-foot {
  45. background-color: var(--dark-grey-3);
  46. border-color: var(--dark-grey-2);
  47. }
  48. .modal-card-body {
  49. background-color: var(--dark-grey-4) !important;
  50. }
  51. .modal-card-title {
  52. color: var(--white);
  53. }
  54. p,
  55. label,
  56. td,
  57. th {
  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. overflow: initial;
  81. &::v-deep {
  82. & > div {
  83. display: flex;
  84. flex-grow: 1;
  85. column-gap: 16px;
  86. }
  87. .right {
  88. margin-left: auto;
  89. justify-content: flex-end;
  90. column-gap: 16px;
  91. }
  92. }
  93. }
  94. @media screen and (max-width: 600px) {
  95. .modal-card {
  96. .modal-card-head,
  97. .modal-card-foot {
  98. border-radius: 0;
  99. }
  100. }
  101. }
  102. @media screen and (max-height: 650px) {
  103. .modal-card {
  104. height: 100%;
  105. }
  106. }
  107. </style>