Plan stuff. Log stuff.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

167 lines
2.9 KiB

4 years ago
  1. <script>
  2. import { createEventDispatcher } from 'svelte';
  3. export let title = "";
  4. export let wide = false;
  5. export let error = null;
  6. export let closable = false;
  7. const dispatch = createEventDispatcher();
  8. </script>
  9. <div class="modal-background" on:click|self={() => closable ? dispatch("close") : null}>
  10. <div class="modal" class:wide>
  11. <div class="header">
  12. <div class="title" class:noclose={!closable}>{title}</div>
  13. {#if (closable)}
  14. <div class="x">
  15. <div class="button" on:click|self={() => dispatch("close")}>X</div>
  16. </div>
  17. {/if}
  18. </div>
  19. <hr />
  20. {#if (error != null)}
  21. <div class="error">{error}</div>
  22. {/if}
  23. <div class="body">
  24. <slot></slot>
  25. </div>
  26. </div>
  27. </div>
  28. <style>
  29. div.modal-background {
  30. position: fixed;
  31. top: 0;
  32. left: 0;
  33. width: 100%;
  34. height: 100%;
  35. background: rgba(0,0,0,0.3);
  36. }
  37. div.modal {
  38. position: absolute;
  39. left: 50%;
  40. top: 50%;
  41. width: calc(100vw - 4em);
  42. max-width: 40ch;
  43. max-height: calc(100vh - 4em);
  44. overflow: auto;
  45. transform: translate(-50%,-50%);
  46. padding: 1em;
  47. border-radius: 0.2em;
  48. background: #333;
  49. }
  50. div.modal.wide {
  51. max-width: 60ch;
  52. }
  53. div.modal :global(hr) {
  54. border: 0.5px solid gray;
  55. margin: 0;
  56. }
  57. div.error {
  58. margin: 0.5em;
  59. padding: 0.5em;
  60. border: 1px solid rgb(204, 65, 65);
  61. border-radius: 0.2em;
  62. background-color: rgb(133, 39, 39);
  63. color: rgb(211, 141, 141);
  64. animation: fadein 0.5s;
  65. }
  66. div.body {
  67. margin: 1em 0.25ch;
  68. }
  69. div.title {
  70. color: #CCC;
  71. line-height: 1em;
  72. }
  73. div.title.noclose {
  74. margin-bottom: 1.2em;
  75. }
  76. div.x {
  77. position: relative;
  78. line-height: 1em;
  79. top: -1em;
  80. text-align: right;
  81. }
  82. div.x div.button {
  83. color: #CCC;
  84. display: inline-block;
  85. padding: 0em 0.5ch 0.1em 0.5ch;
  86. line-height: 1em;
  87. user-select: none;
  88. cursor: pointer;
  89. }
  90. div.x div.button:hover {
  91. background: #222;
  92. color: #FFF;
  93. }
  94. div.modal :global(button) {
  95. display: inline-block;
  96. padding: 0.25em 0.75ch 0.26em 0.75ch;
  97. margin: 0.75em 0.25ch 0.25em 0.25ch;
  98. background: none;
  99. border: none;
  100. border-radius: 0.2em;
  101. color: #CCC;
  102. cursor: pointer;
  103. }
  104. div.modal :global(button:hover), div.modal :global(button:focus) {
  105. background: #222;
  106. color: #FFF;
  107. }
  108. div.modal :global(label) {
  109. padding: 0 0 0.125em 0.25ch;
  110. font-size: 0.75em;
  111. }
  112. div.modal :global(input), div.modal :global(select) {
  113. width: 100%;
  114. margin-bottom: 0.5em;
  115. background: #222;
  116. color: #777;
  117. border: none;
  118. outline: none;
  119. }
  120. div.modal :global(select) {
  121. padding-left: 0.5ch;
  122. }
  123. div.modal :global(input:last-of-type) {
  124. margin-bottom: 1em;
  125. }
  126. div.modal :global(input.nolast) {
  127. margin-bottom: 0.5em;
  128. }
  129. div.modal :global(input:focus), div.modal :global(select:focus) {
  130. background: #111;
  131. color: #CCC;
  132. border: none;
  133. outline: none;
  134. }
  135. div.modal :global(p) {
  136. margin: 0.25em 1ch 1em 1ch;
  137. font-size: 0.9em;
  138. }
  139. @keyframes fadein {
  140. from { opacity: 0; }
  141. to { opacity: 1; }
  142. }
  143. </style>