Modal.vue 4.4 KB

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