Skip to content
This repository was archived by the owner on Apr 1, 2021. It is now read-only.

Commit 36fdd2a

Browse files
committed
add vue loading spinner
1 parent 7f2f2c7 commit 36fdd2a

File tree

10 files changed

+356
-322
lines changed

10 files changed

+356
-322
lines changed

package-lock.json

Lines changed: 225 additions & 317 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
},
2020
"devDependencies": {
2121
"babel-plugin-wildcard": "^5.0.0",
22+
"babel-preset-stage-2": "^6.24.1",
2223
"cross-env": "^5.1",
2324
"eslint": "^5.0.1",
2425
"eslint-config-standard": "^11.0.0",
@@ -49,6 +50,7 @@
4950
"simple-line-icons": "^2.4.1",
5051
"vue": "^2.5.16",
5152
"vue-chartjs": "^3.3.2",
53+
"vue-loading-spinner": "^1.0.11",
5254
"vue-notification": "^1.3.10",
5355
"vue-router": "^3.0.1",
5456
"vue-sweetalert2": "^1.4.2",

resources/assets/js/bootstrap.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
1-
window._ = require('lodash')
2-
window.Popper = require('popper.js').default
3-
window.Vue = require('vue')
4-
51
/**
62
* We'll load jQuery and the Bootstrap jQuery plugin which provides support
73
* for JavaScript based Bootstrap features such as modals and tabs. This
84
* code may be modified to fit the specific needs of your application.
95
*/
106

117
try {
8+
window._ = require('lodash')
129
window.$ = window.jQuery = require('jquery')
10+
window.Popper = require('popper.js').default
11+
window.Vue = require('vue')
12+
13+
// Lodash Improvement
14+
window._.mixin({ pascalCase: _.flow(_.camelCase, _.upperFirst) })
1315

1416
// Animate CSS
1517
window.$.fn.extend({

resources/assets/js/coreui/_nav.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,15 @@ export default {
207207
text : 'NEW',
208208
},
209209
},
210+
{
211+
name : 'Loading',
212+
url : '/loading',
213+
icon : 'icon-reload',
214+
badge: {
215+
variant: 'danger',
216+
text : 'HOT',
217+
},
218+
},
210219
{
211220
divider: true,
212221
},
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<template>
2+
<div :class="['spinner-container', { 'full-width': fullWidth || cover, 'full-height': fullHeight || cover}]">
3+
<component
4+
:is="cVariant"
5+
:size="cSize" />
6+
<div class="spinner-body">
7+
<slot/>
8+
</div>
9+
</div>
10+
</template>
11+
12+
<script>
13+
import * as Spinner from 'vue-loading-spinner'
14+
15+
export const COMPONENTS = _.mapKeys(Spinner, (value, key) => `Spinner${key}`)
16+
17+
export default {
18+
name : 'LoadingSpinner',
19+
components: {
20+
...COMPONENTS,
21+
},
22+
props: {
23+
variant: {
24+
type : String,
25+
default : 'rotate-square',
26+
validator: function (value) {
27+
return _.keys(Spinner).indexOf(_.pascalCase(value)) !== -1
28+
},
29+
},
30+
size: {
31+
type : Number,
32+
default: 40,
33+
},
34+
fullWidth : Boolean,
35+
fullHeight: Boolean,
36+
cover : Boolean,
37+
},
38+
computed: {
39+
cVariant () {
40+
return `Spinner${_.pascalCase(this.variant)}`
41+
},
42+
cSize () {
43+
return `${this.size}px`
44+
},
45+
},
46+
}
47+
</script>

resources/assets/js/coreui/main.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import Datepicker from 'vuejs-datepicker'
66
import { id } from 'vuejs-datepicker/dist/locale'
77
import Notifications from 'vue-notification'
88
import Sweetalert from 'vue-sweetalert2'
9+
import Loading from './components/Loading'
910
import App from './App'
1011
import router from './router'
1112
import store from './store'
@@ -14,6 +15,7 @@ Vue.use(BootstrapVue)
1415
Vue.use(Notifications)
1516
Vue.use(Sweetalert)
1617

18+
Vue.component('b-loading', Loading)
1719
Vue.component('b-datepicker', {
1820
extends: Datepicker,
1921
props : {

resources/assets/js/coreui/router/index.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import Typography from '@/views/theme/Typography'
1212

1313
import Charts from '@/views/Charts'
1414
import Widgets from '@/views/Widgets'
15+
import Loading from '@/views/Loading'
1516

1617
// Views - Components
1718
import Cards from '@/views/base/Cards'
@@ -100,6 +101,11 @@ export default new Router({
100101
name : 'Widgets',
101102
component: Widgets,
102103
},
104+
{
105+
path : 'loading',
106+
name : 'Loading',
107+
component: Loading,
108+
},
103109
{
104110
path : 'base',
105111
redirect : '/base/cards',
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<template>
2+
<div class="wrapper">
3+
<b-card header="Vue Loading Spinner">
4+
<b-row>
5+
<template v-for="variant in variants">
6+
<b-loading
7+
:variant="variant"
8+
:key="variant">
9+
{{ variant }}
10+
</b-loading>
11+
</template>
12+
</b-row>
13+
</b-card>
14+
<b-card header="Cover Size Loading">
15+
<b-loading
16+
variant="RotateSquare2"
17+
cover >
18+
Loading
19+
</b-loading>
20+
</b-card>
21+
</div>
22+
</template>
23+
24+
<script>
25+
import * as Spinner from 'vue-loading-spinner'
26+
27+
export default {
28+
name: 'Loading',
29+
data () {
30+
return {
31+
variants: _.keys(Spinner),
32+
}
33+
},
34+
}
35+
36+
</script>

resources/assets/sass/coreui/style.scss

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ $simple-line-font-path: '~simple-line-icons/fonts/';
1919
@import '~font-awesome/css/font-awesome.min.css';
2020
@import '~simple-line-icons/css/simple-line-icons.css';
2121
@import '~flag-icon-css/css/flag-icon.min.css';
22-
@import '~animate.css/animate.min.css';
22+
// @import '~animate.css/animate.min.css';
2323

2424
// Import Other CSS Module
2525

@@ -32,3 +32,4 @@ $simple-line-font-path: '~simple-line-icons/fonts/';
3232
// Custom styles
3333
@import 'custom';
3434
@import 'vendors/vue-notification/notification';
35+
@import 'vendors/vue-loading-spinner/spinner';
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
@import '~vue-loading-spinner/dist/vue-loading-spinner.css';
2+
3+
.spinner-container {
4+
display: flex;
5+
justify-content: center;
6+
align-items: center;
7+
flex-direction: column;
8+
min-height: 250px;
9+
min-width: 250px;
10+
width: 25%;
11+
overflow: hidden;
12+
.spinner-body {
13+
margin-top: 1rem;
14+
}
15+
&.full-width {
16+
width: 100%;
17+
}
18+
&.full-height {
19+
height: 100vh;
20+
}
21+
}

0 commit comments

Comments
 (0)