From c6b4c6a90a3bb77add64994f51d3e2af790c8452 Mon Sep 17 00:00:00 2001 From: jdlugosz963 Date: Fri, 17 Dec 2021 00:22:38 +0100 Subject: make styles and add some features --- src/assets/css/tailwind.css | 31 ++++++++++++++++++ src/components/group/GroupMaker.vue | 21 +++++++++--- src/components/group/GroupSender.vue | 62 +++++++++++++++++++++++++---------- src/components/group/Message.vue | 20 +++-------- src/components/searcher/Searcher.vue | 41 +++++------------------ src/components/searcher/Sugestion.vue | 21 +----------- src/main.js | 2 ++ src/services/ChatService.js | 12 +++++++ src/views/Home.vue | 52 ++++++++++++++++++++++++++--- src/views/Login.vue | 12 +++---- src/views/Register.vue | 14 ++++---- 11 files changed, 182 insertions(+), 106 deletions(-) create mode 100644 src/assets/css/tailwind.css (limited to 'src') diff --git a/src/assets/css/tailwind.css b/src/assets/css/tailwind.css new file mode 100644 index 0000000..1028353 --- /dev/null +++ b/src/assets/css/tailwind.css @@ -0,0 +1,31 @@ +@tailwind base; +@tailwind components; +@tailwind utilities; + +@layer base { + .inset-center { + position: absolute; + top: 50%; + left: 50%; + transform: translate(-50%, -50%); + } + + kbd { + @apply bg-gray-600; + @apply p-1; + @apply rounded-md; + @apply border-gray-800; + @apply font-fira; + } + + .searcher { + @apply inset-center; + @apply w-2/3; + @apply h-90; + @apply shadow-lg; + @apply bg-gray-900; + @apply p-4 rounded-lg; + @apply border-2; + @apply border-blue-900; + } +} diff --git a/src/components/group/GroupMaker.vue b/src/components/group/GroupMaker.vue index f3da293..06963e3 100644 --- a/src/components/group/GroupMaker.vue +++ b/src/components/group/GroupMaker.vue @@ -1,15 +1,17 @@ @@ -69,6 +73,15 @@ export default { this.close() console.log(this.users) + }, + + hotkeys(e) { + switch(e.code) { + case 'Delete': + e.preventDefault() + this.$emit('close') + break + } } }, diff --git a/src/components/group/GroupSender.vue b/src/components/group/GroupSender.vue index ba36949..a815561 100644 --- a/src/components/group/GroupSender.vue +++ b/src/components/group/GroupSender.vue @@ -1,12 +1,25 @@ @@ -20,6 +33,7 @@ export default { return { message: "", messages: [], + isFocus: false } }, @@ -45,13 +59,38 @@ export default { console.log(data) - if(status===200) + if(status===200){ this.messages = data.messages + this.scroll_down() + } }, push_message(message) { - if(message.receiver == this.group.id) + if(message.receiver == this.group.id){ this.messages.push(message) + this.scroll_down() + } + }, + + scroll_down() { + this.$nextTick(function () { + const messages = this.$refs.messages + console.log(messages) + messages.scrollTop = messages.scrollHeight + }) + }, + + hotkeys(e) { + switch(e.code) { + case 'Delete': + e.preventDefault() + this.$emit('close', this.group.id) + break + case 'Escape': + e.preventDefault() + this.$refs.input.blur() + break + } } }, @@ -72,14 +111,3 @@ export default { } } - - diff --git a/src/components/group/Message.vue b/src/components/group/Message.vue index eedcc6e..556deb9 100644 --- a/src/components/group/Message.vue +++ b/src/components/group/Message.vue @@ -1,8 +1,8 @@ @@ -29,15 +29,3 @@ export default { } } - - diff --git a/src/components/searcher/Searcher.vue b/src/components/searcher/Searcher.vue index f8dd51f..e74600a 100644 --- a/src/components/searcher/Searcher.vue +++ b/src/components/searcher/Searcher.vue @@ -1,7 +1,8 @@ @@ -72,7 +73,11 @@ export default { hotkeys(e) { switch(e.code) { - case 'Escape': + case 'Escape': + e.preventDefault() + this.close() + break + case 'Delete': e.preventDefault() this.close() break @@ -127,31 +132,3 @@ export default { } } - - diff --git a/src/components/searcher/Sugestion.vue b/src/components/searcher/Sugestion.vue index 4721ca2..15a177d 100644 --- a/src/components/searcher/Sugestion.vue +++ b/src/components/searcher/Sugestion.vue @@ -1,5 +1,5 @@ @@ -9,24 +9,5 @@ export default { props: { sugestion: Array }, - - created() { - this.$nextTick(function () { - }) - } - } - - diff --git a/src/main.js b/src/main.js index fd31090..50babcd 100644 --- a/src/main.js +++ b/src/main.js @@ -6,6 +6,8 @@ import Axios from 'axios' import Notifications from 'vue-notification' import VueHotkey from 'v-hotkey' +import '@/assets/css/tailwind.css' + Vue.config.productionTip = false Axios.defaults.headers.common['Authorization'] = store.state.token !== "" && `Token ${store.state.token}`; diff --git a/src/services/ChatService.js b/src/services/ChatService.js index d077e9b..d03f250 100644 --- a/src/services/ChatService.js +++ b/src/services/ChatService.js @@ -37,5 +37,17 @@ export default { } }) .catch(error => error_notify(error)) + }, + + async get_group_detail(group_pk) { + return await axios + .get(url+`groups/detail/${group_pk}/`) + .then(res => { + return { + status: res.status, + data: res.data + } + }) + .catch(error => error_notify(error)) } } diff --git a/src/views/Home.vue b/src/views/Home.vue index d85760b..205a260 100644 --- a/src/views/Home.vue +++ b/src/views/Home.vue @@ -1,11 +1,19 @@