Skip to content

Commit de5da0f

Browse files
committed
Added Paginator (first version), Added eslint
1 parent 0078406 commit de5da0f

File tree

14 files changed

+2066
-86
lines changed

14 files changed

+2066
-86
lines changed

.eslintrc.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
module.exports = {
2+
extends: [
3+
"eslint:recommended",
4+
'plugin:vue/vue3-recommended',
5+
],
6+
rules: {
7+
"indent": [
8+
"error",
9+
4,
10+
],
11+
"vue/html-indent": 0,
12+
"vue/max-attributes-per-line": 0,
13+
}
14+
}

README.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33
Simple DataTable with slots, class and style modification for tr and td, sortable by columns (only graphics with click event).
44

5-
<img src="https://github.com/BitTheCat/tailwind-vue-data-table/blob/main/tvdatatable.jpg"/>
5+
Contains the TVPaginator component that can be disabled via prop or used in stand-alone mode.
6+
7+
<img src="https://github.com/BitTheCat/tailwind-vue-data-table/blob/main/assets/tvdatatable.jpg"/>
68

79
### Install
810
```
@@ -15,7 +17,10 @@ import { TVTable } from '@bitthecat/tailwind-vue-data-table'
1517
```
1618

1719
### Next additions
18-
- Pagination (can be disabled)
20+
- Pagination (can be disabled) ✔️
21+
22+
<img src="https://github.com/BitTheCat/tailwind-vue-data-table/blob/main/assets/tvpagination.jpg"/>
23+
1924
- Select row column (with checkbox)
2025
- Row detail
2126
- ...
File renamed without changes.

assets/tvpagination.jpg

11.8 KB
Loading

dev/Table.vue renamed to dev/TableShow.vue

Lines changed: 32 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,28 @@
11
<template>
2-
<div class="grid gap-4">
3-
<span class="text-xs"> Simple </span>
4-
<TVTable
5-
:items="items"
6-
:fields="fieldsSimple"
7-
>
8-
</TVTable>
9-
2+
<div>
3+
<div class="mb-3">
4+
<span class="text-xs "> Simple </span>
5+
<TVTable
6+
:items="items"
7+
:fields="fieldsSimple"
8+
/>
9+
</div>
1010
<hr>
11-
12-
<span class="text-xs">With Props</span>
13-
<TVTable
14-
:items="items"
15-
:fields="fields"
16-
multiple-sortable
17-
>
18-
<template #cell:username="{ item }">
19-
{{ item.emoji }} - {{ item.username }}
20-
</template>
21-
</TVTable>
22-
23-
11+
<div>
12+
<span class="text-xs">With Props</span>
13+
<TVTable
14+
:items="filterItems"
15+
:fields="fields"
16+
multiple-sortable
17+
:total-rows="items.length"
18+
:per-page="perPage"
19+
@change-page="changePage"
20+
>
21+
<template #cell:username="{ item }">
22+
{{ item.emoji }} - {{ item.username }}
23+
</template>
24+
</TVTable>
25+
</div>
2426
</div>
2527
</template>
2628

@@ -29,7 +31,7 @@ import { defineComponent, ref } from 'vue';
2931
import TVTable from '../src/components/TVTable.vue';
3032
3133
defineComponent({
32-
name: 'Table',
34+
name: 'TableShow',
3335
})
3436
3537
const fields = ref([
@@ -93,4 +95,12 @@ const items = ref([
9395
},
9496
])
9597
98+
const perPage = ref(2)
99+
100+
const filterItems = ref(items.value.slice(0, 1 * perPage.value))
101+
102+
const changePage = (values) => {
103+
filterItems.value = items.value.slice(values.from, values.to)
104+
}
105+
96106
</script>
File renamed without changes.

dev/router.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import { createRouter, createWebHistory } from 'vue-router';
22

3-
import Table from './Table.vue'
3+
import TableShow from './TableShow.vue'
44

55
const routes = [
6-
{ path: '/', component: Table },
6+
{ path: '/', component: TableShow },
77
];
88

99
const router = createRouter({
10-
history: createWebHistory(),
11-
routes,
10+
history: createWebHistory(),
11+
routes,
1212
});
1313

1414
export default router;

index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@
77
</head>
88
<body>
99
<div id="app"></div>
10-
<script type="module" src="/dev/main.ts"></script>
10+
<script type="module" src="/dev/main.js"></script>
1111
</body>
1212
</html>

0 commit comments

Comments
 (0)