Skip to content

Commit 724537c

Browse files
committed
Fixed Component (css inside the table)
1 parent ddc0cab commit 724537c

File tree

1 file changed

+14
-54
lines changed

1 file changed

+14
-54
lines changed

src/components/TVDataTable.vue

Lines changed: 14 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
<template>
2-
<table>
3-
<thead>
4-
<tr>
2+
<table class="min-w-full ">
3+
<thead class="bg-gray-300 border">
4+
<tr class="divide-x divide-y">
55
<th
66
v-for="field in fields"
77
:key="field.label"
8+
class="px-2 py-1.5 text-xs font-medium text-black uppercase"
89
:class="field.thClass"
910
:style="field.thStyle"
1011
>
@@ -19,7 +20,7 @@
1920
viewBox="0 0 24 24"
2021
:stroke-width="sortable[field.key] === 'asc' ? 4 : 2"
2122
stroke="currentColor"
22-
class="table-sort"
23+
class="w-2.5 h-2.5 cursor-pointer"
2324
@click="updateSortable(field.key, 'asc')"
2425
>
2526
<path stroke-linecap="round" stroke-linejoin="round" d="M4.5 15.75l7.5-7.5 7.5 7.5" />
@@ -30,7 +31,7 @@
3031
viewBox="0 0 24 24"
3132
:stroke-width="sortable[field.key] === 'desc' ? 4 : 2"
3233
stroke="currentColor"
33-
class="table-sort"
34+
class="w-2.5 h-2.5 cursor-pointer"
3435
@click="updateSortable(field.key, 'desc')"
3536
>
3637
<path stroke-linecap="round" stroke-linejoin="round" d="M19.5 8.25l-7.5 7.5-7.5-7.5" />
@@ -40,11 +41,16 @@
4041
</th>
4142
</tr>
4243
</thead>
43-
<tbody>
44-
<tr v-for="(item) in items" :key="item.label">
44+
<tbody class="px-2 py-1.5 text-left text-xs font-medium border">
45+
<tr
46+
v-for="(item) in items"
47+
:key="item.label"
48+
class="divide-x divide-y last:border-b-0 px-2 py-1.5 text-left text-xs font-medium border odd:bg-gray-300/50 even:bg-gray-100/50 hover:bg-gray-400/50"
49+
>
4550
<td
4651
v-for="field in fields"
4752
:key="field.key"
53+
class="px-2 py-1.5 align-top lg:table-cell lg:text-left lg:align-middle last:border-b-0"
4854
:class="field.tdClass"
4955
:style="field.tdStyle"
5056
>
@@ -90,50 +96,4 @@ const updateSortable = (key, sort) => {
9096
9197
emit('updateSortable', sortable.value)
9298
}
93-
</script>
94-
95-
<style>
96-
table {
97-
@apply min-w-full ;
98-
}
99-
100-
thead {
101-
@apply bg-gray-300 border;
102-
}
103-
104-
tr {
105-
@apply divide-x divide-y;
106-
}
107-
108-
tr:last-child {
109-
@apply border-b-0;
110-
}
111-
112-
th {
113-
@apply px-2 py-1.5 text-xs font-medium text-black uppercase;
114-
}
115-
116-
td {
117-
@apply px-2 py-1.5 align-top lg:table-cell lg:text-left lg:align-middle;
118-
}
119-
120-
td:last-child {
121-
@apply border-b-0;
122-
}
123-
124-
tbody tr, tbody {
125-
@apply px-2 py-1.5 text-left text-xs font-medium border;
126-
}
127-
128-
tbody tr:nth-child(odd) {
129-
@apply bg-gray-300/50 hover:bg-gray-400/50;
130-
}
131-
132-
tbody tr:nth-child(even) {
133-
@apply bg-gray-100/50 hover:bg-gray-400/50 ;
134-
}
135-
136-
.table-sort {
137-
@apply w-2.5 h-2.5 cursor-pointer
138-
}
139-
</style>
99+
</script>

0 commit comments

Comments
 (0)