Skip to content

Commit

Permalink
feat: header+pagination sticky
Browse files Browse the repository at this point in the history
  • Loading branch information
ctot-nondef committed Oct 18, 2024
1 parent 6bfc6e9 commit a7b519d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
3 changes: 2 additions & 1 deletion components/data-table/data-table.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const emit = defineEmits(["table-ready", "columnFiltersChange", "globalFilterCha
interface Props {
items: Array<never>;
columns: Array<ColumnDef<never>>;
header: boolean;
}
const props = defineProps<Props>();
Expand Down Expand Up @@ -71,7 +72,7 @@ onMounted(() => {

<template>
<Table>
<TableHeader class="bg-primary font-bold text-on-primary">
<TableHeader v-if="header" class="bg-primary font-bold text-on-primary">
<TableRow v-for="headerGroup in table.getHeaderGroups()" :key="headerGroup.id">
<TableHead v-for="header in headerGroup.headers" :key="header.id">
{{ header.column.columnDef.header }}
Expand Down
17 changes: 12 additions & 5 deletions components/geojson-table-window-content.vue
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,22 @@ function registerTable(table: Table<FeatureType>) {
<Centered v-if="isPending">
<LoadingIndicator />
</Centered>
<div class="grid justify-items-end py-2">
<DataTablePagination
v-if="tables.get('0')"
:table="tables.get('0') as unknown as Table<never>"
/>
<div class="sticky top-0 z-10">
<div v-if="tables.get('0')" class="grid justify-items-end bg-white py-2">
<DataTablePagination :table="tables.get('0') as unknown as Table<never>" />
</div>
<TableHeader class="bg-primary font-bold text-on-primary">
<TableRow v-for="headerGroup in tables.get('0')!.getHeaderGroups()" :key="headerGroup.id">
<TableHead v-for="header in headerGroup.headers" :key="header.id">
{{ header.column.columnDef.header }}
</TableHead>
</TableRow>
</TableHeader>
</div>
<DataTable
v-if="!isPending && data && data[0]"
:columns="columns as unknown as Array<ColumnDef<never>>"
:header="false"
:items="data[0].features as Array<never>"
@table-ready="registerTable"
></DataTable>
Expand Down

0 comments on commit a7b519d

Please sign in to comment.