Skip to content

Commit 298c7cb

Browse files
authored
Merge pull request #1 from BitTheCat/busy-state
Added busy-state for TVTable (0.1.6)
2 parents ed42b57 + e7fa92a commit 298c7cb

File tree

6 files changed

+54
-5
lines changed

6 files changed

+54
-5
lines changed

README.md

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,26 @@ import { TVTable } from '@bitthecat/tailwind-vue-data-table'
3333
- Select row column (with checkbox) ✔️
3434

3535
<img src="https://github.com/BitTheCat/tailwind-vue-data-table/blob/main/assets/tvtable_checkbox.jpg"/>
36+
3637
- Row detail ✔️
38+
39+
<img src="https://github.com/BitTheCat/tailwind-vue-data-table/blob/main/assets/tvtable_row_details.jpg"/>
3740

3841
- Row Clicked event ✔️
42+
43+
- Busy state ✔️
44+
<img src="https://github.com/BitTheCat/tailwind-vue-data-table/blob/main/assets/tvtable_busy_state.jpg"/>
3945

46+
- Additional rows up the header
47+
48+
- Select rows
49+
50+
- Provide item from api url
51+
52+
- Footer
53+
54+
- Refresh table
55+
4056
- ...
4157

4258
<hr>
@@ -52,6 +68,7 @@ import { TVTable } from '@bitthecat/tailwind-vue-data-table'
5268
| hidePagination | false | enables for hide paginator |
5369
| multipleSortable | false | enables multiple sortable for table header |
5470
| enableCheck | false | enables checkbox for table row |
71+
| busy | false | enables spinner for loading data |
5572

5673
### Slots
5774

@@ -107,4 +124,8 @@ data retrieves the field value
107124
| tdStyle | used for overwrite the td style |
108125
| thClass | used for overwrite the th class |
109126
| tdClass | used for overwrite the td class |
110-
| _showDetails | used for show row details (default false) |
127+
| _showDetails | used for show row details (default false) |
128+
129+
<hr>
130+
131+
This project is licensed under the MIT license. See [LICENSE](LICENSE).

assets/tvtable_busy_state.png

5.68 KB
Loading

assets/tvtable_row_details.png

17.7 KB
Loading

dev/TableShow.vue

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,12 @@
77
:items="cloneItems"
88
:fields="fieldsSimple"
99
enable-check
10+
:busy="busy"
1011
@check-row="checkRow"
1112
@row-clicked="checkRow"
1213
/>
14+
15+
<input class="border mt-2 p-1 rounded bg-gray-300 text-sm" type="button" :value="`Test busy: ${busy ? 'on' : 'off' }`" @click="busy = !busy" />
1316
</div>
1417
<hr>
1518
<div>
@@ -29,12 +32,15 @@
2932
>
3033
<template #cell:username="row">
3134
{{ row.item.emoji }} - {{ row.item.username }}
32-
<input id="checkbox" :checked="row.item._showDetails" type="checkbox" @click.stop="row.toggleDetails(row.item)" />
3335
</template>
3436

3537
<template #row-details>
3638
ROW-DETAILS ROW-DETAILS ROW-DETAILS
3739
</template>
40+
41+
<template #cell:details="row">
42+
<input id="checkbox" :checked="row.item._showDetails" type="checkbox" @click.stop="row.toggleDetails(row.item)" />
43+
</template>
3844
</TVTable>
3945
Selected:
4046
<pre>
@@ -72,6 +78,12 @@ const fields = ref([
7278
key: 'email',
7379
tdClass: 'bg-indigo-300'
7480
},
81+
{
82+
label: 'details',
83+
key: '',
84+
thStyle: 'width: 30px',
85+
tdClass: 'flex text-center',
86+
},
7587
])
7688
7789
const fieldsSimple = ref([
@@ -113,6 +125,8 @@ const items = ref([
113125
},
114126
])
115127
128+
const busy = ref(false)
129+
116130
const currentPage = ref(1)
117131
118132
const perPage = ref(2)

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.5",
3+
"version": "0.1.6",
44
"keywords": [
55
"tailwindcss",
66
"vue",

src/components/TVTable.vue

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,21 @@
5252
</tr>
5353
</thead>
5454
<tbody class="px-2 py-1.5 text-left text-xs font-medium border">
55-
<template v-for="(item, index) in items" :key="item.label">
56-
<tr
55+
<tr v-if="busy">
56+
<td :colspan="enableCheck ? fields.length + 1 : fields.length">
57+
<div class="flex justify-center mb-3 mt-3">
58+
<slot name="busy">
59+
<svg class="animate-spin -ml-1 mr-3 h-6 w-6 text-black" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24">
60+
<circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle>
61+
<path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path>
62+
</svg>
63+
</slot>
64+
</div>
65+
</td>
66+
</tr>
67+
<template v-for="(item, index) in items" v-else :key="item.label">
68+
<tr
69+
:id="`TV_TABLE_row_${item.label}`"
5770
class="divide-x divide-y last:border-b-0 px-2 py-1.5 text-left text-xs font-medium border hover:bg-gray-400/50"
5871
:class="index % 2 ? 'bg-gray-300/50' : 'bg-gray-100/50'"
5972
@click="rowClicked(item)"
@@ -135,6 +148,7 @@ const props = defineProps({
135148
hidePagination: Boolean,
136149
multipleSortable: Boolean,
137150
enableCheck: Boolean,
151+
busy: Boolean,
138152
})
139153
140154
const emit = defineEmits([

0 commit comments

Comments
 (0)