Few pages
import { html, atom, renderApp } from 'mates';
import { Pagination, Text } from 'mates-ui';
const App = () => {
const page = atom(1);
return () => html`
<x-col gap="var(--md-space-3)">
${Text("Current: " + page(), { type: "body-sm", color: "muted" })}
${Pagination({ currentPage: page(), totalPages: 7, onChange: (p) => page.set(p) })}
</x-col>
`;
};
renderApp(App, document.getElementById('app'));
Many pages with ellipsis
import { html, atom, renderApp } from 'mates';
import { Pagination, Text } from 'mates-ui';
const App = () => {
const page = atom(5);
return () => html`
<x-col gap="var(--md-space-3)">
${Text("Current: " + page(), { type: "body-sm", color: "muted" })}
${Pagination({ currentPage: page(), totalPages: 24, siblingCount: 1, onChange: (p) => page.set(p) })}
</x-col>
`;
};
renderApp(App, document.getElementById('app'));
Wide sibling window
import { html, renderApp } from 'mates';
import { Pagination } from 'mates-ui';
const App = () => () => html`
${Pagination({ currentPage: 8, totalPages: 30, siblingCount: 2, disabled: true, onChange: () => {} })}
`;
renderApp(App, document.getElementById('app'));
Edge cases — 0 and 1 pages
import { html, renderApp } from 'mates';
import { Pagination, Text } from 'mates-ui';
const App = () => () => html`
<x-col gap="var(--md-space-4)">
<x-col gap="var(--md-space-2)">
${Text("totalPages: 0 — nothing rendered", { type: "label-sm", color: "muted" })}
${Pagination({ currentPage: 1, totalPages: 0, onChange: () => {} })}
</x-col>
<x-col gap="var(--md-space-2)">
${Text("totalPages: 1 — nothing rendered", { type: "label-sm", color: "muted" })}
${Pagination({ currentPage: 1, totalPages: 1, onChange: () => {} })}
</x-col>
</x-col>
`;
renderApp(App, document.getElementById('app'));