Files
filecodebox/src/components/common/DataTable.vue
T

63 lines
1.8 KiB
Vue

<template>
<div
class="data-table-2026 theme-2026-card theme-2026-card-hover overflow-hidden rounded-[30px] shadow-md transition-all duration-300 hover:-translate-y-0.5 hover:shadow-lg"
>
<div
class="border-b px-6 py-4"
:class="[isDarkMode ? 'border-gray-700/80' : 'border-[#d9e4e6]']"
>
<div class="flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between">
<h3 class="text-lg font-medium" :class="[isDarkMode ? 'text-white' : 'text-gray-800']">
{{ title }}
</h3>
<div v-if="slots.actions" class="flex shrink-0 flex-wrap items-center gap-2">
<slot name="actions"></slot>
</div>
</div>
<div v-if="slots.toolbar" class="mt-4">
<slot name="toolbar"></slot>
</div>
</div>
<div class="overflow-x-auto">
<table
class="min-w-full divide-y"
:class="[isDarkMode ? 'divide-[#31454d]' : 'divide-[#d7e3e5]']"
>
<thead>
<tr>
<th
v-for="header in headers"
:key="header"
class="px-6 py-3.5 text-left text-xs font-medium uppercase tracking-wider"
:class="[isDarkMode ? 'text-gray-400' : 'text-gray-500']"
>
{{ header }}
</th>
</tr>
</thead>
<tbody
class="divide-y"
:class="[isDarkMode ? 'divide-[#31454d]/70' : 'divide-[#d7e3e5]/80']"
>
<slot name="body"></slot>
</tbody>
</table>
</div>
<slot name="footer"></slot>
</div>
</template>
<script setup lang="ts">
import { inject, useSlots } from 'vue'
interface Props {
title: string
headers: string[]
}
defineProps<Props>()
const slots = useSlots()
const isDarkMode = inject('isDarkMode')
</script>