Compare commits

..

1 Commits

Author SHA1 Message Date
443743c3ed add dark mode in table pagination 2023-03-25 13:54:02 +05:30
2 changed files with 31 additions and 53 deletions

View File

@ -7,18 +7,11 @@
relative
overflow-hidden
bg-white
border-b
border-gray-200
border-b border-gray-200
shadow
sm:rounded-lg
dark:shadow-glass
dark:border
dark:border-white/10
dark:bg-gray-800/70
"
"
>
<BaseDarkHighlight v-if="darkHighlight" class="z-[-1]" />
<slot name="header" />
<table :class="tableClass">
<thead :class="theadClass">
@ -58,11 +51,7 @@
<tr
v-for="placeRow in placeholderCount"
:key="placeRow"
:class="
placeRow % 2 === 0
? 'bg-white dark:bg-gray-800'
: 'bg-gray-50 dark:bg-gray-800'
"
:class="placeRow % 2 === 0 ? 'bg-white' : 'bg-gray-50'"
>
<td
v-for="column in columns"
@ -86,11 +75,7 @@
<tr
v-for="(row, index) in sortedRows"
:key="index"
:class="
index % 2 === 0
? 'bg-white dark:bg-transparent'
: 'bg-gray-50 dark:bg-gray-700/20 dark:border-y dark:border-gray-600'
"
:class="index % 2 === 0 ? 'bg-white' : 'bg-gray-50'"
>
<td
v-for="column in columns"
@ -118,10 +103,7 @@
justify-center
w-full
h-full
bg-white
bg-opacity-60
dark:bg-gray-700
dark:bg-opacity-60
bg-white bg-opacity-60
"
>
<SpinnerIcon class="w-10 h-10 text-primary-500" />
@ -181,12 +163,9 @@ const props = defineProps({
sortOrder: { type: String, default: '' },
tableClass: {
type: String,
default: 'min-w-full divide-y divide-gray-200 dark:divide-gray-600',
},
theadClass: {
type: String,
default: 'bg-gray-50 dark:bg-gray-800 dark:text-white',
default: 'min-w-full divide-y divide-gray-200',
},
theadClass: { type: String, default: 'bg-gray-50' },
tbodyClass: { type: String, default: '' },
noResultsMessage: {
type: String,
@ -207,10 +186,6 @@ const props = defineProps({
type: Number,
default: 3,
},
darkHighlight: {
type: Boolean,
default: false,
},
})
let rows = reactive([])
@ -261,7 +236,7 @@ function getColumn(columnName) {
function getThClass(column) {
let classes =
'whitespace-nowrap px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider dark:text-white'
'whitespace-nowrap px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider'
if (column.defaultThClass) {
classes = column.defaultThClass
@ -281,8 +256,7 @@ function getThClass(column) {
}
function getTdClass(column) {
let classes =
'px-6 py-4 text-sm text-gray-500 whitespace-nowrap dark:text-gray-300'
let classes = 'px-6 py-4 text-sm text-gray-500 whitespace-nowrap'
if (column.defaultTdClass) {
classes = column.defaultTdClass
@ -335,7 +309,6 @@ function changeSorting(column) {
}
if (!usesLocalData.value) {
if (pagination.value) pagination.value.currentPage = 1
mapDataToRows()
}
}
@ -353,9 +326,7 @@ async function pageChange(page) {
await mapDataToRows()
}
async function refresh(isPreservePage = false) {
if (pagination.value && !isPreservePage) pagination.value.currentPage = 1
async function refresh() {
await mapDataToRows()
}

View File

@ -10,13 +10,14 @@
bg-white
border-t border-gray-200
sm:px-6
dark:bg-transparent dark:border-white/10
"
>
<div class="flex justify-between flex-1 sm:hidden">
<a
href="#"
:class="{
'disabled cursor-normal pointer-events-none !bg-gray-100 !text-gray-400':
'disabled cursor-normal pointer-events-none !bg-gray-100 !text-gray-400 dark:!bg-gray-800 dark:!text-gray-500':
pagination.currentPage === 1,
}"
class="
@ -32,6 +33,7 @@
border border-gray-300
rounded-md
hover:bg-gray-50
dark:bg-gray-800 dark:border-gray-600 dark:text-gray-300
"
@click="pageClicked(pagination.currentPage - 1)"
>
@ -40,7 +42,7 @@
<a
href="#"
:class="{
'disabled cursor-default pointer-events-none !bg-gray-100 !text-gray-400':
'disabled cursor-default pointer-events-none !bg-gray-100 !text-gray-400 dark:!bg-gray-800 dark:!text-gray-500':
pagination.currentPage === pagination.totalPages,
}"
class="
@ -57,6 +59,7 @@
border border-gray-300
rounded-md
hover:bg-gray-50
dark:bg-gray-800 dark:border-gray-600 dark:text-gray-300
"
@click="pageClicked(pagination.currentPage + 1)"
>
@ -65,12 +68,12 @@
</div>
<div class="hidden sm:flex-1 sm:flex sm:items-center sm:justify-between">
<div>
<p class="text-sm text-gray-700">
<p class="text-sm text-gray-700 dark:text-gray-400">
Showing
{{ ' ' }}
<span
v-if="pagination.limit && pagination.currentPage"
class="font-medium"
class="font-medium dark:text-gray-200"
>
{{
pagination.currentPage * pagination.limit - (pagination.limit - 1)
@ -81,7 +84,7 @@
{{ ' ' }}
<span
v-if="pagination.limit && pagination.currentPage"
class="font-medium"
class="font-medium dark:text-gray-200"
>
<span
v-if="
@ -98,7 +101,7 @@
{{ ' ' }}
of
{{ ' ' }}
<span v-if="pagination.totalCount" class="font-medium">
<span v-if="pagination.totalCount" class="font-medium dark:text-gray-200">
{{ pagination.totalCount }}
</span>
{{ ' ' }}
@ -113,7 +116,7 @@
<a
href="#"
:class="{
'disabled cursor-normal pointer-events-none !bg-gray-100 !text-gray-400':
'disabled cursor-normal pointer-events-none !bg-gray-100 !text-gray-400 dark:!bg-gray-800 dark:!text-gray-500':
pagination.currentPage === 1,
}"
class="
@ -129,6 +132,7 @@
border border-gray-300
rounded-l-md
hover:bg-gray-50
dark:border-gray-600 dark:bg-gray-800 dark:text-gray-300
"
@click="pageClicked(pagination.currentPage - 1)"
>
@ -140,9 +144,9 @@
href="#"
aria-current="page"
:class="{
'z-10 bg-primary-50 border-primary-500 text-primary-600':
'z-10 bg-primary-50 border-primary-500 text-primary-600 dark:bg-primary-500 dark:text-white':
isActive(1),
'bg-white border-gray-300 text-gray-500 hover:bg-gray-50':
'bg-white border-gray-300 text-gray-500 hover:bg-gray-50 dark:border-gray-600 dark:bg-gray-800 dark:text-gray-300':
!isActive(1),
}"
class="
@ -173,6 +177,7 @@
text-gray-700
bg-white
border border-gray-300
dark:border-gray-600 dark:bg-gray-800 dark:text-gray-300
"
>
...
@ -182,9 +187,9 @@
:key="page"
href="#"
:class="{
'z-10 bg-primary-50 border-primary-500 text-primary-600':
'z-10 bg-primary-50 border-primary-500 text-primary-600 dark:bg-primary-500 dark:text-white':
isActive(page),
'bg-white border-gray-300 text-gray-500 hover:bg-gray-50':
'bg-white border-gray-300 text-gray-500 hover:bg-gray-50 dark:border-gray-600 dark:bg-gray-800 dark:text-gray-300':
!isActive(page),
disabled: page === '...',
}"
@ -220,6 +225,7 @@
text-gray-700
bg-white
border border-gray-300
dark:border-gray-600 dark:bg-gray-800 dark:text-gray-300
"
>
...
@ -229,9 +235,9 @@
href="#"
aria-current="page"
:class="{
'z-10 bg-primary-50 border-primary-500 text-primary-600':
'z-10 bg-primary-50 border-primary-500 text-primary-600 dark:bg-primary-500 dark:text-white':
isActive(pagination.totalPages),
'bg-white border-gray-300 text-gray-500 hover:bg-gray-50':
'bg-white border-gray-300 text-gray-500 hover:bg-gray-50 dark:border-gray-600 dark:bg-gray-800 dark:text-gray-300':
!isActive(pagination.totalPages),
}"
class="
@ -263,9 +269,10 @@
border border-gray-300
rounded-r-md
hover:bg-gray-50
dark:border-gray-600 dark:bg-gray-800 dark:text-gray-300
"
:class="{
'disabled cursor-default pointer-events-none !bg-gray-100 !text-gray-400':
'disabled cursor-default pointer-events-none !bg-gray-100 !text-gray-400 dark:!bg-gray-800 dark:!text-gray-500':
pagination.currentPage === pagination.totalPages,
}"
@click="pageClicked(pagination.currentPage + 1)"