Modal.vue 3.9 KB

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