Skip to content

Commit 98c97fd

Browse files
committed
Add table preset
1 parent 53ff3e6 commit 98c97fd

File tree

6 files changed

+72
-3
lines changed

6 files changed

+72
-3
lines changed

docs/_sidebar.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
- [List](presets.md?id=list)
1616
- [Bullet List](presets.md?id=bullet-list)
1717
- [Twitch](presets.md?id=twitch)
18+
- [Table](presets.md?id=table)
1819

1920
- Development
2021
- [Getting started](development.md?id=development)

docs/assets/js/app.js

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

docs/assets/js/app.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/presets.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,16 @@
5151
<vcl-twitch :primary="props.primary" :secondary="props.secondary" />
5252
</template>
5353
</color-switch>
54+
55+
### Table
56+
57+
| Custom Prop | Type | Default | Description |
58+
|:-----------:|:-------:|:-------:|:-----------------:|
59+
| rows | Number | 5 | Number of rows |
60+
| columns | Number | 4 | Number of columns |
61+
62+
<color-switch>
63+
<template slot-scope="props">
64+
<vcl-table :primary="props.primary" :secondary="props.secondary" :rows="5" :columns="4" />
65+
</template>
66+
</color-switch>

src/components/presets/Table.vue

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<script>
2+
import VueContentLoading from '../VueContentLoading.vue';
3+
4+
export default {
5+
components: {
6+
VueContentLoading,
7+
},
8+
9+
props: {
10+
header: {
11+
default: true,
12+
type: Boolean,
13+
},
14+
rows: {
15+
default: 5,
16+
type: Number,
17+
},
18+
columns: {
19+
default: 4,
20+
type: Number,
21+
},
22+
},
23+
24+
computed: {
25+
height () {
26+
return (this.rows * 30) - 20;
27+
},
28+
width () {
29+
return ((this.columns - 1) * 20) + 10 + (this.columns * 100);
30+
},
31+
},
32+
33+
methods: {
34+
getXPos (column) {
35+
return 5 + ((column - 1) * 100) + ((column - 1) * 20);
36+
},
37+
getYPos (row) {
38+
return (row - 1) * 30;
39+
},
40+
},
41+
};
42+
</script>
43+
44+
<template>
45+
<vue-content-loading v-bind="$attrs" :width="width" :height="height">
46+
<template v-for="r in rows">
47+
<template v-for="c in columns">
48+
<rect :key="r + '_' + c" :x="getXPos(c)" :y="getYPos(r)" rx="3" ry="3" :width="100" height="10" />
49+
</template>
50+
<rect :key="r + '_l'" v-if="r < rows" x="0" :y="getYPos(r) + 20" :width="width" height="1" />
51+
</template>
52+
</vue-content-loading>
53+
</template>

src/core/components.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import VclTwitch from '../components/presets/Twitch.vue';
66
import VclFacebook from '../components/presets/Facebook.vue';
77
import VclInstagram from '../components/presets/Instagram.vue';
88
import VclBulletList from '../components/presets/BulletList.vue';
9+
import VclTable from '../components/presets/Table.vue';
910

1011
export default VueContentLoading;
1112

@@ -16,5 +17,6 @@ export {
1617
VclFacebook,
1718
VclInstagram,
1819
VclBulletList,
20+
VclTable,
1921
VueContentLoading,
2022
};

0 commit comments

Comments
 (0)