AddTextContentModal.svelte 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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. if (name.trim() === '' || content.trim() === '') {
  40. toast.error($i18n.t('Please fill in all fields.'));
  41. name = '';
  42. content = '';
  43. return;
  44. }
  45. dispatch('submit', {
  46. name,
  47. content
  48. });
  49. show = false;
  50. name = '';
  51. content = '';
  52. }}
  53. >
  54. <div class="mb-3 w-full">
  55. <div class="w-full flex flex-col gap-2.5">
  56. <div class="w-full">
  57. <div class=" text-sm mb-2">Title</div>
  58. <div class="w-full mt-1">
  59. <input
  60. class="w-full rounded-lg py-2 px-4 text-sm bg-white dark:text-gray-300 dark:bg-gray-850 outline-none"
  61. type="text"
  62. bind:value={name}
  63. placeholder={`Name your content`}
  64. required
  65. />
  66. </div>
  67. </div>
  68. <div>
  69. <div class="text-sm mb-2">Content</div>
  70. <div class=" w-full mt-1">
  71. <textarea
  72. 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"
  73. rows="10"
  74. bind:value={content}
  75. placeholder={`Write your content here`}
  76. required
  77. />
  78. </div>
  79. </div>
  80. </div>
  81. </div>
  82. <div class="flex justify-end text-sm font-medium">
  83. <button
  84. class=" px-4 py-2 bg-emerald-700 hover:bg-emerald-800 text-gray-100 transition rounded-lg"
  85. type="submit"
  86. >
  87. {$i18n.t('Add Content')}
  88. </button>
  89. </div>
  90. </form>
  91. </div>
  92. </div>
  93. </div>
  94. </Modal>
  95. <style>
  96. input::-webkit-outer-spin-button,
  97. input::-webkit-inner-spin-button {
  98. /* display: none; <- Crashes Chrome on hover */
  99. -webkit-appearance: none;
  100. margin: 0; /* <-- Apparently some margin are still there even though it's hidden */
  101. }
  102. .tabs::-webkit-scrollbar {
  103. display: none; /* for Chrome, Safari and Opera */
  104. }
  105. .tabs {
  106. -ms-overflow-style: none; /* IE and Edge */
  107. scrollbar-width: none; /* Firefox */
  108. }
  109. input[type='number'] {
  110. -moz-appearance: textfield; /* Firefox */
  111. }
  112. </style>