Modal.vue 4.4 KB

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