Skip to content

Commit 3a06651

Browse files
committed
Fixed TVTable & TVPagination, Update README
1 parent 791e898 commit 3a06651

File tree

5 files changed

+21
-12
lines changed

5 files changed

+21
-12
lines changed

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,15 @@ Contains the TVPaginator component that can be disabled via prop or used in stan
1111
npm i @bitthecat/tailwind-vue-data-table
1212
```
1313

14+
Add this code inside **tailwind.config.*** to compile the css library
15+
16+
``` js
17+
content: [
18+
...
19+
'./node_modules/@bitthecat/tailwind-vue-data-table/dist/*.js',
20+
],
21+
```
22+
1423
### Use in Vue
1524
``` js
1625
import { TVTable } from '@bitthecat/tailwind-vue-data-table'

dev/TableShow.vue

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
<div>
1212
<span class="text-xs">With Props</span>
1313
<TVTable
14+
v-model:currentPage="currentPage"
1415
:items="filterItems"
1516
:fields="fields"
1617
multiple-sortable
@@ -95,6 +96,8 @@ const items = ref([
9596
},
9697
])
9798
99+
const currentPage = ref(1)
100+
98101
const perPage = ref(2)
99102
100103
const filterItems = ref(items.value.slice(0, 1 * perPage.value))

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@bitthecat/tailwind-vue-data-table",
3-
"version": "0.1.1",
3+
"version": "0.1.2",
44
"keywords": [
55
"tailwindcss",
66
"vue",

src/components/TVPagination.vue

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
</div>
2929
<div class="sm:flex hidden">
3030
<template v-for="page of pages" :key="`page_${page}`">
31-
<p :class="paginationClass(page)" @click="changePage(page)">
31+
<p class="text-sm font-medium leading-none cursor-pointer link px-2" :class="paginationClass(page)" @click="changePage(page)">
3232
{{ page }}
3333
</p>
3434
</template>
@@ -121,9 +121,7 @@ const pages = computed(() => {
121121
})
122122
123123
const paginationClass = (page) => {
124-
let classes = [
125-
'text-sm font-medium leading-none cursor-pointer link px-2',
126-
]
124+
let classes = []
127125
if (page === props.currentPage) {
128126
classes.push('rounded-xl bg-gray-400 text-white')
129127
}

src/components/TVTable.vue

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<template>
2-
<div v-if="!hidePagination && !hideSummary" class="flex items-center justify-end mr-2 mb-2 text-xs font-small text-body">
2+
<div v-if="!hidePagination && totalRows != 0" class="flex items-center justify-end mr-2 mb-2 text-xs font-small text-body">
33
<span>Displaying {{ fromRow + 1 }} to {{ toRow }} of {{ totalRows }} items</span>
44
</div>
55

@@ -67,9 +67,9 @@
6767
</table>
6868

6969
<TVPagination
70-
v-if="totalRows > perPage && !hidePagination"
70+
v-if="localTotalRows > perPage && !hidePagination"
7171
v-model:currentPage="localCurrentPage"
72-
:total-rows="totalRows"
72+
:total-rows="localTotalRows"
7373
:per-page="perPage"
7474
/>
7575
</template>
@@ -103,14 +103,13 @@ const props = defineProps({
103103
type: Number,
104104
default: 15
105105
},
106-
hideSummary: Boolean,
107106
hidePagination: Boolean,
108107
multipleSortable: Boolean,
109108
})
110109
111110
const emit = defineEmits(['updateSortable', 'changePage'])
112111
113-
const totalRows = ref(props.totalRows || props.items.length || 0)
112+
const localTotalRows = ref(props.totalRows || props.items.length || 0)
114113
const fromRow = ref(0)
115114
const toRow = ref(0)
116115
const localCurrentPage = ref(props.currentPage)
@@ -133,11 +132,11 @@ const refreshCounter = () => {
133132
if (localCurrentPage.value === 0) {
134133
return
135134
}
136-
let from = (totalRows.value > 0) ? 1 : 0
135+
let from = (localTotalRows.value > 0) ? 1 : 0
137136
if (localCurrentPage.value > 1) {
138137
from = from + (localCurrentPage.value - 1) * props.perPage
139138
}
140-
let to = Math.min(from + props.perPage - 1, totalRows.value)
139+
let to = Math.min(from + props.perPage - 1, localTotalRows.value)
141140
fromRow.value = from - 1
142141
toRow.value = to
143142
}

0 commit comments

Comments
 (0)