├── .gitignore ├── .gitattributes ├── src ├── index.js └── vue-loading-button.vue ├── LICENSE ├── examples └── example.vue ├── package.json └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | /node_modules/ 2 | /dist/ -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /src/index.js: -------------------------------------------------------------------------------- 1 | import component from "./vue-loading-button.vue"; 2 | 3 | // install function executed by Vue.use() 4 | export function install(Vue) { 5 | if (install.installed) return; 6 | install.installed = true; 7 | Vue.component("VueLoadingButton", component); 8 | } 9 | 10 | // create module definition for Vue.use() 11 | const plugin = { 12 | install 13 | }; 14 | 15 | // auto-install when vue is found 16 | let GlobalVue = null; 17 | if (typeof window !== "undefined") { 18 | GlobalVue = window.Vue; 19 | } else if (typeof global !== "undefined") { 20 | GlobalVue = global.Vue; 21 | } 22 | if (GlobalVue) { 23 | GlobalVue.use(plugin); 24 | } 25 | 26 | export default component; 27 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 William L 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. -------------------------------------------------------------------------------- /examples/example.vue: -------------------------------------------------------------------------------- 1 | 23 | 24 | 46 | 47 | 57 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "vue-loading-button", 3 | "version": "0.2.0", 4 | "description": "A Vue button component with slideout loading indicator", 5 | "license": "MIT", 6 | "main": "dist/vue-loading-button.umd.js", 7 | "module": "dist/vue-loading-button.esm.js", 8 | "unpkg": "dist/vue-loading-button.min.js", 9 | "browser": { 10 | "./sfc": "src/vue-loading-button.vue" 11 | }, 12 | "scripts": { 13 | "example": "vue serve ./examples/example.vue", 14 | "build": "npm run build:unpkg & npm run build:es & npm run build:umd", 15 | "build:umd": "rollup --config build/rollup.config.js --format umd --file dist/vue-loading-button.umd.js", 16 | "build:es": "rollup --config build/rollup.config.js --format es --file dist/vue-loading-button.esm.js", 17 | "build:unpkg": "rollup --config build/rollup.config.js --format iife --file dist/vue-loading-button.min.js" 18 | }, 19 | "keywords": [ 20 | "vue", 21 | "component", 22 | "button", 23 | "loading", 24 | "load", 25 | "indicator", 26 | "spinner" 27 | ], 28 | "repository": { 29 | "type": "git", 30 | "url": "https://github.com/shwilliam/vue-loading-button.git" 31 | }, 32 | "bugs": { 33 | "url": "https://github.com/shwilliam/vue-loading-button/issues" 34 | }, 35 | "homepage": "https://github.com/shwilliam/vue-loading-button#readme", 36 | "dependencies": {}, 37 | "devDependencies": { 38 | "minimist": "^1.2.0", 39 | "rollup": "^0.57.1", 40 | "rollup-plugin-buble": "^0.19.2", 41 | "rollup-plugin-uglify-es": "0.0.1", 42 | "rollup-plugin-vue": "^4.6.1", 43 | "vue": "^2.5.16", 44 | "vue-template-compiler": "^2.5.16" 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # vue-loading-button 2 | 3 | > Straightforward Vue button with slideout loading indicator 4 | 5 |

6 | Component example use 7 |

8 | 9 | [![try it on codesandbox](https://codesandbox.io/static/img/play-codesandbox.svg)](https://codesandbox.io/s/4zywwyjxw7) 10 | 11 | ## Props 12 | 13 | | Prop | Type | Required | Default | Description | 14 | | ------- | ------- | -------- | ------- | ------------------------------------ | 15 | | loading | boolean | false | false | Controls loading indicator animation | 16 | | styled | boolean | false | false | Enables opinionated sample styles | 17 | 18 | ## Installation 19 | 20 | Install the package from npm by running: 21 | 22 | ``` 23 | $ npm i vue-loading-button 24 | ``` 25 | 26 | or 27 | 28 | ``` 29 | $ yarn add vue-loading-button 30 | ``` 31 | 32 | ## Usage 33 | 34 | Import, register and place the component in your Vue app. 35 | 36 | ```html 37 | 40 | ``` 41 | 42 | ```js 43 | import VueLoadingButton from 'vue-loading-button' 44 | 45 | export default { 46 | components: { 47 | VueLoadingButton, 48 | }, 49 | } 50 | ``` 51 | 52 | >

Unstyled component example use

53 | > Note: By default, this button component will apply minimal styles to enable you to easily add your own implementation-specific CSS. To enable the more opinionated styles seen at the top of this file, pass a `styled` prop as `true` to the button. 54 | 55 | ## Accessibility 56 | 57 | Apply attributes, such as aria-label, directly on the element to apply them to the button. 58 | 59 | ```html 60 | 63 | ``` 64 | 65 | ## Dev 66 | 67 | Running example script requires @vue/cli and @vue/cli-service-global to be installed. 68 | Install globally by running `npm i --g @vue/cli @vue/cli-service-global` or `yarn add global vue/cli @vue/cli-service-global`. 69 | 70 | ## Contributing 71 | 72 | This project is open to and encourages contributions! Feel free to discuss any bug fixes/features in the [issues](https://github.com/shwilliam/vue-loading-button/issues). If you wish to work on this project: 73 | 74 | 1. [Fork the project](https://github.com/shwilliam/vue-loading-button/archive/master.zip) 75 | 2. Create your feature branch (`git checkout -b new-feature-branch`) 76 | 3. Commit your changes (`git commit -am 'add new feature'`) 77 | 4. Push to the branch (`git push origin new-feature-branch`) 78 | 5. [Submit a pull request!](https://github.com/shwilliam/vue-loading-button/pull/new/master) 79 | -------------------------------------------------------------------------------- /src/vue-loading-button.vue: -------------------------------------------------------------------------------- 1 | 20 | 21 | 38 | 39 | 171 | --------------------------------------------------------------------------------