From 5ecc782b3954958df43fa4695ba0fa4fe742a791 Mon Sep 17 00:00:00 2001 From: Matt Aitken Date: Thu, 22 Dec 2022 18:06:45 +0000 Subject: [PATCH] =?UTF-8?q?Disable=20next/prev=20buttons=20so=20the=20layo?= =?UTF-8?q?ut=20doesn=E2=80=99t=20jump=20around?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/components/LinkWithDisabled.tsx | 26 +++++++++ apps/webapp/app/components/Pagination.tsx | 56 +++++++++++++------ .../workflows/$workflowSlug/runs/index.tsx | 2 - 3 files changed, 64 insertions(+), 20 deletions(-) create mode 100644 apps/webapp/app/components/LinkWithDisabled.tsx diff --git a/apps/webapp/app/components/LinkWithDisabled.tsx b/apps/webapp/app/components/LinkWithDisabled.tsx new file mode 100644 index 000000000..cf0ac8093 --- /dev/null +++ b/apps/webapp/app/components/LinkWithDisabled.tsx @@ -0,0 +1,26 @@ +import { Link } from "@remix-run/react"; +import classNames from "classnames"; + +type Props = Parameters[0] & { + disabled?: boolean; + disabledClassName?: string; +}; + +export function LinkDisabled({ + disabled = false, + disabledClassName, + ...props +}: Props) { + if (disabled) { + return ( + + {props.children} + + ); + } else { + return {props.children}; + } +} diff --git a/apps/webapp/app/components/Pagination.tsx b/apps/webapp/app/components/Pagination.tsx index dfe41e27f..3bfcb5dc6 100644 --- a/apps/webapp/app/components/Pagination.tsx +++ b/apps/webapp/app/components/Pagination.tsx @@ -6,6 +6,7 @@ import { } from "@heroicons/react/24/solid"; import { Link, useLocation } from "@remix-run/react"; import classNames from "classnames"; +import { LinkDisabled } from "./LinkWithDisabled"; export function PaginationControls({ currentPage, @@ -56,27 +57,29 @@ export function PaginationControls({ className="isolate inline-flex -space-x-px rounded-md shadow-sm" aria-label="Pagination" > - {currentPage > 1 && ( - - Previous -