Skip to content

Commit

Permalink
- Updated /bookmarks/status route with defer, Await and Suspense
Browse files Browse the repository at this point in the history
- Added `/bookmarks/status/all` route
  • Loading branch information
michaelschwobe committed Dec 12, 2023
1 parent 62a0289 commit 5adb918
Show file tree
Hide file tree
Showing 9 changed files with 472 additions and 362 deletions.
80 changes: 80 additions & 0 deletions app/components/status-tr.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
import { forwardRef } from "react";
import { ButtonDelete } from "~/components/button-delete";
import { StatusCode } from "~/components/status-code";
import { StatusText } from "~/components/status-text";
import { Icon } from "~/components/ui/icon";
import { LinkButton } from "~/components/ui/link-button";
import { Td, Tr } from "~/components/ui/table";
import { cn } from "~/utils/misc";
import type { GetStatusData } from "~/utils/status.server";

export const StatusTr = forwardRef<
React.ElementRef<"tr">,
Omit<React.ComponentPropsWithoutRef<"tr">, "children"> & {
id: string;
isOkHidden?: boolean;
statusCode: GetStatusData["status"] | null;
statusText: GetStatusData["statusText"] | null;
url: string;
}
>(
(
{ className, id, isOkHidden, url, statusCode, statusText, ...props },
ref,
) => {
return (
<Tr
{...props}
className={cn(
isOkHidden &&
typeof statusCode === "number" &&
statusCode >= 200 &&
statusCode <= 299
? "hidden"
: undefined,
className,
)}
ref={ref}
>
<Td>
<LinkButton
to={`/bookmarks/${id}/edit`}
size="sm-icon"
variant="ghost"
>
<Icon type="pencil" />
<span className="sr-only">Edit bookmark</span>
</LinkButton>
</Td>
<Td className="max-sm:px-0">
<StatusCode>{statusCode}</StatusCode>
</Td>
<Td>
<LinkButton
to={url}
target="_blank"
rel="noopener noreferrer"
size="sm"
variant="ghost"
className="flex w-full max-w-[75vw] justify-start overflow-hidden sm:max-w-[45vw]"
>
<Icon type="external-link" />
<span className="truncate font-normal">{url}</span>
</LinkButton>
</Td>
<Td className="max-sm:px-0">
<StatusText>{statusText}</StatusText>
</Td>
<Td>
<ButtonDelete
formAction={`/bookmarks/${id}/edit`}
label="bookmark"
size="sm-icon"
variant="ghost-danger"
/>
</Td>
</Tr>
);
},
);
StatusTr.displayName = "StatusTr";
154 changes: 0 additions & 154 deletions app/components/table-columns-bookmarks-status.tsx

This file was deleted.

Loading

0 comments on commit 5adb918

Please sign in to comment.