]> Repos - mime-chat/commitdiff
frontend ui enhacements
authorAndrew Gundersen <gundersena@xavier.edu>
Mon, 22 Feb 2021 02:42:02 +0000 (20:42 -0600)
committerAndrew Gundersen <gundersena@xavier.edu>
Mon, 22 Feb 2021 02:42:02 +0000 (20:42 -0600)
13 files changed:
src/App.vue
src/components/messageView/index.vue
src/components/messageView/mockMessages.ts [deleted file]
src/components/messageView/viewDetails/offsetCalculator.ts
src/components/messageView/viewDetails/transitions.ts
src/components/taInput/index.vue
src/components/taInput/inputController.ts
src/components/taInput/textDetails/text.vue
src/components/taInput/textDetails/textVisualizer.ts
src/components/textBubble/bubbleDetails/computed.ts
src/components/textBubble/index.vue
src/modules/scrollView.ts
src/views/home.vue

index 8f6d51d119e5bda71d250ebf9a123fb69f549721..99315a23e9d1aceb14c4bc4914386e5ff1fc1c76 100644 (file)
   }
 
   #app {
+    font-family: "SF Pro Text";
+
     -webkit-font-smoothing: antialiased;
     -moz-osx-font-smoothing: grayscale;
 
-    color: #2c3e50;
-
     height: 100vh;
     width: 100vw;
 
     width: 100vw;
     height: 54px;
 
-    -webkit-user-select: none;
-    -webkit-app-region: drag;
+    opacity: 0.75;
 
-    background-color: red;
+    background-color: #EBEBEB;
 
-    opacity: 0.0;
+    -webkit-user-select: none;
+    -webkit-app-region: drag;
 
     border: none;
-    outline:none;
+    outline: none;
 
   }
 
index d75ef739491a6892b36b58d13cd0d7cd94113f15..58d19e873726c1e59267bdbd737a6ebdd9a71198 100644 (file)
 
 <script lang="ts">
 
-
-// mock messages
-import Messages from "./mockMessages";
-
-
 import TextBubble from "@/components/textBubble/index.vue";
+
 import { Message } from "@/types/message/index";
+import { useIpc } from "@/modules/ipc";
+import { Queue } from '@/modules/queue';
+
 import useTransitions from "./viewDetails/transitions";
 import useScrollView from "@/modules/scrollView";
+
 import useMitt from "@/modules/mitt";
