├── .gitignore ├── .npmignore ├── LICENSE ├── README.md ├── babel.config.js ├── package-lock.json ├── package.json ├── src ├── components │ └── Chat.vue └── index.js └── vue.config.js /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | **.DS_Store 3 | .vscode 4 | dist/ 5 | build/ 6 | npm-debug.log* 7 | logs 8 | *.log 9 | .npm 10 | .eslintcache 11 | *.tgz -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | *.map -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 David Davis 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # vue-chat-widget 2 | `vue-chat-widget` is a simple chat window that can be included easily in any Vue project. It is backend agnostic and as such provides no messaging facilities, only the UI component. 3 |
4 | 5 | ![Demo gif of react-chat-window being used](https://media.giphy.com/media/XEsOASAkabaoCm1chn/source.gif) 6 | 7 | ## Features 8 | 9 | - Customizeable 10 | - Backend agnostic 11 | - No file input's or emojis 12 | - Free 13 | 14 | ## [Demo](https://vue-chat-window-david-j-davis.marmt-group.now.sh/) 15 | 16 | ## Table of Contents 17 | - [Installation](#installation) 18 | - [Example](#example) 19 | - [Components](#components) 20 | - [Backend Example with WebSockets](#backend) 21 | 22 | ## Installation 23 | 24 | ``` 25 | $ npm install vue-chat-widget 26 | ``` 27 | 28 | ## Example 29 | 30 | ``` javascript 31 | 45 | 46 | 101 | ``` 102 | 103 | ## Notification Sound 104 | 105 | Implement your own notification mp3 sound “🔔”, or [download this mp3 file](https://www.dropbox.com/s/fnnjo8cyxj8ovgf/notification.mp3?dl=1). 106 | 107 | ## Components 108 | 109 | ## Chat 110 | 111 | `Chat` is the only component needed to use vue-chat-widget. It will react dynamically to changes in messages. All new messages must be added via a change in props as shown in the example. 112 | 113 | Launcher props: 114 | 115 | | prop | type | required | description | 116 | |------------------|--------|----------|-------------| 117 | | iconColorProp | String | no | Set icon color for close and open icons. Defaults to `#e6e6e6`| 118 | | messageOutColorProp | String | no | Set color of outgoing messages. Defaults to `#3d7e9a` | 119 | | messageInColorProp | String | no | Set color of incoming messages. Defaults to `#f1f0f0` | 120 | | messageBackgroundColorProp | String | no | Set background color of message area. Default to `#ffffff` | 121 | | initOpenProp | Boolean | yes | Force the open/close state of the chat window on mount. | 122 | | messageListProp | Array [[message](#message-objects)] | yes | An array of message objects to be rendered as a conversation. | 123 | | @onToggleOpen | event | yes | Event emitted when chat window is open and closed. | 124 | | @onMessageWasSent | function([message](#message-objects)) | yes | Emitted when a message is sent, with a message object as an argument. | 125 | 126 | 127 | ### Message Objects 128 | 129 | Message objects are rendered differently depending on their type. Currently, only text types are supported. Each message object has an `author` field which can have the value 'you' or 'them'. 130 | 131 | ``` javascript 132 | { 133 | author: 'them', 134 | body: 'some text' 135 | } 136 | 137 | { 138 | author: 'you', 139 | body: 'some text' 140 | } 141 | 142 | ``` 143 | 144 | ## Backend 145 | 146 | For an example frontend using vue-chat-widget and websockets, [look here](https://gist.github.com/david-j-davis/afcd4bcceaa7562f91604b945dd3f8b0). For an accompanying backend in Node.js for this, [look here](https://gist.github.com/david-j-davis/5f88958874a0acdf0a9bde30ddfc1a23). -------------------------------------------------------------------------------- /babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | presets: [ 3 | '@vue/app' 4 | ] 5 | } -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "vue-chat-widget", 3 | "version": "0.3.2", 4 | "private": false, 5 | "description": "A lean Vue.js chat ui that is backend agnostic", 6 | "main": "./dist/vue-chat-widget.common.js", 7 | "files": [ 8 | "dist/" 9 | ], 10 | "scripts": { 11 | "serve": "vue-cli-service serve", 12 | "build": "vue-cli-service build", 13 | "build-bundle": "vue-cli-service build --target lib --name vue-chat-widget ./src/index.js", 14 | "lint": "vue-cli-service lint", 15 | "publish": "npm publish --access public" 16 | }, 17 | "keywords": [ 18 | "vuejs chat", 19 | "vue chat widget", 20 | "vue chat ui", 21 | "vue chat socket", 22 | "vue simple chat" 23 | ], 24 | "author": "david-j-davis ", 25 | "repository": { 26 | "type": "git", 27 | "url": "https://github.com/Marmt-Group/app-vue-chat-widget" 28 | }, 29 | "bugs": { 30 | "url": "https://github.com/Marmt-Group/app-vue-chat-widget/issues" 31 | }, 32 | "license": "MIT", 33 | "dependencies": { 34 | "core-js": "^3.2.1", 35 | "vue": "^2.6.10", 36 | "vue-icon": "^2.1.1" 37 | }, 38 | "devDependencies": { 39 | "@vue/cli-plugin-babel": "^3.11.0", 40 | "@vue/cli-plugin-eslint": "^3.11.0", 41 | "@vue/cli-service": "^3.11.0", 42 | "babel-core": "^6.26.3", 43 | "babel-eslint": "^10.0.3", 44 | "eslint-plugin-vue": "^5.2.3", 45 | "vue-template-compiler": "^2.6.10" 46 | }, 47 | "eslintConfig": { 48 | "root": true, 49 | "env": { 50 | "node": true 51 | }, 52 | "extends": [ 53 | "plugin:vue/essential", 54 | "eslint:recommended" 55 | ], 56 | "rules": {}, 57 | "parserOptions": { 58 | "parser": "babel-eslint" 59 | } 60 | }, 61 | "postcss": { 62 | "plugins": { 63 | "autoprefixer": {} 64 | } 65 | }, 66 | "browserslist": [ 67 | "> 1%", 68 | "last 2 versions" 69 | ] 70 | } 71 | -------------------------------------------------------------------------------- /src/components/Chat.vue: -------------------------------------------------------------------------------- 1 | 26 | 27 | 91 | 92 | 222 | -------------------------------------------------------------------------------- /src/index.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | import feather from 'vue-icon' 3 | Vue.config.productionTip = false 4 | Vue.use(feather, 'v-icon') 5 | 6 | export { default as Chat } from './components/Chat.vue' -------------------------------------------------------------------------------- /vue.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | css: { extract: false } 3 | } --------------------------------------------------------------------------------