Modal.vue 4.9 KB

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