Modal.vue 4.6 KB

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