import React from 'react';
import { Pagination, PaginationVariant, Gallery, GalleryItem, Card, CardBody } from '@breakaway/preact-core';
export const PaginationSticky: React.FunctionComponent = () => {
const [page, setPage] = React.useState(1);
const [perPage, setPerPage] = React.useState(100);
const [isTopSticky, setIsTopSticky] = React.useState(true);
const itemCount = 523;
const onToggleSticky = () => {
setIsTopSticky((prev) => !prev);
};
const onSetPage = (_event: React.MouseEvent | React.KeyboardEvent | MouseEvent, newPage: number) => {
setPage(newPage);
};
const onPerPageSelect = (
_event: React.MouseEvent | React.KeyboardEvent | MouseEvent,
newPerPage: number,
newPage: number
) => {
setPerPage(newPerPage);
setPage(newPage);
};
const buildCards = () => {
const numberOfCards = (page - 1) * perPage + perPage - 1 >= itemCount ? itemCount - (page - 1) * perPage : perPage;
return Array.apply(0, Array(numberOfCards)).map((x, i) => (
This is a card
));
};
return isTopSticky ? (
{buildCards()}
) : (
{buildCards()}
);
};