Modal.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. <template>
  2. <div class="modal is-active">
  3. <div class="modal-background" @click="closeThisModal()" />
  4. <div
  5. :class="{
  6. 'modal-card': true,
  7. 'modal-wide': wide,
  8. 'modal-split': split
  9. }"
  10. >
  11. <header class="modal-card-head">
  12. <h2 class="modal-card-title is-marginless">
  13. {{ title }}
  14. </h2>
  15. <span class="delete material-icons" @click="closeThisModal()"
  16. >highlight_off</span
  17. >
  18. </header>
  19. <section class="modal-card-body">
  20. <slot name="body" />
  21. </section>
  22. <footer class="modal-card-foot" v-if="$slots['footer'] != null">
  23. <slot name="footer" />
  24. </footer>
  25. </div>
  26. </div>
  27. </template>
  28. <script>
  29. import { mapActions } from "vuex";
  30. export default {
  31. props: {
  32. title: { type: String, default: "Modal" },
  33. wide: { type: Boolean, default: false },
  34. split: { type: Boolean, default: false }
  35. },
  36. emits: ["closed"],
  37. mounted() {
  38. this.type = this.toCamelCase(this.title);
  39. },
  40. methods: {
  41. toCamelCase: str =>
  42. str
  43. .toLowerCase()
  44. .replace(/[-_]+/g, " ")
  45. .replace(/[^\w\s]/g, "")
  46. .replace(/ (.)/g, $1 => $1.toUpperCase())
  47. .replace(/ /g, ""),
  48. closeThisModal() {
  49. this.closeCurrentModal();
  50. this.$emit("closed");
  51. },
  52. ...mapActions("modalVisibility", ["closeCurrentModal"])
  53. }
  54. };
  55. </script>
  56. <style lang="scss">
  57. .night-mode .modal .modal-card {
  58. .modal-card-head,
  59. .modal-card-foot {
  60. background-color: var(--dark-grey-3);
  61. border-color: var(--dark-grey-2);
  62. }
  63. .modal-card-body {
  64. background-color: var(--dark-grey-4) !important;
  65. }
  66. .modal-card-head .delete.material-icons,
  67. .modal-card-title {
  68. color: var(--white);
  69. }
  70. p,
  71. label,
  72. td,
  73. th {
  74. color: var(--light-grey-2) !important;
  75. }
  76. h1,
  77. h2,
  78. h3,
  79. h4,
  80. h5,
  81. h6 {
  82. color: var(--white) !important;
  83. }
  84. }
  85. .modal {
  86. display: flex;
  87. position: fixed;
  88. top: 0;
  89. bottom: 0;
  90. left: 0;
  91. right: 0;
  92. z-index: 1984;
  93. justify-content: center;
  94. align-items: center;
  95. .modal-background {
  96. position: absolute;
  97. top: 0;
  98. bottom: 0;
  99. left: 0;
  100. right: 0;
  101. background-color: rgba(10, 10, 10, 0.85);
  102. }
  103. .modal-card {
  104. display: flex;
  105. flex-direction: column;
  106. position: relative;
  107. width: 800px;
  108. max-width: calc(100% - 40px);
  109. max-height: calc(100vh - 40px);
  110. overflow: auto;
  111. margin: 0;
  112. font-size: 16px;
  113. &.modal-wide {
  114. width: 1300px;
  115. }
  116. &.modal-split {
  117. height: 100%;
  118. .modal-card-body {
  119. display: flex;
  120. flex-wrap: wrap;
  121. height: 100%;
  122. row-gap: 24px;
  123. .left-section,
  124. .right-section {
  125. flex-basis: 50%;
  126. max-height: 100%;
  127. overflow-y: auto;
  128. flex-grow: 1;
  129. .section {
  130. display: flex;
  131. flex-direction: column;
  132. flex-grow: 1;
  133. width: auto;
  134. padding: 15px !important;
  135. margin: 0 10px;
  136. }
  137. @media screen and (max-width: 1100px) {
  138. flex-basis: 100%;
  139. max-height: unset;
  140. }
  141. }
  142. }
  143. }
  144. .modal-card-head,
  145. .modal-card-foot {
  146. display: flex;
  147. flex-shrink: 0;
  148. position: relative;
  149. justify-content: flex-start;
  150. align-items: center;
  151. padding: 20px;
  152. background-color: var(--light-grey);
  153. }
  154. .modal-card-head {
  155. border-radius: 5px 5px 0 0;
  156. .modal-card-title {
  157. display: flex;
  158. flex: 1;
  159. margin: 0;
  160. font-size: 26px;
  161. font-weight: 600;
  162. }
  163. .delete.material-icons {
  164. font-size: 28px;
  165. cursor: pointer;
  166. &:hover,
  167. &:focus {
  168. filter: brightness(90%);
  169. }
  170. }
  171. }
  172. .modal-card-foot {
  173. border-radius: 0 0 5px 5px;
  174. overflow: initial;
  175. & > div {
  176. display: flex;
  177. flex-grow: 1;
  178. column-gap: 16px;
  179. }
  180. .right {
  181. display: flex;
  182. margin-left: auto;
  183. margin-right: 0;
  184. justify-content: flex-end;
  185. column-gap: 16px;
  186. }
  187. }
  188. .modal-card-body {
  189. flex: 1;
  190. flex-wrap: wrap;
  191. padding: 20px;
  192. overflow: auto;
  193. background-color: var(--white);
  194. }
  195. @media screen and (max-width: 650px) {
  196. max-height: 100vh;
  197. height: 100%;
  198. max-width: 100%;
  199. .modal-card-head,
  200. .modal-card-foot {
  201. border-radius: 0;
  202. }
  203. }
  204. }
  205. }
  206. </style>