Open source alternative to Semrush and Ahrefs
TypeScript backlink-analysisgoogle-search-console-mcpkeyword-researchmcpseoseo-agentseo-auditseo-automationseo-skillsseo-toolssite-audit
Port the reports, report detail and templates pages to shadcn (EVE-302) (#746)
Carter Smithfcfa125d5e24
diff --git a/src/client/features/reports/ReportTemplateForm.tsx b/src/client/features/reports/ReportTemplateForm.tsxindex 8aae3649..4a05bb3d 100644--- a/src/client/features/reports/ReportTemplateForm.tsx+++ b/src/client/features/reports/ReportTemplateForm.tsx@@ -3,8 +3,14 @@ import { useMutation } from "@tanstack/react-query";import { toast } from "sonner";import { z } from "zod";import { useAppForm } from "@/client/components/form/useAppForm";-import { Modal } from "@/client/components/Modal";import { Button } from "@/client/components/ui/button";+import {+ Dialog,+ DialogContent,+ DialogFooter,+ DialogHeader,+ DialogTitle,+} from "@/client/components/ui/dialog";import { captureClientEvent } from "@/client/lib/posthog";import { saveReportTemplate } from "@/serverFunctions/reportTemplates";import type { ReportTemplate } from "@/types/schemas/report-templates";@@ -75,56 +81,70 @@ export function ReportTemplateForm({});return (- <Modal maxWidth="max-w-2xl" onClose={onClose} labelledBy="template-title">- <h3 id="template-title" className="text-lg font-semibold">- {template ? "Edit template" : "New template"}- </h3>+ <Dialog+ open+ onOpenChange={(open) => {+ if (!open && !saveMutation.isPending) onClose();+ }}+ >+ <DialogContent showCloseButton={false} className="sm:max-w-2xl">+ <form.AppForm>+ <form.Form className="flex flex-col gap-4">+ <DialogHeader>+ <DialogTitle>+ {template ? "Edit template" : "New template"}+ </DialogTitle>+ </DialogHeader>- <form.AppForm>- <form.Form className="flex flex-col gap-4">- <form.AppField name="name">- {(field) => (- <field.TextField- label="Name"- placeholder="Monthly client check-in"- required- />- )}- </form.AppField>+ <form.AppField name="name">+ {(field) => (+ <field.TextField+ label="Name"+ placeholder="Monthly client check-in"+ required+ />+ )}+ </form.AppField>- <form.AppField name="description">- {(field) => (- <field.TextField- label="Description"- description="One line saying when to use it. This is what an agent reads to decide."- placeholder="The monthly update we send retainer clients."- required- />- )}- </form.AppField>+ <form.AppField name="description">+ {(field) => (+ <field.TextField+ label="Description"+ description="One line saying when to use it. This is what an agent reads to decide."+ placeholder="The monthly update we send retainer clients."+ required+ />+ )}+ </form.AppField>- <form.AppField name="instructions">- {(field) => (- <field.TextareaField- label="Instructions"- description="Brand voice for the whole project lives in Context › Writing preferences."- className="h-56 font-mono leading-relaxed md:text-xs"- placeholder={INSTRUCTIONS_PLACEHOLDER}- required- />- )}- </form.AppField>+ <form.AppField name="instructions">+ {(field) => (+ <field.TextareaField+ label="Instructions"+ description="Brand voice for the whole project lives in Context › Writing preferences."+ className="h-56 font-mono leading-relaxed md:text-xs"+ placeholder={INSTRUCTIONS_PLACEHOLDER}+ required+ />+ )}+ </form.AppField>- <div className="flex justify-end gap-2">- <Button type="button" variant="ghost" onClick={onClose}>- Cancel- </Button>- <form.SubmitButton>- {template ? "Save changes" : "Create template"}- </form.SubmitButton>- </div>- </form.Form>- </form.AppForm>- </Modal>+ <DialogFooter>+ <Button+ type="button"+ variant="ghost"+ onClick={onClose}+ disabled={saveMutation.isPending}+ >+ Cancel+ </Button>+ <form.SubmitButton>+ {template ? "Save changes" : "Create template"}+ </form.SubmitButton>+ </DialogFooter>+ </form.Form>+ </form.AppForm>+ </DialogContent>+ </Dialog>);}diff --git a/src/client/features/reports/ReportTemplatesList.tsx b/src/client/features/reports/ReportTemplatesList.tsxindex 60eca457..16dca3ea 100644--- a/src/client/features/reports/ReportTemplatesList.tsx+++ b/src/client/features/reports/ReportTemplatesList.tsx@@ -2,6 +2,14 @@ import { LayoutTemplate, Pencil, Trash2 } from "lucide-react";import { EmptyState } from "@/client/components/EmptyState";import { RowActionsMenu } from "@/client/components/RowActionsMenu";import { DropdownMenuItem } from "@/client/components/ui/dropdown-menu";+import {+ Table,+ TableBody,+ TableCell,+ TableHead,+ TableHeader,+ TableRow,+} from "@/client/components/ui/table";import { formatRelativeTime } from "@/client/lib/relative-time";import type { ReportTemplate } from "@/types/schemas/report-templates";@@ -25,35 +33,35 @@ export function ReportTemplatesList({}return (- <div className="overflow-x-auto rounded-lg border border-base-300">- <table className="table table-sm">- <thead>- <tr>- <th>Name</th>- <th>Description</th>- <th>Updated</th>- <th></th>- </tr>- </thead>- <tbody>+ <div className="rounded-lg border border-border">+ <Table>+ <TableHeader>+ <TableRow>+ <TableHead>Name</TableHead>+ <TableHead>Description</TableHead>+ <TableHead>Updated</TableHead>+ <TableHead />+ </TableRow>+ </TableHeader>+ <TableBody>{templates.map((template) => (- <tr key={template.id} className="hover:bg-base-200">- <td>+ <TableRow key={template.id}>+ <TableCell><buttontype="button"- className="link link-hover text-left font-medium"+ className="text-left font-medium hover:underline"onClick={() => onEdit(template)}>{template.name}</button>- </td>- <td className="max-w-[420px] text-base-content/70">+ </TableCell>+ <TableCell className="max-w-[420px] text-muted-foreground">{template.description}- </td>- <td className="whitespace-nowrap text-base-content/70">+ </TableCell>+ <TableCell className="whitespace-nowrap text-muted-foreground">{formatRelativeTime(template.updatedAt)}- </td>- <td className="w-10 text-right">+ </TableCell>+ <TableCell className="w-10 text-right"><RowActionsMenu label={`Actions for ${template.name}`}><DropdownMenuItem onClick={() => onEdit(template)}><Pencil />@@ -67,11 +75,11 @@ export function ReportTemplatesList({Delete</DropdownMenuItem></RowActionsMenu>- </td>- </tr>+ </TableCell>+ </TableRow>))}- </tbody>- </table>+ </TableBody>+ </Table></div>);}diff --git a/src/client/features/reports/ReportViewer.tsx b/src/client/features/reports/ReportViewer.tsxindex 5b31135d..7861951f 100644--- a/src/client/features/reports/ReportViewer.tsx+++ b/src/client/features/reports/ReportViewer.tsx@@ -36,8 +36,7 @@ export function ReportViewer({title={title}onLoad={() => setLoadedSrc(src)}className={- className ??- "h-full w-full rounded-lg border border-base-300 bg-base-100"+ className ?? "h-full w-full rounded-lg border border-border bg-card"}/>{loadedSrc !== src ? (diff --git a/src/client/features/reports/ReportsList.tsx b/src/client/features/reports/ReportsList.tsxindex 106a8f88..cb1bc99e 100644--- a/src/client/features/reports/ReportsList.tsx+++ b/src/client/features/reports/ReportsList.tsx@@ -1,7 +1,8 @@import { Link } from "@tanstack/react-router";import { FileText, Trash2 } from "lucide-react";import { EmptyState } from "@/client/components/EmptyState";-import { PortalMenu } from "@/client/components/PortalMenu";+import { RowActionsMenu } from "@/client/components/RowActionsMenu";+import { DropdownMenuItem } from "@/client/components/ui/dropdown-menu";import {Table,TableBody,@@ -66,28 +67,21 @@ export function ReportsList({that produced it: what a reader needs to tell two reportson the same site apart. */}<TableCell className="text-muted-foreground">- {report.templateName ?? report.skill ?? "-"}+ {report.templateName ?? report.skill ?? "—"}</TableCell><TableCell className="whitespace-nowrap text-muted-foreground">{formatRelativeTime(report.updatedAt)}</TableCell><TableCell className="w-10 text-right">- <PortalMenu ariaLabel={`Actions for ${report.title}`}>- {(close) => (- <li>- <button- className="text-error"- onClick={() => {- close();- onDelete(report);- }}- >- <Trash2 className="size-3.5" />- Delete- </button>- </li>- )}- </PortalMenu>+ <RowActionsMenu label={`Actions for ${report.title}`}>+ <DropdownMenuItem+ variant="destructive"+ onClick={() => onDelete(report)}+ >+ <Trash2 />+ Delete+ </DropdownMenuItem>+ </RowActionsMenu></TableCell></TableRow>))}diff --git a/src/client/features/reports/shared.tsx b/src/client/features/reports/shared.tsxindex 7eb6de2a..3fc0bf76 100644--- a/src/client/features/reports/shared.tsx+++ b/src/client/features/reports/shared.tsx@@ -1,9 +1,25 @@import { formatRelativeTime } from "@/client/lib/relative-time";+import { useId } from "react";import { useMutation, useQueryClient } from "@tanstack/react-query";-import { Copy, ExternalLink, X } from "lucide-react";+import { Copy, ExternalLink } from "lucide-react";import { toast } from "sonner";import { ConfirmDialog } from "@/client/components/ConfirmDialog";-import { Modal } from "@/client/components/Modal";+import { Button } from "@/client/components/ui/button";+import {+ Dialog,+ DialogContent,+ DialogDescription,+ DialogHeader,+ DialogTitle,+} from "@/client/components/ui/dialog";+import {+ Field,+ FieldContent,+ FieldDescription,+ FieldLabel,+} from "@/client/components/ui/field";+import { Input } from "@/client/components/ui/input";+import { Switch } from "@/client/components/ui/switch";import { getStandardErrorMessage } from "@/client/lib/error-messages";import { captureClientEvent } from "@/client/lib/posthog";import {@@ -107,6 +123,7 @@ export function ShareReportModal({onClose: () => void;}) {const queryClient = useQueryClient();+ const switchId = useId();const { projectId, id: reportId } = report;// Share and unshare in one mutation, keyed by the state the toggle is moving// to. The response is written straight into the report query so the modal@@ -148,99 +165,89 @@ export function ShareReportModal({};return (- <Modal- onClose={onClose}- labelledBy="share-report-title"- maxWidth="max-w-lg"+ <Dialog+ open+ onOpenChange={(open) => {+ if (!open) onClose();+ }}>- <div className="flex items-start justify-between gap-4">- <div className="min-w-0">- <h3 id="share-report-title" className="text-base font-semibold">- Share- </h3>- <p className="truncate text-sm text-base-content/60">+ <DialogContent className="sm:max-w-lg">+ <DialogHeader className="min-w-0 pr-8">+ <DialogTitle>Share</DialogTitle>+ <DialogDescription className="truncate">{report.title}- </p>- </div>- <button- type="button"- className="btn btn-ghost btn-sm btn-square -mr-2 -mt-1"- aria-label="Close"- onClick={onClose}- >- <X className="size-4" />- </button>- </div>+ </DialogDescription>+ </DialogHeader>- <div className="rounded-lg border border-base-300">- <label className="flex cursor-pointer items-center justify-between gap-4 p-4">- <span className="min-w-0">- <span className="block text-sm font-medium">Public link</span>- <span className="block text-xs text-base-content/60">- {shared- ? "Anyone with the link can view. No sign-in needed."- : "Only members of your organization can open it. A link that was open can keep loading for up to a minute."}- </span>- </span>- <input- type="checkbox"- className="toggle toggle-primary"- checked={mutation.isPending ? mutation.variables : shared}- disabled={mutation.isPending}- onChange={(event) => mutation.mutate(event.target.checked)}- />- </label>+ <div className="rounded-lg border border-border">+ <Field orientation="horizontal" className="p-4">+ <FieldContent>+ <FieldLabel htmlFor={switchId}>Public link</FieldLabel>+ <FieldDescription id={`${switchId}-description`}>+ {shared+ ? "Anyone with the link can view. No sign-in needed."+ : "Only members of your organization can open it. A link that was open can keep loading for up to a minute."}+ </FieldDescription>+ </FieldContent>+ <Switch+ id={switchId}+ aria-describedby={`${switchId}-description`}+ checked={mutation.isPending ? mutation.variables : shared}+ disabled={mutation.isPending}+ onCheckedChange={(checked) => mutation.mutate(checked)}+ />+ </Field>- {shared ? (- <div className="space-y-3 border-t border-base-300 p-4">- {/* The field wraps onto its own line when the row gets narrow, so- the link stays readable on a phone instead of shrinking. */}- <div className="flex flex-wrap items-stretch gap-2">- <input- readOnly- value={url}- aria-label="Share link"- onFocus={(event) => event.target.select()}- className="input input-sm input-bordered min-w-0 flex-1 basis-64 text-sm"- />- <div className="ml-auto flex items-stretch">- <a- href={url}- target="_blank"- rel="noreferrer"- aria-label="Open link"- title="Open"- className="btn btn-sm btn-ghost rounded-r-none border border-r-0 border-base-300"- >- <ExternalLink className="size-4" />- </a>- <button- type="button"- onClick={() => void copy()}- className="btn btn-sm btn-primary rounded-l-none"- >- <Copy className="size-4" />- Copy link- </button>+ {shared ? (+ <div className="space-y-3 border-t border-border p-4">+ {/* The field wraps onto its own line when the row gets narrow, so+ the link stays readable on a phone instead of shrinking. */}+ <div className="flex flex-wrap items-stretch gap-2">+ <Input+ readOnly+ value={url}+ aria-label="Share link"+ onFocus={(event) => event.target.select()}+ className="min-w-0 flex-1 basis-64"+ />+ <div className="ml-auto flex items-stretch gap-2">+ <Button+ variant="outline"+ size="icon"+ nativeButton={false}+ aria-label="Open link"+ title="Open"+ render={<a href={url} target="_blank" rel="noreferrer" />}+ >+ <ExternalLink />+ </Button>+ <Button onClick={() => void copy()}>+ <Copy data-icon="inline-start" />+ Copy link+ </Button>+ </div></div>+ <p className="text-xs text-muted-foreground">+ Shows the latest saved version. Hidden from search engines.+ {report.sharedAt+ ? ` Link created ${formatRelativeTime(report.sharedAt)}.`+ : ""}+ </p></div>- <p className="text-xs text-base-content/50">- Shows the latest saved version. Hidden from search engines.- {report.sharedAt- ? ` Link created ${formatRelativeTime(report.sharedAt)}.`- : ""}- </p>- </div>- ) : null}- </div>+ ) : null}+ </div>- {/* Shown in place rather than as a toast: the message belongs next to- the toggle that would not move. */}- {mutation.isError ? (- <p className="text-sm text-error">- {getStandardErrorMessage(mutation.error, "Failed to update sharing")}- </p>- ) : null}- </Modal>+ {/* Shown in place rather than as a toast: the message belongs next to+ the toggle that would not move. */}+ {mutation.isError ? (+ <p className="text-sm text-destructive">+ {getStandardErrorMessage(+ mutation.error,+ "Failed to update sharing",+ )}+ </p>+ ) : null}+ </DialogContent>+ </Dialog>);}diff --git a/src/routes/_app/p/$projectId/reports/$reportId.tsx b/src/routes/_app/p/$projectId/reports/$reportId.tsxindex 4775bf9e..817961eb 100644--- a/src/routes/_app/p/$projectId/reports/$reportId.tsx+++ b/src/routes/_app/p/$projectId/reports/$reportId.tsx@@ -13,9 +13,16 @@ import {} from "lucide-react";import { z } from "zod";import { BackLink, PageHeader } from "@/client/components/PageHeader";-import { PortalMenu } from "@/client/components/PortalMenu";import { QueryError } from "@/client/components/QueryState";import { PageLoading } from "@/client/components/Spinner";+import { Button } from "@/client/components/ui/button";+import {+ DropdownMenu,+ DropdownMenuContent,+ DropdownMenuItem,+ DropdownMenuSeparator,+ DropdownMenuTrigger,+} from "@/client/components/ui/dropdown-menu";import { ReportViewer } from "@/client/features/reports/ReportViewer";import {DeleteReportModal,@@ -162,17 +169,17 @@ function ReportDetailPage() {description={<dl className="flex flex-wrap items-baseline gap-x-6 gap-y-1 text-foreground"><div className="flex items-baseline gap-1.5">- <dt className="text-base-content/50">Created by</dt>+ <dt className="text-muted-foreground">Created by</dt><dd>{formatCreatedBy(report)}</dd></div><div className="flex items-baseline gap-1.5">- <dt className="text-base-content/50">Type</dt>+ <dt className="text-muted-foreground">Type</dt>{/* As in the list's Type column: the template name when thereport followed one, else the skill, else an em dash. */}<dd>{report.templateName ?? report.skill ?? "—"}</dd></div><div className="flex items-baseline gap-1.5">- <dt className="text-base-content/50">Updated</dt>+ <dt className="text-muted-foreground">Updated</dt><dd title={new Date(report.updatedAt).toLocaleString()}>{formatRelativeTime(report.updatedAt)}</dd>@@ -187,70 +194,51 @@ function ReportDetailPage() {icon carries the state: a globe once a public link is live, alock while only members can open it. */}{hosted ? (- <button- type="button"- className="btn btn-primary btn-sm gap-1.5"- onClick={() => setShowShare(true)}- >+ <Button onClick={() => setShowShare(true)}>{report.shareToken ? (- <Globe className="size-4" />+ <Globe data-icon="inline-start" />) : (- <Lock className="size-4" />+ <Lock data-icon="inline-start" />)}Share- </button>+ </Button>) : (- <button- type="button"- className="btn btn-primary btn-sm gap-1.5"- onClick={exportPdf}- >- <FileDown className="size-4" />+ <Button onClick={exportPdf}>+ <FileDown data-icon="inline-start" />Export- </button>+ </Button>)}- <PortalMenu- ariaLabel="Report actions"- triggerClassName="btn btn-ghost btn-sm btn-square"- triggerContent={<MoreHorizontal className="size-4" />}- menuClassName="w-52"- >- {(close) => (- <>- {hosted ? (- <>- <li>- <button- onClick={() => {- close();- exportPdf();- }}- >- <FileDown className="size-4" />- Export- </button>- </li>- <li- role="separator"- className="mx-1 my-1 h-px bg-base-300"- />- </>- ) : null}- <li>- <button- className="text-error"- onClick={() => {- close();- setShowDelete(true);- }}- >- <Trash2 className="size-4" />- Delete- </button>- </li>- </>- )}- </PortalMenu>+ <DropdownMenu>+ <DropdownMenuTrigger+ render={+ <Button+ variant="ghost"+ size="icon"+ aria-label="Report actions"+ />+ }+ >+ <MoreHorizontal />+ </DropdownMenuTrigger>+ <DropdownMenuContent align="end" className="w-52">+ {hosted ? (+ <>+ <DropdownMenuItem onClick={exportPdf}>+ <FileDown />+ Export+ </DropdownMenuItem>+ <DropdownMenuSeparator />+ </>+ ) : null}+ <DropdownMenuItem+ variant="destructive"+ onClick={() => setShowDelete(true)}+ >+ <Trash2 />+ Delete+ </DropdownMenuItem>+ </DropdownMenuContent>+ </DropdownMenu></>}/>@@ -263,28 +251,30 @@ function ReportDetailPage() {so keyboard focus reaches them without tabbing through the report;inset from the edge so they clear a classic scrollbar. z-10 keepsthem above the viewer, which is positioned and comes later. */}- <div className="absolute top-1 right-5 z-10 flex items-center gap-0.5 rounded-md border border-base-300 bg-base-100/95 p-0.5 shadow-sm backdrop-blur">- <button- type="button"- className="btn btn-ghost btn-sm btn-square"+ <div className="absolute top-1 right-5 z-10 flex items-center gap-0.5 rounded-md border border-border bg-card/95 p-0.5 shadow-sm backdrop-blur">+ <Button+ variant="ghost"+ size="icon-sm"aria-label="Full screen"title="Full screen"onClick={() =>void navigate({ search: () => ({ full: true }), replace: true })}>- <Maximize2 className="size-4" />- </button>- <a- href={`/r/${report.id}`}- target="_blank"- rel="noreferrer"- className="btn btn-ghost btn-sm btn-square"+ <Maximize2 />+ </Button>+ <Button+ variant="ghost"+ size="icon-sm"+ nativeButton={false}aria-label="Open in new tab"title="Open in new tab"+ render={+ <a href={`/r/${report.id}`} target="_blank" rel="noreferrer" />+ }>- <ExternalLink className="size-4" />- </a>+ <ExternalLink />+ </Button></div><ReportViewer src={`/r/${report.id}`} title={report.title} /></div>@@ -334,24 +324,19 @@ function FullScreenReport({}, [onExit]);return (- <div className="fixed inset-0 z-50 flex flex-col bg-base-100">- <div className="flex items-center justify-between gap-3 border-b border-base-300 px-4 py-2">+ <div className="fixed inset-0 z-50 flex flex-col bg-background">+ <div className="flex items-center justify-between gap-3 border-b border-border px-4 py-2"><span className="truncate text-sm font-medium">{title}</span>- <button- type="button"- ref={exitRef}- className="btn btn-ghost btn-sm gap-1.5"- onClick={onExit}- >- <Minimize2 className="size-4" />+ <Button ref={exitRef} variant="ghost" onClick={onExit}>+ <Minimize2 data-icon="inline-start" />Exit- </button>+ </Button></div><div className="min-h-0 flex-1 p-2"><ReportViewersrc={`/r/${reportId}`}title={title}- className="h-full w-full bg-base-100"+ className="h-full w-full bg-background"/></div></div>