Skip to content

Commit 2396ea2

Browse files
committed
feat: add makeHeaderSticky and makePaginationSticky for the afcl table
1 parent af8c59f commit 2396ea2

File tree

2 files changed

+31
-5
lines changed

2 files changed

+31
-5
lines changed

adminforth/documentation/docs/tutorial/03-Customization/15-afcl.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1186,6 +1186,30 @@ const tableState = ref("loading");
11861186

11871187
</div>
11881188

1189+
1190+
### Making header and pagination sticky
1191+
1192+
If you want to make table header or pagination, you can add `makeHeaderSticky`, `makePaginationSticky`
1193+
1194+
```
1195+
<Table
1196+
class="min-h-[200px] max-h-[250px]"
1197+
makeHeaderSticky
1198+
makePaginationSticky
1199+
:columns="[
1200+
{ label: 'Name', fieldName: 'name' },
1201+
{ label: 'Age', fieldName: 'age' },
1202+
{ label: 'Country', fieldName: 'country' },
1203+
]"
1204+
:data="[
1205+
{ name: 'John', age: 30, country: 'US' },
1206+
{ name: 'Rick', age: 25, country: 'CA' },
1207+
{ name: 'Alice', age: 35, country: 'UK' },
1208+
{ name: 'Colin', age: 40, country: 'AU' },
1209+
]"
1210+
></Table>
1211+
```
1212+
11891213
## ProgressBar
11901214

11911215
<div class="split-screen" >

adminforth/spa/src/afcl/Table.vue

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
<template>
2-
<div class="afcl-table-container relative overflow-x-auto shadow-md rounded-lg">
3-
<div class="overflow-x-auto w-full">
2+
<div class="afcl-table-container relative overflow-x-auto overflow-y-auto shadow-md rounded-lg">
43
<table class="afcl-table w-full text-sm text-left rtl:text-right text-lightTableText dark:text-darkTableText overflow-x-auto">
5-
<thead class="afcl-table-thread text-xs text-lightTableHeadingText uppercase bg-lightTableHeadingBackground dark:bg-darkTableHeadingBackground dark:text-darkTableHeadingText">
4+
<thead class="afcl-table-thread text-xs text-lightTableHeadingText uppercase bg-lightTableHeadingBackground dark:bg-darkTableHeadingBackground dark:text-darkTableHeadingText" :class="makeHeaderSticky ? 'sticky top-0' : ''">
65
<tr>
76
<th
87
scope="col"
@@ -79,10 +78,11 @@
7978
</tr>
8079
</tbody>
8180
</table>
82-
</div>
8381
<nav class="afcl-table-pagination-container bg-lightTableBackground dark:bg-darkTableBackground mt-2 flex flex-col gap-2 items-center sm:flex-row justify-center sm:justify-between px-4 pb-4"
8482
v-if="totalPages > 1"
85-
:aria-label="$t('Table navigation')">
83+
:aria-label="$t('Table navigation')"
84+
:class="makePaginationSticky ? 'sticky bottom-0' : ''"
85+
>
8686
<i18n-t
8787
keypath="Showing {from} to {to} of {total}" tag="span" class="afcl-table-pagination-text text-sm font-normal text-center text-lightTablePaginationText dark:text-darkTablePaginationText sm:mb-4 md:mb-0 block w-full md:inline md:w-auto"
8888
>
@@ -169,6 +169,8 @@
169169
isLoading?: boolean,
170170
defaultSortField?: string,
171171
defaultSortDirection?: 'asc' | 'desc',
172+
makeHeaderSticky?: boolean,
173+
makePaginationSticky?: boolean,
172174
}>(), {
173175
evenHighlights: true,
174176
pageSize: 5,

0 commit comments

Comments
 (0)