Modal.vue 4.6 KB

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