JSFiddle - React, Tailwind, and code Playground

Vue message entry

by Christopher O

HTML

<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.15/lodash.min.js"></script>
<div id="app">
  <h2>Agent One:</h2><br>
  <div class="footOut">
    <div class="footC1 footC">
      <input type="text" class="footInput" placeholder="Type a message" v-model.trim="msg"  @input="keyd" maxlength="153">
    </div>
    <div class="footC2 footC">
      🚀
    </div>
    <br class="clear">
   </div><br><br><br>
    
    
  <h2>Agent Two:</h2><br>
  <div class="footOut">
    <div :class="['footC1', 'footC', locked ? 'footInuse' : '']">
      <input type="text" class="footInput" placeholder="Type a message" v-model="msg2" :disabled="locked" maxlength="153">
      <span class="footCover" v-if="locked">Agent One is typing. Please wait.</span>
    </div>
    <div  :class="['footC2', 'footC', locked ? 'footInuse' : '']">
      🚀
    </div>
    <br class="clear">
    
  </div>

</div>

CSS

body {
  background: #20262E;
  padding: 20px;
  font-family: Helvetica;
}

#app {
  background: #fff;
  border-radius: 4px;
  padding: 20px;
  transition: all 0.2s;
  height: 200px;
  width: 550px;
}


.footC {
  box-shadow: 0 2px 10px grey;
  border-radius: 40px;
  height: 40px;
  /* color: black; */
  background-color: white;
}

.footInuse {
  background-color: #ccc !important;
  /* border: 1px dashed #aaa !important; */
  color: #aaa !important;
}

.footInuse input {
  color: #aaa !important;
}

.footC1 {
  width: 500px;
  float: left;
  position: relative;
  /* border: 1px solid red; */
}

.footC2 {
  width: 40px;
  float: right;
  text-align: center;
  font-size: 25px;
}
.footC2:hover {
  color: blue;
}

.footInput {
  width: 70%;
  height: 28px;
  margin: 4px 4px 4px 16px;
  padding: 0;
  border: 0;
  background: transparent;
}

.clear {
  clear: all;
}

input:hover, select:hover, input:active, select:active, input:focus, select:focus, input:disabled, select:disabled, textarea:disabled {
  outline: none;
}

/* .footC1 {
  position: relative;
} */

.footCover{
    color: #fff;
    border: 2px solid #AEAEAE;
    border-radius: 30px;
    background: #605F61;
    font-size: 16px;
    font-weight: bold;
    display: inline-block;
    line-height: 0px;
    padding: 11px;
}

div.footC1 .footCover  {
    position: absolute;
    display: block;
    top: -18px;
    left: 22%;
}

Vue

console.clear();
var myTimeout;

var VUE = new Vue({
  el: "#app",
  data: {
  msg: "",
  msg2: "",
  locked: false,
  bla: "",
  pos: 0,
    todos: [
      { text: "Learn JavaScript", done: false },
      { text: "Learn Vue", done: false },
      { text: "Play around in JSFiddle", done: true },
      { text: "Build something awesome", done: true }
    ]
  },
  methods: {
  	toggle: function(todo){
    	todo.done = !todo.done
    },
    keyd: _.debounce(($event) => {
    	// debounce runs function after N insince last time called
    	console.log("d: "+VUE.msg);
      VUE.msg2 = VUE.msg;
      VUE.locked = true;
      clearTimeout(myTimeout);
      myTimeout = setTimeout(function(){ VUE.locked = false; }, 3000);
    }, 500, {"maxWait": 1000, "leading": true, "trailing": true}),
  }
});

/* document.getElementById('foobar').addEventListener('keyup', e => {
  console.log('Caret at: ', e.target.selectionStart)
}) */