MultiLineTextInput.vue 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <template>
  2. <div>
  3. <!-- Send a label through props -->
  4. <label class="label">{{label}}</label>
  5. <!-- Iterate lines here -->
  6. <div class="multi-field field"
  7. v-for="(line, index) in lines"
  8. :key="line.value">
  9. <div class="control multi-control">
  10. <div class="multi-input-container">
  11. <input
  12. :value="line.value"
  13. placeholder="Add Something Nice (:"
  14. class="input is-medium multi-input"
  15. type="text">
  16. </div>
  17. <div class="btn-container">
  18. <!-- Delete the line -->
  19. <button
  20. @click.prevent="emitRemove(index)"
  21. type="button"
  22. class="button is-danger multi-button">
  23. Delete
  24. </button>
  25. </div>
  26. </div>
  27. </div>
  28. <!-- Add the Line -->
  29. <button
  30. @click="emitAdd"
  31. type="button"
  32. class="m-b-sm button is-medium is-link is-outlined">
  33. Add an answer
  34. </button>
  35. </div>
  36. </template>
  37. <script>
  38. export default {
  39. props:{
  40. label : {
  41. type: String,
  42. required: true
  43. },
  44. lines: {
  45. type: Array,
  46. required: true
  47. }
  48. },
  49. methods: {
  50. emitAdd() {
  51. this.$emit('addClicked')
  52. },
  53. emitRemove(index) {
  54. this.$emit('removeClicked', index)
  55. }
  56. }
  57. }
  58. </script>
  59. <style scoped lang="scss">
  60. .multi-input {
  61. float: left;
  62. width: 100%;
  63. }
  64. .multi-button {
  65. height: inherit;
  66. }
  67. .multi-input-container {
  68. display: flex;
  69. flex: 1;
  70. }
  71. .btn-container {
  72. display: flex;
  73. opacity: 0;
  74. }
  75. .multi-control {
  76. display: flex;
  77. &:hover > .btn-container {
  78. opacity: 1;
  79. }
  80. }
  81. </style>