├── babel.config.js ├── public └── example.png ├── .gitignore ├── src ├── install.js └── components │ └── Stories.vue ├── LICENSE ├── package.json └── README.md /babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | presets: [ 3 | '@vue/cli-plugin-babel/preset' 4 | ] 5 | } 6 | -------------------------------------------------------------------------------- /public/example.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stfalcon-studio/vue-stories-instagram/HEAD/public/example.png -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules 3 | /dist 4 | 5 | 6 | # local env files 7 | .env.local 8 | .env.*.local 9 | 10 | # Log files 11 | npm-debug.log* 12 | yarn-debug.log* 13 | yarn-error.log* 14 | pnpm-debug.log* 15 | 16 | # Editor directories and files 17 | .idea 18 | .vscode 19 | *.suo 20 | *.ntvs* 21 | *.njsproj 22 | *.sln 23 | *.sw? 24 | -------------------------------------------------------------------------------- /src/install.js: -------------------------------------------------------------------------------- 1 | import component from "./components/Stories.vue"; 2 | 3 | export function install(Vue) { 4 | if (install.installed) return; 5 | install.installed = true; 6 | Vue.component('Stories', component); 7 | } 8 | 9 | const plugin = { 10 | install 11 | }; 12 | 13 | 14 | let GlobalVue = null; 15 | if (typeof window !== 'undefined') { 16 | GlobalVue = window.Vue; 17 | } else if (typeof global !== 'undefined') { 18 | GlobalVue = global.Vue; 19 | } 20 | if (GlobalVue) { 21 | GlobalVue.use(plugin); 22 | } 23 | 24 | export default component; -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 andriyliashok 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 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "vue-stories-instagram", 3 | "description": "A simple vuejs plugin to view stories like in Instagram", 4 | "version": "0.2.1", 5 | "private": false, 6 | "repository": "https://github.com/stfalcon-studio/vue-stories-instagram", 7 | "bugs": "https://github.com/stfalcon-studio/vue-stories-instagram/issues", 8 | "main": "dist/vue-stories-instagram.umd.js", 9 | "module": "dist/vue-stories-instagram.esm.js", 10 | "unpkg": "dist/vue-stories-instagram.min.js", 11 | "browser": { 12 | "./sfc": "src/components/Stories.vue" 13 | }, 14 | "scripts": { 15 | "build": "npm run build:umd & npm run build:es & npm run build:unpkg", 16 | "build:umd": "rollup --config build/rollup.config.js --format umd --file dist/vue-stories-instagram.umd.js", 17 | "build:es": "rollup --config build/rollup.config.js --format es --file dist/vue-stories-instagram.esm.js", 18 | "build:unpkg": "rollup --config build/rollup.config.js --format iife --file dist/vue-stories-instagram.min.js" 19 | }, 20 | "devDependencies": { 21 | "rollup": "^1.17.0", 22 | "@rollup/plugin-buble": "^0.21.3", 23 | "@rollup/plugin-commonjs": "^11.1.0", 24 | "rollup-plugin-vue": "^5.0.1", 25 | "vue": "^2.6.10", 26 | "vue-template-compiler": "^2.6.10", 27 | "sass": "^1.43.4", 28 | "sass-loader": "^10.2.0" 29 | }, 30 | "eslintConfig": { 31 | "root": true, 32 | "env": { 33 | "node": true 34 | }, 35 | "extends": [ 36 | "plugin:vue/essential", 37 | "eslint:recommended" 38 | ], 39 | "parserOptions": { 40 | "parser": "babel-eslint" 41 | }, 42 | "rules": {} 43 | }, 44 | "browserslist": [ 45 | "> 1%", 46 | "last 2 versions", 47 | "not dead" 48 | ] 49 | } 50 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # vue-stories-instagram 2 | 3 |
4 | 5 | Demo 6 | 7 | 8 | ## Simple usage 9 | ```vue 10 | 13 | 14 | 49 | ``` 50 | 51 | ### Props 52 | | Property | Type | Default | Description | 53 | |----------------------|------------------|----------|--------------------------------------------------------------------| 54 | | `stories` | [Array] | required | An array of story objects | 55 | | `duration` | Number | 3000 | Story duration in milliseconds | 56 | | `currentIndex` | Number | 0 | Select story by index | 57 | | `showInnerContent` | Boolean | false | Inner story content (scoped-slot) | 58 | | `showOuterContent` | Boolean | false | Outer story content (scoped-slot) | 59 | | **Events** | | | | 60 | | `allStoriesEnd` | Function() | - | Callback when all stories ends | 61 | | `сurrentImageEnd` | Function(index) | - | Callback when a current story image ends | 62 | | `сurrentAllImagesEnd`| Function(index) | - | Callback when a current story all images ends | 63 | | `closeStories` | Function() | - | Callback when click on close icon | 64 | 65 | ### Story Object 66 | | Property | Description | 67 | |------------|----------------------------------------------------------------------| 68 | | `username` | The user name. | 69 | | `picture` | The user pisture. | 70 | | `time` | The time when the story was added. | 71 | | `images` | The array of images or video. | 72 | | `url` | The url of the resource, image or video. | 73 | | `viewed` | Optional. marked story images as viewed | 74 | | `type` | Optional. Type of the story. `'image' \| 'video'` | 75 | 76 | 77 | ## With custom slot 78 | ```vue 79 | 116 | 117 | 160 | ``` -------------------------------------------------------------------------------- /src/components/Stories.vue: -------------------------------------------------------------------------------- 1 | 74 | 75 | 288 | 289 | 527 | --------------------------------------------------------------------------------