add basic skeletons components

This commit is contained in:
Axolotle 2020-12-16 12:08:18 +01:00
parent b1fcfe2e13
commit 5077072747
6 changed files with 171 additions and 0 deletions

View file

@ -0,0 +1,32 @@
<template>
<b-card>
<template #header>
<b-skeleton width="30%" height="36px" class="m-0" />
</template>
<div v-for="count in itemCount" :key="count">
<template v-if="randint(0, 1)">
<b-skeleton width="100%" height="24px" />
<b-skeleton :width="randint(15, 60) + '%'" height="24px" />
</template>
<b-skeleton v-else :width="randint(45, 100) + '%'" height="24px" />
<b-skeleton :width="randint(20, 30) + '%'" height="38px" class="mt-3" />
<hr>
</div>
</b-card>
</template>
<script>
import { randint } from '@/helpers/commons'
export default {
name: 'CardButtonsSkeleton',
props: {
itemCount: { type: Number, default: 5 }
},
methods: { randint }
}
</script>

View file

@ -0,0 +1,52 @@
<template>
<b-card>
<template #header>
<b-skeleton width="30%" height="36px" class="m-0" />
</template>
<template v-for="count in itemCount">
<b-row :key="count" :class="{ 'd-block': cols === null }">
<b-col v-bind="cols">
<div style="height: 38px" class="d-flex align-items-center">
<b-skeleton class="m-0" :width="randint(45, 100) + '%'" height="24px" />
</div>
</b-col>
<b-col>
<div class="w100 d-flex justify-content-between" v-if="count % 2 === 0">
<b-skeleton width="100%" height="38px" />
<b-skeleton width="38px" height="38px" class="ml-2" />
</div>
<b-skeleton v-else width="100%" height="38px" />
<b-skeleton :width="randint(15, 35) + '%'" height="19px" />
</b-col>
</b-row>
<hr :key="count + '-hr'">
</template>
<template #footer>
<div class="d-flex justify-content-end w-100">
<b-skeleton width="100px" height="38px" />
</div>
</template>
</b-card>
</template>
<script>
import { randint } from '@/helpers/commons'
export default {
name: 'CardFormSkeleton',
props: {
itemCount: { type: Number, default: 5 },
cols: { type: [Object, null], default () { return { md: 4, lg: 2 } } }
},
methods: { randint }
}
</script>

View file

@ -0,0 +1,30 @@
<template>
<b-card>
<template #header>
<b-skeleton width="30%" height="36px" class="m-0" />
</template>
<b-row v-for="i in itemCount" :key="i" no-gutters>
<b-col cols="5" md="3" xl="3">
<b-skeleton :width="randint(45, 95) + '%'" height="19px" />
</b-col>
<b-col>
<b-skeleton :width="randint(10, 60) + '%'" height="19px" />
</b-col>
</b-row>
</b-card>
</template>
<script>
import { randint } from '@/helpers/commons'
export default {
name: 'CardInfoSkeleton',
props: {
itemCount: { type: Number, default: 5 }
},
methods: { randint }
}
</script>

View file

@ -0,0 +1,30 @@
<template>
<b-card no-body>
<template #header>
<b-skeleton width="30%" height="36px" class="m-0" />
</template>
<b-list-group flush>
<b-list-group-item v-for="count in itemCount" :key="count" class="d-flex">
<div style="width: 20%;">
<b-skeleton :width="randint(50, 100) + '%'" height="24px" class="mr-3" />
</div>
<b-skeleton :width="randint(30, 80) + '%'" height="24px" class="m-0" />
</b-list-group-item>
</b-list-group>
</b-card>
</template>
<script>
import { randint } from '@/helpers/commons'
export default {
name: 'CardListSkeleton',
props: {
itemCount: { type: Number, default: 5 }
},
methods: { randint }
}
</script>

View file

@ -0,0 +1,22 @@
<template>
<b-list-group>
<b-list-group-item v-for="count in itemCount" :key="count">
<b-skeleton :width="randint(15, 25) + '%'" height="24px" class="mb-2" />
<b-skeleton :width="randint(25, 50) + '%'" height="24px" class="m-0" />
</b-list-group-item>
</b-list-group>
</template>
<script>
import { randint } from '@/helpers/commons'
export default {
name: 'ListGroupSkeleton',
props: {
itemCount: { type: Number, default: 5 }
},
methods: { randint }
}
</script>

View file

@ -101,3 +101,8 @@ export function flattenObjectLiteral (obj, flattened = {}) {
export function arrayDiff (arr1 = [], arr2 = []) {
return arr1.filter(item => !arr2.includes(item))
}
export function randint (min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min
}