Modal.vue 4.4 KB

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