LimitedTextField.vue 980 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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="50" 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 >= 50
  21. },
  22. len() {
  23. return this.inputText.length
  24. }
  25. },
  26. mounted() {
  27. },
  28. components: {
  29. SimpleProgressBar,
  30. },
  31. }
  32. </script>
  33. <style scoped>
  34. .textarea {
  35. width: 100%;
  36. color: #fff;
  37. resize: vertical;
  38. min-height: 1.2em;
  39. height: 1.2em;
  40. border: 1px solid #aaa;
  41. margin: auto;
  42. background-color: #222;
  43. }
  44. .not_enough {
  45. border: 1px solid #f00;
  46. }
  47. .enough {
  48. border: 1px solid #0f0;
  49. }
  50. .width {
  51. width: 100%;
  52. max-width: 60em;
  53. }
  54. </style>