Modal.vue 4.6 KB

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