Modal.vue 4.7 KB

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