├── .github └── no-response.yml ├── package.json ├── LICENSE ├── README.md └── v-snackbars.vue /.github/no-response.yml: -------------------------------------------------------------------------------- 1 | # Configuration for probot-no-response - https://github.com/probot/no-response 2 | 3 | # Number of days of inactivity before an Issue is closed for lack of response 4 | daysUntilClose: 5 5 | # Label requiring a response 6 | responseRequiredLabel: waiting-for-requestor 7 | # Comment to post when closing an Issue for lack of response. Set to `false` to disable 8 | closeComment: > 9 | This issue has been automatically closed because the requestor didn't provide any additional comment. 10 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "v-snackbars", 3 | "version": "3.2.8", 4 | "description": "Display the v-snackbar (from Vuetify) with a stack display", 5 | "main": "v-snackbars.vue", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "repository": { 10 | "type": "git", 11 | "url": "git+https://github.com/Aymkdn/v-snackbars.git" 12 | }, 13 | "keywords": [ 14 | "vuetify" 15 | ], 16 | "author": "aymkdn", 17 | "license": "MIT", 18 | "bugs": { 19 | "url": "https://github.com/Aymkdn/v-snackbars/issues" 20 | }, 21 | "homepage": "https://github.com/Aymkdn/v-snackbars#readme" 22 | } 23 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Aymeric 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. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # v-snackbars 2 | Display the `v-snackbar` (from Vuetify) with a stack display 3 | 4 | ![Capture](https://user-images.githubusercontent.com/946315/86259071-d8468480-bbbb-11ea-9eca-3aac7d9be455.PNG) 5 | 6 | ## Requirements 7 | 8 | [Vuetify](https://www.npmjs.com/package/vuetify) > v2.3 (it may work with an earlier version of Vuetify but I haven't tested) 9 | 10 | ## Install 11 | 12 | ```bash 13 | npm install v-snackbars 14 | ``` 15 | 16 | ## Demo 17 | 18 | See it in action: https://codesandbox.io/s/v-snackbars-demo-8xrbr?file=/src/App.vue 19 | 20 | ## How to use 21 | 22 | ```js 23 | import VSnackbars from "v-snackbars" 24 | export default { 25 | components:{ 26 | "v-snackbars": VSnackbars 27 | }, 28 | […] 29 | } 30 | ``` 31 | 32 | ```vue 33 | 34 | ``` 35 | 36 | You need to provide a `messages` array. Using a `push` on the array will cause the text to be shown in a snackbar. 37 | 38 | For example, to display _"This is a message"_, just do the below: 39 | ```javascript 40 | this.messages.push("This is a message"); 41 | ``` 42 | 43 | You can use the same options as the `v-snackbar`. For example: 44 | ```vue 45 | 46 | ``` 47 | 48 | ### Options 49 | 50 | #### Snackbar Options 51 | 52 | The same [`v-snackbar` options](https://vuetifyjs.com/en/components/snackbars/) should be applicable, like `bottom`, `right`, `left`, `top`, `color`, `timeout`, …. 53 | 54 | ### Personalized content 55 | 56 | You can use `v-slot:default` to customize the content of the snackbar. 57 | 58 | For example: 59 | ```vue 60 | 61 | 65 | 66 | ``` 67 | 68 | The parameter: 69 | - `message`: the current message that is displayed in the notification 70 | - `id`: the unique key/id of the message 71 | - `index`: the index in the array of notifications/messages 72 | 73 | #### Personalized button 74 | 75 | A `close` button is used by default. If you prefer to define your own action button, you can use a ` v-slot:action`. 76 | 77 | For example: 78 | ```vue 79 | 80 | 83 | 84 | ``` 85 | 86 | By clicking on `Dismiss`, it will remove the related snackbar. 87 | 88 | The parameters: 89 | - `close`: the function to remove a notification 90 | - `index`: the index in the array of notifications/messages 91 | - `message`: the current message that is displayed in the notification 92 | - `id`: the unique key/id of the message 93 | 94 | ## Objects 95 | 96 | If you want to customize each snackbar, you can also pass a `objects` instead of `messages`, which will contain the various props (like `message`, `color`, `timeout`, `transition`, `contentClass` or the position). 97 | 98 | In the JavaScript code: 99 | ```javascript 100 | this.objects.push({ 101 | message:"Success", 102 | color:"green", 103 | timeout:5000 104 | }) 105 | this.objects.push({ 106 | message:"Error", 107 | color:"red", 108 | timeout:-1 109 | }) 110 | ``` 111 | 112 | In your Vue template: 113 | ```vue 114 | 115 | ``` 116 | 117 | Check the **"Random Toast"** button on the [demo](https://codesandbox.io/s/v-snackbars-demo-8xrbr?file=/src/App.vue). 118 | 119 | ## Interactivity 120 | 121 | You can add some layers of interactivity with the messages. 122 | 123 | For example, you can change the text by doing: 124 | ```javascript 125 | this.$set(this.messages, i, "New message to display"); 126 | ``` 127 | 128 | To remove a notification, you'll have to use `splice`: 129 | ```javascript 130 | this.messages.splice(i, 1); 131 | ``` 132 | 133 | Check the **"Show Interactivity"** button on the [demo](https://codesandbox.io/s/v-snackbars-demo-8xrbr?file=/src/App.vue). 134 | -------------------------------------------------------------------------------- /v-snackbars.vue: -------------------------------------------------------------------------------- 1 | 48 | 49 | 339 | --------------------------------------------------------------------------------