import React from "react"; import { StyledButton } from "./paginationHelpers"; import { type Button } from "../button"; import { Icon } from "../icon"; import { ChevronRight } from "@washingtonpost/wpds-assets"; import { PaginationContext } from "./PaginationRoot"; const NAME = "PaginationNextButton"; export type PaginationNextButtonProps = React.ComponentPropsWithRef< typeof Button >; // PageNavigationButton export const PaginationNextButton = React.forwardRef< HTMLButtonElement, PaginationNextButtonProps >(({ css, density = "compact", icon = "right", ...props }, ref) => { const { page, setPage, slug, totalPages } = React.useContext(PaginationContext); const handleClick = () => { if (page < totalPages) { return setPage(page + 1); } }; const lastPage = page === totalPages; const href = lastPage || !slug?.length ? null : `${slug}?page=${page + 1}`; const rel = !lastPage ? "next" : ""; return ( ); }); PaginationNextButton.displayName = NAME;