styling for input item
This commit is contained in:
parent
aeb212b5c9
commit
20140b16b4
3 changed files with 80 additions and 40 deletions
|
|
@ -45,3 +45,5 @@ PID 65740 received SIGSEGV for address: 0x7fbddef00000
|
||||||
0 segfault-handler.node 0x0000000116e6ae60 _ZL16segfault_handleriP9__siginfoPv + 304
|
0 segfault-handler.node 0x0000000116e6ae60 _ZL16segfault_handleriP9__siginfoPv + 304
|
||||||
PID 65817 received SIGSEGV for address: 0x7fe23f39d000
|
PID 65817 received SIGSEGV for address: 0x7fe23f39d000
|
||||||
0 segfault-handler.node 0x0000000110840e60 _ZL16segfault_handleriP9__siginfoPv + 304
|
0 segfault-handler.node 0x0000000110840e60 _ZL16segfault_handleriP9__siginfoPv + 304
|
||||||
|
PID 93442 received SIGSEGV for address: 0x7f91092e1000
|
||||||
|
0 segfault-handler.node 0x0000000111beae60 _ZL16segfault_handleriP9__siginfoPv + 304
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,7 @@ export default function useInputController() {
|
||||||
|
|
||||||
// send message on ENTER.
|
// send message on ENTER.
|
||||||
const onEnter = () => {
|
const onEnter = () => {
|
||||||
|
|
||||||
if (input.value) {
|
if (input.value) {
|
||||||
// remove first character of input.
|
// remove first character of input.
|
||||||
const text = input.value.substring(1);
|
const text = input.value.substring(1);
|
||||||
|
|
@ -48,10 +49,12 @@ export default function useInputController() {
|
||||||
if (textInput) textInput.value = '';
|
if (textInput) textInput.value = '';
|
||||||
input.value = " ";
|
input.value = " ";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// update input on keydown event & listen for special commands.
|
// update input on keydown event & listen for special commands.
|
||||||
const onKeyDown = (e: KeyboardEvent) => {
|
const onKeyDown = (e: KeyboardEvent) => {
|
||||||
|
|
||||||
if (textInput) textInput.focus();
|
if (textInput) textInput.focus();
|
||||||
|
|
||||||
// keyboardCharMap is an array of arrays, with each inner
|
// keyboardCharMap is an array of arrays, with each inner
|
||||||
|
|
@ -64,6 +67,7 @@ export default function useInputController() {
|
||||||
if (e.shiftKey) {
|
if (e.shiftKey) {
|
||||||
iCol = 1;
|
iCol = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ch = keyboardCharMap[e.keyCode][iCol];
|
const ch = keyboardCharMap[e.keyCode][iCol];
|
||||||
|
|
||||||
// Optionally do things with non-printables,
|
// Optionally do things with non-printables,
|
||||||
|
|
@ -84,6 +88,7 @@ export default function useInputController() {
|
||||||
default:
|
default:
|
||||||
input.value += ch;
|
input.value += ch;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// stop stream recording and render audio message on space key up event.
|
// stop stream recording and render audio message on space key up event.
|
||||||
|
|
@ -122,12 +127,16 @@ export default function useInputController() {
|
||||||
|
|
||||||
// watch keyboard input & update current state.
|
// watch keyboard input & update current state.
|
||||||
watch(input, (input, prevInput) => {
|
watch(input, (input, prevInput) => {
|
||||||
|
|
||||||
|
//
|
||||||
if (prevInput !== "" || prevInput.length > 0) {
|
if (prevInput !== "" || prevInput.length > 0) {
|
||||||
if (!isRecording.value) {
|
if (!isRecording.value) {
|
||||||
isTyping.value = true;
|
isTyping.value = true;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
if (input === " " && isRecording.value === false) {
|
if (input === " " && isRecording.value === false) {
|
||||||
isTyping.value = false;
|
isTyping.value = false;
|
||||||
isRecording.value = true;
|
isRecording.value = true;
|
||||||
|
|
@ -137,7 +146,9 @@ export default function useInputController() {
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
isTyping.value = true;
|
isTyping.value = true;
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
|
||||||
|
|
@ -5,16 +5,21 @@
|
||||||
:class="{ playing: isRecording }"
|
:class="{ playing: isRecording }"
|
||||||
:style="{ top: `${elementY}px`, left: `${elementX}px` }"
|
:style="{ top: `${elementY}px`, left: `${elementX}px` }"
|
||||||
>
|
>
|
||||||
|
|
||||||
|
<!-- animations for recording and on-standby -->
|
||||||
<span v-if="isRecording" class="play"></span>
|
<span v-if="isRecording" class="play"></span>
|
||||||
<span v-if="isRecording" class="pause"></span>
|
<span v-if="isRecording" class="pause">
|
||||||
<div class="text-input" v-show="isTyping && input.length > 0">
|
<div class="rec-icon"></div>
|
||||||
<div class="initials">A</div>
|
</span>
|
||||||
<input id="textInput" type="text" />
|
|
||||||
</div>
|
<!-- Show text input on key-down -->
|
||||||
|
<input id="textInput" type="text" v-show="isTyping && input.length > 0"/>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
|
||||||
import { defineComponent } from "vue";
|
import { defineComponent } from "vue";
|
||||||
import draggify from "@/modules/draggify";
|
import draggify from "@/modules/draggify";
|
||||||
import useInputController from "./inputController";
|
import useInputController from "./inputController";
|
||||||
|
|
@ -22,7 +27,11 @@ import useInputController from "./inputController";
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: "InputItem",
|
name: "InputItem",
|
||||||
setup() {
|
setup() {
|
||||||
|
|
||||||
|
// Calculate position of inputItem on drag.
|
||||||
const { elementX, elementY } = draggify({ elementId: "inputItem" });
|
const { elementX, elementY } = draggify({ elementId: "inputItem" });
|
||||||
|
|
||||||
|
//
|
||||||
const { input, isRecording, isTyping } = useInputController();
|
const { input, isRecording, isTyping } = useInputController();
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
@ -37,52 +46,69 @@ export default defineComponent({
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
.text-input {
|
|
||||||
position: absolute;
|
#textInput {
|
||||||
top: 50%;
|
width: 150px;
|
||||||
display: flex;
|
height: 36px;
|
||||||
flex-direction: row;
|
|
||||||
justify-content: space-between;
|
border-top-right-radius: 18px;
|
||||||
align-items: center;
|
border-bottom-right-radius: 18px;
|
||||||
left: 50%;
|
|
||||||
background-color: #fff;
|
padding: 0;
|
||||||
transform: translate(-12%, -50%);
|
margin-left: 18px;
|
||||||
border-radius: 25px;
|
|
||||||
input {
|
outline: none;
|
||||||
border-top-right-radius: 25px;
|
border: none;
|
||||||
border-bottom-right-radius: 25px;
|
pointer-events: none;
|
||||||
padding-top: 10px;
|
animation-name: expand;
|
||||||
padding-bottom: 10px;
|
animation-duration: 0.5s;
|
||||||
outline: none;
|
}
|
||||||
border: none;
|
|
||||||
pointer-events: none;
|
@keyframes expand {
|
||||||
|
from {
|
||||||
|
width: 0px;
|
||||||
}
|
}
|
||||||
.initials {
|
to {
|
||||||
border-radius: 50%;
|
width: 150px;
|
||||||
width: 35px;
|
}
|
||||||
height: 35px;
|
}
|
||||||
display: flex;
|
|
||||||
text-align: center;
|
.rec-icon {
|
||||||
justify-content: center;
|
width: 8px;
|
||||||
align-items: center;
|
height: 8px;
|
||||||
|
border-radius: 4px;
|
||||||
|
background-color: red;
|
||||||
|
transform: translate(14px);
|
||||||
|
|
||||||
|
animation-name: rec;
|
||||||
|
animation-duration: 0.5s;
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes rec {
|
||||||
|
from {
|
||||||
|
transform: translate(14px) scale(0.3);
|
||||||
|
}
|
||||||
|
to {
|
||||||
|
transform: translate(14px) scale(1.0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.input-item {
|
.input-item {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
|
|
||||||
width: 30px;
|
display: flex;
|
||||||
height: 30px;
|
align-items: center;
|
||||||
|
|
||||||
border-radius: 19px;
|
padding: 0;
|
||||||
|
|
||||||
|
width: 36px;
|
||||||
|
height: 36px;
|
||||||
|
|
||||||
|
border-radius: 18px;
|
||||||
|
|
||||||
z-index: 20;
|
z-index: 20;
|
||||||
|
|
||||||
top: 200px;
|
|
||||||
right: 0px;
|
|
||||||
|
|
||||||
background-color: white;
|
background-color: white;
|
||||||
border: 4px solid #C3C3C3;
|
|
||||||
|
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
|
||||||
|
|
@ -174,4 +200,5 @@ export default defineComponent({
|
||||||
box-shadow: 0 0 0 0.55em rgba(195, 195, 195, 0.45);
|
box-shadow: 0 0 0 0.55em rgba(195, 195, 195, 0.45);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue