LimitedTextField.vue 964 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <template>
  2. <div class="width">
  3. <textarea v-bind:class="{ textarea: true, not_enough: highlight && !isEnough, enough: highlight && isEnough }" type="text" v-model="inputText" />
  4. <SimpleProgressBar class="progbar" :count="len" max="270" steps="5"/>
  5. </div>
  6. </template>
  7. <script>
  8. import SimpleProgressBar from '../SimpleProgressBar.vue'
  9. export default {
  10. data() {
  11. return {
  12. inputText: '',
  13. }
  14. },
  15. props: [
  16. 'highlight'
  17. ],
  18. computed: {
  19. isEnough() {
  20. return this.inputText.length >= 270
  21. },
  22. len() {
  23. return this.inputText.length
  24. }
  25. },
  26. components: {
  27. SimpleProgressBar,
  28. },
  29. }
  30. </script>
  31. <style scoped>
  32. .textarea {
  33. width: 100%;
  34. min-height: 1.2em;
  35. resize: vertical;
  36. margin: auto;
  37. height: 5em;
  38. color: #fff;
  39. border: 1px solid #aaa;
  40. background-color: #222;
  41. }
  42. .not_enough {
  43. border: 1px solid #f00;
  44. }
  45. .enough {
  46. border: 1px solid #0f0;
  47. }
  48. .width {
  49. width: 100%;
  50. max-width: 60em;
  51. }
  52. </style>