Skip to content

Commit

Permalink
Merge pull request #19 from josephting/table-preset
Browse files Browse the repository at this point in the history
Add table preset
  • Loading branch information
LucasLeandro1204 authored Mar 17, 2019
2 parents 53ff3e6 + 98c97fd commit b72e955
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 3 deletions.
1 change: 1 addition & 0 deletions docs/_sidebar.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
- [List](presets.md?id=list)
- [Bullet List](presets.md?id=bullet-list)
- [Twitch](presets.md?id=twitch)
- [Table](presets.md?id=table)

- Development
- [Getting started](development.md?id=development)
Expand Down
4 changes: 2 additions & 2 deletions docs/assets/js/app.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/assets/js/app.js.map

Large diffs are not rendered by default.

13 changes: 13 additions & 0 deletions docs/presets.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,16 @@
<vcl-twitch :primary="props.primary" :secondary="props.secondary" />
</template>
</color-switch>

### Table

| Custom Prop | Type | Default | Description |
|:-----------:|:-------:|:-------:|:-----------------:|
| rows | Number | 5 | Number of rows |
| columns | Number | 4 | Number of columns |

<color-switch>
<template slot-scope="props">
<vcl-table :primary="props.primary" :secondary="props.secondary" :rows="5" :columns="4" />
</template>
</color-switch>
53 changes: 53 additions & 0 deletions src/components/presets/Table.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<script>
import VueContentLoading from '../VueContentLoading.vue';
export default {
components: {
VueContentLoading,
},
props: {
header: {
default: true,
type: Boolean,
},
rows: {
default: 5,
type: Number,
},
columns: {
default: 4,
type: Number,
},
},
computed: {
height () {
return (this.rows * 30) - 20;
},
width () {
return ((this.columns - 1) * 20) + 10 + (this.columns * 100);
},
},
methods: {
getXPos (column) {
return 5 + ((column - 1) * 100) + ((column - 1) * 20);
},
getYPos (row) {
return (row - 1) * 30;
},
},
};
</script>

<template>
<vue-content-loading v-bind="$attrs" :width="width" :height="height">
<template v-for="r in rows">
<template v-for="c in columns">
<rect :key="r + '_' + c" :x="getXPos(c)" :y="getYPos(r)" rx="3" ry="3" :width="100" height="10" />
</template>
<rect :key="r + '_l'" v-if="r < rows" x="0" :y="getYPos(r) + 20" :width="width" height="1" />
</template>
</vue-content-loading>
</template>
2 changes: 2 additions & 0 deletions src/core/components.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import VclTwitch from '../components/presets/Twitch.vue';
import VclFacebook from '../components/presets/Facebook.vue';
import VclInstagram from '../components/presets/Instagram.vue';
import VclBulletList from '../components/presets/BulletList.vue';
import VclTable from '../components/presets/Table.vue';

export default VueContentLoading;

Expand All @@ -16,5 +17,6 @@ export {
VclFacebook,
VclInstagram,
VclBulletList,
VclTable,
VueContentLoading,
};

0 comments on commit b72e955

Please sign in to comment.