Modal.vue 4.7 KB

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