-import { useIpc } from "@/modules/ipc";
-import { Queue } from '@/modules/queue';
+
 import { defineComponent, reactive, onMounted, onUnmounted, watch, ref } from "vue";
 
 export default defineComponent({
+  
   name: "MessageView",
   components: { TextBubble },
   
@@ -47,24 +47,13 @@ export default defineComponent({
     const renderQ = new Queue();
 
     const { invoke } = useIpc("message");
+
+    // Each method will be called on their respective lifecycle event.
     const { beforeEnter, enter, afterEnter, rendering } = useTransitions();
     const { scrollView } = useScrollView({
       targetId: "messageView",
     });
 
-
-    const messages = Messages;
-    const count = ref(0);
-
-    function emittMessage() {
-      console.log("emitting mock message")
-      if (count.value < messages.length) {
-        emitter.emit("render-message", messages[count.value]);
-        count.value++;
-        return;
-      }
-    }
-
     const render = (m: Message) => {
       if (rendering.value) {
         renderQ.enqueue(m);
@@ -81,6 +70,8 @@ export default defineComponent({
     })
 
     onMounted(() => {
+
+      // Call render function on event "render-message."
       window.ipcRenderer.on("render-message", (event, payload) => {
         const m = payload.message;
         if (m.content) render(m);
@@ -107,8 +98,17 @@ export default defineComponent({
       enter,
       afterEnter,
       scrollView,
-      emittMessage,
     };
   },
 });
 </script>
+
+<style lang="scss" scoped>
+
+  #messageView {
+    width: 1000px;
+    height: 100vh;
+    color: red;
+  }
+
+</style>
diff --git a/src/components/messageView/mockMessages.ts b/src/components/messageView/mockMessages.ts
deleted file mode 100644 (file)
index 6284c82..0000000
+++ /dev/null
@@ -1,161 +0,0 @@
-import { Message } from "@/types/message/index";
-
-const Messages: Message[] = [
-    {
-        content: "Welcome",
-        context: "ai",
-        subContext: "",
-        modifier: "ai",
-        id: "2",
-        time: ""
-    },
-    {
-        content:
-            "add friend",
-        context: "launch",
-        subContext: "",
-        modifier: "sf",
-        id: "1",
-        time: ""
-    },
-    {
-        content: "Did you mean to addcontact?",
-        context: "addcontact",
-        subContext: "",
-        modifier: "ai",
-        id: "5",
-        time: ""
-    },
-    {
-        content: "yes",
-        context: "fulfill",
-        subContext: "",
-        modifier: "sf",
-        id: "6",
-        time: ""
-    },
-
-    {
-        content: "Hey Anna, did you get the paper done?",
-        context: "Mesage from Tommy McConville",
-        subContext: "New Conversation",
-        modifier: "ai",
-        id: "3",
-        time: ""
-    },
-    {
-        content: "Hey do you know Enrique Hernandez?",
-        context: "Message from Crimata",
-        subContext: "",
-        modifier: "ai",
-        id: "7",
-        time: ""
-    },
-
-    {
-        content: "Yes posting it online soon.",
-        context: "You to Tommy McConville",
-        subContext: "",
-        modifier: "sf",
-        id: "4",
-        time: ""
-    },
-    {
-        content: "Hey do you know Enrique Hernandez?",
-        context: "Message from Crimata",
-        subContext: "",
-        modifier: "ai",
-        id: "8",
-        time: ""
-    },
-    {
-        content: "Hey Anna, did you get the paper done?",
-        context: "Message from Tommy McConville",
-        subContext: "",
-        modifier: "ai",
-        id: "9",
-        time: ""
-    },
-    {
-        content: "Hey Anna, did you get the paper done?",
-        context: "Message from Tommy McConville",
-        subContext: "",
-        modifier: "ai",
-        id: "10",
-        time: ""
-    },
-    {
-        content: "Yes posting it online soon.",
-        context: "Message from Tommy McConville",
-        subContext: "",
-        modifier: "sf",
-        id: "11",
-        time: ""
-    },
-    {
-        content:
-            "I can be there at 5 pm tomorrow to greet you at a Chick file with my almond and chive salad.",
-        context: "You to Tommy McConville",
-        subContext: "",
-        modifier: "sf",
-        id: "12",
-        time: ""
-    },
-    {
-        content: "Hey Anna, did you get the paper done?",
-        context: "Message from Tommy McConville",
-        subContext: "",
-        modifier: "ai",
-        id: "13",
-        time: ""
-    },
-    {
-        content: "Hey Anna, did you get the paper done?",
-        context: "Message from Tommy McConville",
-        subContext: "",
-        modifier: "ai",
-        id: "14",
-        time: ""
-    },
-    {
-        content: "Yes posting it online soon.",
-        context: "You to Tommy McConville",
-        subContext: "",
-        modifier: "sf",
-        id: "15",
-        time: ""
-    },
-    {
-        content: "Sweet, thanks!",
-        context: "Message from Tommy McConville",
-        subContext: "",
-        modifier: "ai",
-        id: "16",
-        time: ""
-    },
-    {
-        content: "Hey do you know Enrique Hernandez?",
-        context: "Message from Crimata AI",
-        subContext: "",
-        modifier: "ai",
-        id: "17",
-        time: ""
-    },
-    {
-        content: "Yes posting it online soon.",
-        context: "You to Tommy McConville",
-        subContext: "",
-        modifier: "sf",
-        id: "18",
-        time: ""
-    },
-    {
-        content: "Sweet, thanks!",
-        context: "Message from Tommy McConville",
-        subContext: "",
-        modifier: "ai",
-        id: "19",
-        time: ""
-    },
-];
-export default Messages;
\ No newline at end of file
index a04e5ab4e26a2e6e92a999de79f2f958e90ece36..01be800f2311ee4384ae1b58f749bbe1e47e4437 100644 (file)
@@ -5,7 +5,7 @@ import { ref } from "vue";
 export default function useOffsetCalculator() {
     const xOffset = ref(0);
     const yOffset = ref(0);
-    const firstChildMarginTop = 0;
+    const firstChildMarginTop = 45;
     let previousMessageHeight = 0;
     const messagePadding = 15;
 
index 8d85701800191c92440782b59f6cd2a3dbfa3797..493725ebf5246d0582317f55bf97f422b53c52c1 100644 (file)
@@ -33,9 +33,12 @@ export default function useTransitions() {
 
     const animateMessage = async (el: SVGGElement) => {
 
+        // Where the message gets translated to.
         const elTransform = `translate(${messageOffset.x} ${messageOffset.y})`;
+
         const viewTransform = `translate(0 ${-vB})`;
 
+        // Shift of view height > window height.
         if (shift) {
             await shiftAnimate(el, elTransform, messageView, viewTransform);
         } else {
@@ -44,6 +47,7 @@ export default function useTransitions() {
         rendering.value = false;
     }
 
+    // Get height of messageView.
     const beforeEnter: VueTransitionCallback = () => {
         rendering.value = true;
         // query DOM for messageView element
index 91fb57074540acfeda601d065683f08a88130d01..b0f3a2877ac00c51609a6ebd8fdacf131133803b 100644 (file)
@@ -1,17 +1,33 @@
 <template>
-  <audio-stream v-if="visualizeStream" :bubbleWidth="audioBubbleWidth" :paths="paths" />
-  <text-input v-else :input="input" :textXoffset="textInputXoffset" />
+
+  <!-- render audio or text input-->
+  <AudioStream 
+    v-if="visualizeStream" 
+    :bubbleWidth="audioBubbleWidth" 
+    :paths="paths" 
+  />
+
+  <TextInput 
+    v-else 
+    :input="input" 
+    :textXoffset="textInputXoffset"
+    :textYoffset="textInputYoffset"
+  />
+
 </template>
 
 <script lang="ts">
-// input child components
+
+// import child components
 import TextInput from "./textDetails/text.vue";
 import AudioStream from "./audioDetails/audio.vue";
 
 import useInputController from "./inputController";
 
 import { defineComponent } from "vue";
+
 export default defineComponent({
+  
   name: "TextAudioInput",
   components: { TextInput, AudioStream },
   setup() {
@@ -24,14 +40,20 @@ export default defineComponent({
     const {
       input,
       visualizeStream,
+
       textInputXoffset,
+      textInputYoffset,
+
       audioBubbleWidth,
       paths,
     } = useInputController();
 
     return {
       input,
+      
       textInputXoffset,
+      textInputYoffset,
+
       visualizeStream,
       audioBubbleWidth,
       paths,
index e7eda4c7a7b6c5900c184d1bfe211fc155245a7e..20bf438610ed7d23d45be17c9f9874e650ba6ff9 100644 (file)
@@ -32,9 +32,18 @@ export default function useInputController() {
         emitter.emit("user-message", message);
     }
 
-    const { visualizeStreamAsPaths, expandBubble } = useAudioVisualizer(visualizeStream);
+    const { 
+        visualizeStreamAsPaths, 
+        expandBubble 
+    } = useAudioVisualizer(visualizeStream);
+
     const { keyDownHandler, input } = useKeyDownHandler(enterCallback);
-    const { textInputXoffset, renderTextInput } = useTextVisualizer(input);
+
+    const { 
+        textInputXoffset, 
+        textInputYoffset,
+        renderTextInput 
+    } = useTextVisualizer(input);
 
     // stops stream recording on space key up
     function keyupHandler(e: any) {
@@ -83,6 +92,7 @@ export default function useInputController() {
         input,
         visualizeStream,
         textInputXoffset,
+        textInputYoffset,
         audioBubbleWidth,
         paths
     }
index 886633e545528aaf171882a10476926627400669..eb16b7748e32ed4dc2ea91ab043534e1ae461bf7 100644 (file)
@@ -1,38 +1,52 @@
 <template>
-  <foreignObject class="inputContainer" :x="textXoffset" y="450" width="55%" height="50%">
+
+  <foreignObject 
+    class="inputContainer" 
+    :x="textXoffset" 
+    :y="textYoffset" 
+    width="55%" 
+    height="50%"
+  >
     <div xmlns="http://www.w3.org/1999/xhtml">
-      <div class="inputBubble" contenteditable v-show="input.length > 0" font-family="SF Pro">
+      <div class="inputBubble" v-show="input.length > 0">
         <p>{{ input }}</p>
       </div>
     </div>
+
   </foreignObject>
+
 </template>
 
 <script lang="ts">
+
 import { defineComponent } from "vue";
+
 export default defineComponent({
+
   name: "TextInput",
   props: {
     input: String,
     textXoffset: String,
+    textYoffset: String,
   },
 });
+
 </script>
 
 <style lang="scss" scoped>
-div[contenteditable] {
-  width: auto;
+.inputBubble {
+
   max-width: 180px;
-  height: auto;
-  min-height: 36px;
+  min-height: 32px;
+
   display: table;
   justify-items: center;
-  border: 0;
+
   border-radius: 10px;
-  color: #000;
-  background-color: #b9b9b9;
-  font-size: 14;
-  text-align: left;
+  background-color: #B9B9B9;
+
+  font-size: 14px;
+
   p {
     max-width: 150px;
     overflow-wrap: break-word;
index 4b3c89c37cc7c8c5d5a2f6ccea899dad349eff5e..e41da04b3a71ea7351af0e2da6903ad3b728bf5b 100644 (file)
@@ -50,8 +50,13 @@ export default function useTextVisualizer(input: Ref<string>) {
         return `calc(50% - ${inputWidth.value / 2})`;
     });
 
+    const textInputYoffset = computed(() => {
+        return `calc(97% - ${inputHeight.value})`;
+    });
+
     return {
         textInputXoffset,
+        textInputYoffset,
         renderTextInput
     }
 }
index c3b47695478715b6eb7e8faa580a11c36c8ed38b..a2e9fa2b5e7f0d9610f66178b66ee9fa59bde60d 100644 (file)
@@ -6,6 +6,7 @@ import { computed, onMounted, ref } from "vue";
 export default function useComputedBubble(m: string, id: string) {
     const x = ref(0)
     const paddingLeft = 30;
+
     const winW = 350;
     const messageWidth = ref(0);
     const messageMarginTop = 75;
@@ -39,7 +40,7 @@ export default function useComputedBubble(m: string, id: string) {
     const calculateXoffset = async () => {
         switch (m) {
             case "sf":
-                x.value = winW - messageWidth.value - selfMessageMarginRight;
+                x.value = 800 - messageWidth.value - selfMessageMarginRight;
                 break;
             default:
                 x.value = paddingLeft;
index a19ac84d77388888b33e35bc5e6ab56e28485456..5ac976f21956fac94a2e9c9d305a3609663ed180 100644 (file)
@@ -1,7 +1,7 @@
 <template>
   <g :id="item.id" :class="item.modifier" :transform="startingOffset">
     <rect ref="messageRect" x="30" y="10" width="196" height="63" rx="10" :fill="bubbleFill" />
-    <text font-size="14" font-family="SF Pro" ref="messageText" :fill="textFill">
+    <text font-size="14" font-family="SF Pro Text" ref="messageText" :fill="textFill">
       <tspan dy="16" x="0" v-for="(item, index) in textArr" :key="index">{{ item }}</tspan>
     </text>
     <g :transform="signatureTranslate">
index 303266737e76798e92d1a38980177210f598b377..7184f72157fe1eaeda73346942ef706901a40d90 100644 (file)
@@ -12,30 +12,44 @@ export default function useScrollView({ targetId }: { targetId: string }) {
   let topBound: number;
   const scrollStartHeight = 445;
 
-  const clampedScroll = computed(() => {
-    if (targetHeight.value === 0) { return 0; }
-    topBound = -targetHeight.value + 450;
-    return Math.max(topBound, Math.min(scroll.value, 0)) as number;
-  })
-
   const scrollView = computed(() => {
+
     if (clampedScroll.value === 0) {
       scroll.value = 0;
     } else if (clampedScroll.value === topBound) {
       scroll.value = topBound;
     }
+
+    // x, y, width, height
+    // width and height should be dynamic
     return `0 ${clampedScroll.value} 350 500`;
   });
 
+  const clampedScroll = computed(() => {
+    if (targetHeight.value === 0) { return 0; }
+    topBound = -targetHeight.value + 450;
+    return Math.max(topBound, Math.min(scroll.value, 0)) as number;
+  })
+
   const getHeight = () => {
     if (scrollTarget) {
       return scrollTarget.getBoundingClientRect().height as number;
     }
   }
 
+  const getWidth = () => {
+    if (scrollTarget) {
+      return scrollTarget.getBoundingClientRect().width as number;
+    }
+  }
+
   const updateView = (verticalScroll: number) => {
+
     if (scrollTarget) {
+
       const heightResult = getHeight();
+      const widthResult = getWidth();
+
       if (heightResult) {
         // only scroll if renderer scrollStart
         if (heightResult > scrollStartHeight) {
index 341a81a1bf0b982bb8155cf7ee8707369d9530e8..401b35abacec5838950b53cc7ff1b7fca40173ed 100644 (file)
 
 <script lang="ts">
 
+// Home consists on MessageView and Text/Audio imput component.
 import MessageView from "@/components/messageView/index.vue";
 import TextAudioInput from "@/components/taInput/index.vue";
+
 import { defineComponent } from "vue";
 
 export default defineComponent({
   name: "Messenger",
   components: { MessageView, TextAudioInput },
 });
+
 </script>
 
 <style lang="scss" scoped>