AddTextContentModal.svelte 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. <script lang="ts">
  2. import { toast } from 'svelte-sonner';
  3. import dayjs from 'dayjs';
  4. import { onMount, getContext, createEventDispatcher } from 'svelte';
  5. const i18n = getContext('i18n');
  6. const dispatch = createEventDispatcher();
  7. import Modal from '$lib/components/common/Modal.svelte';
  8. export let show = false;
  9. let name = '';
  10. let content = '';
  11. </script>
  12. <Modal size="md" bind:show>
  13. <div>
  14. <div class=" flex justify-between dark:text-gray-300 px-5 pt-4">
  15. <div class=" text-lg font-medium self-center">{$i18n.t('Add Content')}</div>
  16. <button
  17. class="self-center"
  18. on:click={() => {
  19. show = false;
  20. }}
  21. >
  22. <svg
  23. xmlns="http://www.w3.org/2000/svg"
  24. viewBox="0 0 20 20"
  25. fill="currentColor"
  26. class="w-5 h-5"
  27. >
  28. <path
  29. d="M6.28 5.22a.75.75 0 00-1.06 1.06L8.94 10l-3.72 3.72a.75.75 0 101.06 1.06L10 11.06l3.72 3.72a.75.75 0 101.06-1.06L11.06 10l3.72-3.72a.75.75 0 00-1.06-1.06L10 8.94 6.28 5.22z"
  30. />
  31. </svg>
  32. </button>
  33. </div>
  34. <div class="flex flex-col md:flex-row w-full px-5 py-4 md:space-x-4 dark:text-gray-200">
  35. <div class=" flex flex-col w-full sm:flex-row sm:justify-center sm:space-x-6">
  36. <form
  37. class="flex flex-col w-full"
  38. on:submit|preventDefault={() => {
  39. dispatch('submit', {
  40. name,
  41. content
  42. });
  43. show = false;
  44. name = '';
  45. content = '';
  46. }}
  47. >
  48. <div class="mb-3 w-full">
  49. <div class="w-full flex flex-col gap-2.5">
  50. <div class="w-full">
  51. <div class=" text-sm mb-2">Title</div>
  52. <div class="w-full mt-1">
  53. <input
  54. class="w-full rounded-lg py-2 px-4 text-sm bg-white dark:text-gray-300 dark:bg-gray-850 outline-none"
  55. type="text"
  56. bind:value={name}
  57. placeholder={`Name your content`}
  58. required
  59. />
  60. </div>
  61. </div>
  62. <div>
  63. <div class="text-sm mb-2">Content</div>
  64. <div class=" w-full mt-1">
  65. <textarea
  66. class="w-full resize-none rounded-lg py-2 px-4 text-sm bg-whites dark:text-gray-300 dark:bg-gray-850 outline-none"
  67. rows="10"
  68. bind:value={content}
  69. placeholder={`Write your content here`}
  70. required
  71. />
  72. </div>
  73. </div>
  74. </div>
  75. </div>
  76. <div class="flex justify-end text-sm font-medium">
  77. <button
  78. class=" px-4 py-2 bg-emerald-700 hover:bg-emerald-800 text-gray-100 transition rounded-lg"
  79. type="submit"
  80. >
  81. {$i18n.t('Add Content')}
  82. </button>
  83. </div>
  84. </form>
  85. </div>
  86. </div>
  87. </div>
  88. </Modal>
  89. <style>
  90. input::-webkit-outer-spin-button,
  91. input::-webkit-inner-spin-button {
  92. /* display: none; <- Crashes Chrome on hover */
  93. -webkit-appearance: none;
  94. margin: 0; /* <-- Apparently some margin are still there even though it's hidden */
  95. }
  96. .tabs::-webkit-scrollbar {
  97. display: none; /* for Chrome, Safari and Opera */
  98. }
  99. .tabs {
  100. -ms-overflow-style: none; /* IE and Edge */
  101. scrollbar-width: none; /* Firefox */
  102. }
  103. input[type='number'] {
  104. -moz-appearance: textfield; /* Firefox */
  105. }
  106. </style>