logo

pleroma-fe

My custom branche(s) on git.pleroma.social/pleroma/pleroma-fe git clone https://hacktivis.me/git/pleroma-fe.git

poll_form.vue (3315B)


  1. <template>
  2. <div
  3. v-if="visible"
  4. class="poll-form"
  5. >
  6. <div
  7. v-for="(option, index) in options"
  8. :key="index"
  9. class="poll-option"
  10. >
  11. <div class="input-container">
  12. <input
  13. :id="`poll-${index}`"
  14. v-model="options[index]"
  15. size="1"
  16. class="input poll-option-input"
  17. type="text"
  18. :placeholder="$t('polls.option')"
  19. :maxlength="maxLength"
  20. @change="updatePollToParent"
  21. @keydown.enter.stop.prevent="nextOption(index)"
  22. >
  23. </div>
  24. <button
  25. v-if="options.length > 2"
  26. class="delete-option button-unstyled -hover-highlight"
  27. @click="deleteOption(index)"
  28. >
  29. <FAIcon icon="times" />
  30. </button>
  31. </div>
  32. <button
  33. v-if="options.length < maxOptions"
  34. class="add-option faint button-unstyled -hover-highlight"
  35. @click="addOption"
  36. >
  37. <FAIcon
  38. icon="plus"
  39. size="sm"
  40. />
  41. {{ $t("polls.add_option") }}
  42. </button>
  43. <div class="poll-type-expiry">
  44. <div
  45. class="poll-type"
  46. :title="$t('polls.type')"
  47. >
  48. <Select
  49. v-model="pollType"
  50. class="poll-type-select"
  51. unstyled="true"
  52. @change="updatePollToParent"
  53. >
  54. <option value="single">
  55. {{ $t('polls.single_choice') }}
  56. </option>
  57. <option value="multiple">
  58. {{ $t('polls.multiple_choices') }}
  59. </option>
  60. </Select>
  61. </div>
  62. <div
  63. class="poll-expiry"
  64. :title="$t('polls.expiry')"
  65. >
  66. <input
  67. v-model="expiryAmount"
  68. type="number"
  69. class="input expiry-amount hide-number-spinner"
  70. :min="minExpirationInCurrentUnit"
  71. :max="maxExpirationInCurrentUnit"
  72. @change="expiryAmountChange"
  73. >
  74. {{ ' ' }}
  75. <Select
  76. v-model="expiryUnit"
  77. unstyled="true"
  78. class="expiry-unit"
  79. @change="expiryAmountChange"
  80. >
  81. <option
  82. v-for="unit in expiryUnits"
  83. :key="unit"
  84. :value="unit"
  85. >
  86. {{ $tc(`time.unit.${unit}_short`, expiryAmount, ['']) }}
  87. </option>
  88. </Select>
  89. </div>
  90. </div>
  91. </div>
  92. </template>
  93. <script src="./poll_form.js"></script>
  94. <style lang="scss">
  95. .poll-form {
  96. display: flex;
  97. flex-direction: column;
  98. padding: 0 0.5em 0.5em;
  99. .add-option {
  100. align-self: flex-start;
  101. padding-top: 0.25em;
  102. padding-left: 0.1em;
  103. }
  104. .poll-option {
  105. display: flex;
  106. align-items: baseline;
  107. justify-content: space-between;
  108. margin-bottom: 0.25em;
  109. }
  110. .input-container {
  111. width: 100%;
  112. input {
  113. // Hack: dodge the floating X icon
  114. padding-right: 2.5em;
  115. width: 100%;
  116. }
  117. }
  118. .delete-option {
  119. // Hack: Move the icon over the input box
  120. width: 1.5em;
  121. margin-left: -1.5em;
  122. z-index: 1;
  123. }
  124. .poll-type-expiry {
  125. margin-top: 0.5em;
  126. display: flex;
  127. width: 100%;
  128. }
  129. .poll-type {
  130. margin-right: 0.75em;
  131. flex: 1 1 60%;
  132. .poll-type-select {
  133. padding-right: 0.75em;
  134. }
  135. }
  136. .poll-expiry {
  137. display: flex;
  138. .expiry-amount {
  139. width: 3em;
  140. text-align: right;
  141. }
  142. }
  143. }
  144. </style>