CursorPagination
Más recientes y Anteriores para listas que se leen con un cursor, donde nadie sabe el total: registros, eventos. Dice qué hay en pantalla en vez de «página 3 de ?».
import { CursorPagination } from '@sypnia/ui/react'
En esta página
Líneas de registro
Código
import { useState } from 'react';
import { CursorPagination } from '@sypnia/ui/react';
// Logs are read with a cursor: nobody knows the total, so it says what is on screen and offers newer and older.
export default function Logs() {
const [page, setPage] = useState(0);
const from = 14 * 60 - page * 25;
const time = (m: number) => `${String(Math.floor(m / 60)).padStart(2, '0')}:${String(m % 60).padStart(2, '0')}`;
return <CursorPagination hasPrevious={page > 0} hasNext={page < 5} onPrevious={() => setPage(page - 1)} onNext={() => setPage(page + 1)}
summary={`50 lines, from ${time(from)} to ${time(from - 24)}`} />;
} Cuándo usarlo
Úsalo cuando
- Registros, eventos y otras listas que crecen mientras las lees.
No lo uses cuando
- Listas con un total conocido: usa Pagination.
Para todos
- Es una región de navegación llamada «Páginas».
- El resumen se lee cuando cambia.
Props
| CursorPagination | Tipo | Por defecto |
|---|---|---|
hasNextobligatorio | boolean | |
hasPreviousobligatorio | boolean | |
onNextobligatorio | () => void | |
onPreviousobligatorio | () => void | |
busy | boolean | |
summaryWhat is on screen: «50 rows, from 14:02 to 13:40». | ReactNode |