Skip to content

Open source alternative to Semrush and Ahrefs

Port Site Audit and Lighthouse issues to shadcn (EVE-316) (#760)

Carter Smithef38940ac9ee
diff --git a/src/client/components/ExportMenu.tsx b/src/client/components/ExportMenu.tsx
index 15c21275..7e05c281 100644
--- a/src/client/components/ExportMenu.tsx
+++ b/src/client/components/ExportMenu.tsx
@@ -35,8 +35,9 @@ const ACTION_ITEMS: Record<ExportAction, { label: string; icon: ReactNode }> = {
/**
* The toolbar Export button. The caller runs each action through
* `exportRows()`, so every format shares the empty check and the analytics
- * event. With `scopes`, each scope is a labelled section with the same
- * actions, for example "Current category" and "All actionable".
+ * event. With `scopes`, each scope is a labelled section, for example
+ * "Current category" and "All actionable". A scope lists its own `actions`
+ * when it offers fewer than the menu.
*/
export function ExportMenu<A extends ExportAction>({
actions,
@@ -53,10 +54,10 @@ export function ExportMenu<A extends ExportAction>({
disabled?: boolean;
/** Label for "copy-list", for example "Copy keywords". */
copyListLabel?: string;
- scopes?: { id: string; label: string }[];
+ scopes?: { id: string; label: string; actions?: A[] }[];
}) {
- const renderItems = (scope?: string) =>
- actions.map((action) => (
+ const renderItems = (scope?: string, scopeActions: A[] = actions) =>
+ scopeActions.map((action) => (
<DropdownMenuItem key={action} onClick={() => onExport(action, scope)}>
{ACTION_ITEMS[action].icon}
{action === "copy-list" && copyListLabel
@@ -87,7 +88,7 @@ export function ExportMenu<A extends ExportAction>({
{index > 0 ? <DropdownMenuSeparator /> : null}
<DropdownMenuGroup>
<DropdownMenuLabel>{scope.label}</DropdownMenuLabel>
- {renderItems(scope.id)}
+ {renderItems(scope.id, scope.actions)}
</DropdownMenuGroup>
</Fragment>
))
diff --git a/src/client/features/audit/AuditDetail.tsx b/src/client/features/audit/AuditDetail.tsx
index 31fbd357..60cf13af 100644
--- a/src/client/features/audit/AuditDetail.tsx
+++ b/src/client/features/audit/AuditDetail.tsx
@@ -1,8 +1,14 @@
-import { AlertCircle } from "lucide-react";
+import { AlertCircle, ChevronLeft } from "lucide-react";
import { useQuery } from "@tanstack/react-query";
import { QueryError, QueryState } from "@/client/components/QueryState";
import { PageLoading } from "@/client/components/Spinner";
+import {
+ Alert,
+ AlertDescription,
+ AlertTitle,
+} from "@/client/components/ui/alert";
import { Badge } from "@/client/components/ui/badge";
+import { Button } from "@/client/components/ui/button";
import {
Card,
CardAction,
@@ -24,6 +30,7 @@ import {
} from "@/serverFunctions/audit";
import { ResultsView } from "@/client/features/audit/results/ResultsView";
import {
+ BotProtectionAdvice,
extractHostname,
extractPathname,
formatStartedAt,
@@ -82,9 +89,10 @@ export function AuditDetail({
onRetry={() => void statusQuery.refetch()}
isRetrying={statusQuery.isFetching}
/>
- <button className="btn btn-ghost btn-sm" onClick={onBack}>
- &larr; Back to audits
- </button>
+ <Button variant="ghost" size="sm" onClick={onBack}>
+ <ChevronLeft data-icon="inline-start" />
+ Back to audits
+ </Button>
</div>
</div>
);
@@ -107,16 +115,22 @@ export function AuditDetail({
<div className="px-4 py-4 md:px-6 md:py-6 pb-24 md:pb-8 overflow-auto">
<div className="mx-auto max-w-5xl space-y-4">
<div className="space-y-1">
- <button className="btn btn-ghost btn-sm px-0" onClick={onBack}>
- &larr; All audits
- </button>
+ <Button
+ variant="ghost"
+ size="sm"
+ className="-ml-2.5"
+ onClick={onBack}
+ >
+ <ChevronLeft data-icon="inline-start" />
+ All audits
+ </Button>
<div className="flex flex-wrap items-center gap-x-3 gap-y-1">
<h1 className="text-2xl font-semibold">
{extractHostname(status.startUrl)}
</h1>
{!isRunning && <StatusBadge status={status.status} />}
</div>
- <p className="text-sm text-base-content/60">
+ <p className="text-sm text-muted-foreground">
Site audit &middot; Started {formatStartedAt(status.startedAt)}
</p>
</div>
@@ -130,86 +144,51 @@ export function AuditDetail({
)}
{failedWithoutResults && (
- <div className="alert alert-error">
- <AlertCircle className="size-5" />
- <div className="space-y-1">
- <p className="font-medium">
- This audit stopped before it crawled any pages.
- </p>
+ <Alert variant="destructive">
+ <AlertCircle />
+ <AlertTitle>
+ This audit stopped before it crawled any pages.
+ </AlertTitle>
+ <AlertDescription>
<p>
Run a new audit to try again, or email{" "}
- <a
- className="link link-primary"
- href={`mailto:${SUPPORT_EMAIL}`}
- >
- {SUPPORT_EMAIL}
- </a>{" "}
- if this keeps happening.
+ <a href={`mailto:${SUPPORT_EMAIL}`}>{SUPPORT_EMAIL}</a> if this
+ keeps happening.
</p>
{status.errorCode ? (
- <p className="font-mono text-xs opacity-70">
- Code: {status.errorCode}
- </p>
+ <p className="font-mono text-xs">Code: {status.errorCode}</p>
) : null}
- </div>
- </div>
+ </AlertDescription>
+ </Alert>
)}
{showBlockedCta && (
- <div className="alert alert-warning">
- <AlertCircle className="size-5" />
- <div className="space-y-1">
- <p className="font-medium">
- Site audit couldn't fully crawl this website.
- </p>
- <p>
- Sorry! This site's bot protection blocked our crawler. We don't
- have a workaround for this yet. Desktop crawlers run from your
- own machine and usually get past it: try{" "}
- <a
- className="link link-primary"
- href="https://github.com/PhialsBasement/LibreCrawl"
- target="_blank"
- rel="noreferrer"
- >
- LibreCrawl
- </a>{" "}
- (free, open source) or{" "}
- <a
- className="link link-primary"
- href="https://www.screamingfrog.co.uk/seo-spider/"
- target="_blank"
- rel="noreferrer"
- >
- Screaming Frog
- </a>{" "}
- (free up to 500 URLs).
- </p>
- </div>
- </div>
+ <Alert variant="warning">
+ <AlertCircle />
+ <AlertTitle>
+ Site audit couldn't fully crawl this website.
+ </AlertTitle>
+ <AlertDescription>
+ Sorry! This site's bot protection blocked our crawler.{" "}
+ <BotProtectionAdvice />
+ </AlertDescription>
+ </Alert>
)}
{failedWithResults && (
- <div className="alert alert-warning">
- <AlertCircle className="size-5" />
- <div className="space-y-1">
- <p className="font-medium">
- This audit stopped early after {partialPageCount} page
- {partialPageCount === 1 ? "" : "s"}.
- </p>
- <p>
- The results below cover everything crawled before it stopped.
- Run a new audit to try again, or email{" "}
- <a
- className="link link-primary"
- href={`mailto:${SUPPORT_EMAIL}`}
- >
- {SUPPORT_EMAIL}
- </a>{" "}
- if this keeps happening.
- </p>
- </div>
- </div>
+ <Alert variant="warning">
+ <AlertCircle />
+ <AlertTitle>
+ This audit stopped early after {partialPageCount} page
+ {partialPageCount === 1 ? "" : "s"}.
+ </AlertTitle>
+ <AlertDescription>
+ The results below cover everything crawled before it stopped. Run
+ a new audit to try again, or email{" "}
+ <a href={`mailto:${SUPPORT_EMAIL}`}>{SUPPORT_EMAIL}</a> if this
+ keeps happening.
+ </AlertDescription>
+ </Alert>
)}
{(isComplete || isFailed) && (
@@ -357,14 +336,14 @@ function ProgressRow({
>
<div className="flex items-center gap-2 min-w-0 flex-1">
<HttpStatusBadge code={entry.statusCode} />
- <span className="truncate text-base-content/80" title={entry.url}>
+ <span className="truncate text-foreground/80" title={entry.url}>
{pathname}
</span>
</div>
<div className="flex items-center gap-3 shrink-0">
{entry.title && (
<span
- className="text-xs text-base-content/40 truncate max-w-[260px] hidden md:block"
+ className="text-xs text-muted-foreground truncate max-w-[260px] hidden md:block"
title={entry.title}
>
{entry.title}
diff --git a/src/client/features/audit/launch/AuditHistorySection.tsx b/src/client/features/audit/launch/AuditHistorySection.tsx
index 05fe56c8..f37b64c6 100644
--- a/src/client/features/audit/launch/AuditHistorySection.tsx
+++ b/src/client/features/audit/launch/AuditHistorySection.tsx
@@ -2,9 +2,18 @@ import { Link } from "@tanstack/react-router";
import type { UseQueryResult } from "@tanstack/react-query";
import { ScanSearch, Trash2 } from "lucide-react";
import type { getAuditHistory } from "@/serverFunctions/audit";
-import { PortalMenu } from "@/client/components/PortalMenu";
+import { EmptyState } from "@/client/components/EmptyState";
import { QueryState } from "@/client/components/QueryState";
+import { RowActionsMenu } from "@/client/components/RowActionsMenu";
import { Badge } from "@/client/components/ui/badge";
+import { Button } from "@/client/components/ui/button";
+import {
+ Card,
+ CardContent,
+ CardHeader,
+ CardTitle,
+} from "@/client/components/ui/card";
+import { DropdownMenuItem } from "@/client/components/ui/dropdown-menu";
import {
Table,
TableBody,
@@ -52,20 +61,17 @@ function AuditHistoryTable({
onDelete: (auditId: string) => void;
}) {
if (history.length === 0) {
- return (
- <div className="flex items-center justify-center py-16">
- <div className="text-center text-base-content/40 space-y-3">
- <ScanSearch className="size-12 mx-auto opacity-30" />
- <p className="text-lg font-medium">No audits yet</p>
- </div>
- </div>
- );
+ return <EmptyState icon={ScanSearch} title="No audits yet" />;
}
return (
- <div className="card bg-base-100 border border-base-300">
- <div className="card-body gap-3">
- <h2 className="card-title text-base">Previous Audits</h2>
+ <Card>
+ <CardHeader>
+ <CardTitle>
+ <h2>Previous Audits</h2>
+ </CardTitle>
+ </CardHeader>
+ <CardContent>
<Table>
<TableHeader>
<TableRow>
@@ -108,8 +114,8 @@ function AuditHistoryTable({
))}
</TableBody>
</Table>
- </div>
- </div>
+ </CardContent>
+ </Card>
);
}
@@ -124,30 +130,28 @@ function HistoryActions({
}) {
return (
<div className="flex items-center justify-end gap-2 reveal-on-hover">
- <Link
- to="/p/$projectId/audit"
- params={{ projectId }}
- search={{ auditId, tab: "pages" }}
- className="btn btn-primary btn-xs"
+ <Button
+ size="xs"
+ nativeButton={false}
+ render={
+ <Link
+ to="/p/$projectId/audit"
+ params={{ projectId }}
+ search={{ auditId, tab: "pages" }}
+ />
+ }
>
View
- </Link>
- <PortalMenu ariaLabel="Audit actions">
- {(close) => (
- <li>
- <button
- className="text-error"
- onClick={() => {
- close();
- onDelete(auditId);
- }}
- >
- <Trash2 className="size-3.5" />
- Delete audit
- </button>
- </li>
- )}
- </PortalMenu>
+ </Button>
+ <RowActionsMenu label="Audit actions">
+ <DropdownMenuItem
+ variant="destructive"
+ onClick={() => onDelete(auditId)}
+ >
+ <Trash2 />
+ Delete audit
+ </DropdownMenuItem>
+ </RowActionsMenu>
</div>
);
}
diff --git a/src/client/features/audit/launch/LaunchFormCard.tsx b/src/client/features/audit/launch/LaunchFormCard.tsx
index 90099917..56f2a5b3 100644
--- a/src/client/features/audit/launch/LaunchFormCard.tsx
+++ b/src/client/features/audit/launch/LaunchFormCard.tsx
@@ -1,5 +1,21 @@
import { Link } from "@tanstack/react-router";
-import { Loader2 } from "lucide-react";
+import { AlertCircle } from "lucide-react";
+import { Alert, AlertTitle } from "@/client/components/ui/alert";
+import { Button } from "@/client/components/ui/button";
+import {
+ Card,
+ CardContent,
+ CardHeader,
+ CardTitle,
+} from "@/client/components/ui/card";
+import {
+ Field,
+ FieldDescription,
+ FieldError,
+ FieldLabel,
+} from "@/client/components/ui/field";
+import { Input } from "@/client/components/ui/input";
+import { Switch } from "@/client/components/ui/switch";
import { MIN_PAGES } from "@/client/features/audit/launch/types";
import type { useLaunchController } from "@/client/features/audit/launch/useLaunchController";
import { getFieldError, getFormError } from "@/client/lib/forms";
@@ -18,10 +34,13 @@ export function LaunchFormCard({
maxPagesLimit,
}: Props) {
return (
- <div className="card bg-base-100 border border-base-300">
- <div className="card-body gap-4">
- <h2 className="card-title text-base">Start New Audit</h2>
-
+ <Card>
+ <CardHeader>
+ <CardTitle>
+ <h2>Start New Audit</h2>
+ </CardTitle>
+ </CardHeader>
+ <CardContent className="space-y-4">
<form
className="grid grid-cols-1 gap-3 lg:grid-cols-12 lg:items-center"
onSubmit={(event) => {
@@ -34,39 +53,33 @@ export function LaunchFormCard({
const urlError = getFieldError(field.state.meta.errors);
return (
- <label
- className={`input input-bordered w-full lg:col-span-9 ${urlError ? "input-error" : ""}`}
- >
- <input
- placeholder="https://example.com"
- value={field.state.value}
- onChange={(event) => {
- field.handleChange(event.target.value);
- if (launchForm.state.errorMap.onSubmit) {
- launchForm.setErrorMap({ onSubmit: undefined });
- }
- }}
- />
- </label>
+ <Input
+ className="lg:col-span-9"
+ aria-label="Site URL"
+ aria-invalid={urlError ? true : undefined}
+ placeholder="https://example.com"
+ value={field.state.value}
+ onBlur={field.handleBlur}
+ onChange={(event) => {
+ field.handleChange(event.target.value);
+ if (launchForm.state.errorMap.onSubmit) {
+ launchForm.setErrorMap({ onSubmit: undefined });
+ }
+ }}
+ />
);
}}
</launchForm.Field>
<launchForm.Subscribe selector={(state) => state.isSubmitting}>
{(isSubmitting) => (
- <button
+ <Button
type="submit"
- className="btn btn-primary btn-sm w-full lg:col-span-3"
- disabled={isSubmitting}
+ className="w-full lg:col-span-3"
+ pending={isSubmitting}
>
- {isSubmitting ? (
- <>
- <Loader2 className="size-4 animate-spin" /> Starting...
- </>
- ) : (
- "Start Audit"
- )}
- </button>
+ {isSubmitting ? "Starting..." : "Start Audit"}
+ </Button>
)}
</launchForm.Subscribe>
@@ -81,8 +94,8 @@ export function LaunchFormCard({
</form>
<LaunchErrors launchForm={launchForm} />
- </div>
- </div>
+ </CardContent>
+ </Card>
);
}
@@ -94,90 +107,79 @@ function LaunchOptions({
const isFreeLimited = maxPagesLimit < PAID_MAX_AUDIT_PAGES;
return (
- <div className="rounded-lg border border-base-300 bg-base-200/20 p-3 space-y-2">
- <label className="text-xs font-medium uppercase tracking-wide text-base-content/60">
- Crawl limit
- </label>
- <div className="flex items-center gap-2">
- <span className="text-sm text-base-content/70">Max pages</span>
- <launchForm.Field name="maxPagesInput">
- {(field) => (
- <input
- type="number"
- min={MIN_PAGES}
- max={maxPagesLimit}
- className="input input-bordered input-sm w-28"
- value={field.state.value}
- onChange={(event) => {
- const next = event.target.value;
- if (!/^\d*$/.test(next)) return;
- field.handleChange(next);
- if (launchForm.state.errorMap.onSubmit) {
- launchForm.setErrorMap({ onSubmit: undefined });
- }
- }}
- onBlur={commitMaxPagesInput}
- />
- )}
- </launchForm.Field>
- </div>
- <p className="text-xs text-base-content/50">
+ <Field className="rounded-lg border border-border p-3">
+ <FieldLabel htmlFor="audit-max-pages">Max pages</FieldLabel>
+ <launchForm.Field name="maxPagesInput">
+ {(field) => (
+ <Input
+ id="audit-max-pages"
+ type="number"
+ min={MIN_PAGES}
+ max={maxPagesLimit}
+ className="w-28"
+ value={field.state.value}
+ onChange={(event) => {
+ const next = event.target.value;
+ if (!/^\d*$/.test(next)) return;
+ field.handleChange(next);
+ if (launchForm.state.errorMap.onSubmit) {
+ launchForm.setErrorMap({ onSubmit: undefined });
+ }
+ }}
+ onBlur={commitMaxPagesInput}
+ />
+ )}
+ </launchForm.Field>
+ <FieldDescription>
Enter any value from {MIN_PAGES} to {maxPagesLimit.toLocaleString()}.
{isFreeLimited ? (
<>
{" "}
- <Link
- to={SUBSCRIBE_ROUTE}
- search={{ upgrade: true }}
- className="link link-primary"
- >
+ <Link to={SUBSCRIBE_ROUTE} search={{ upgrade: true }}>
Upgrade
</Link>{" "}
to crawl up to {PAID_MAX_AUDIT_PAGES.toLocaleString()} pages.
</>
) : null}
- </p>
- </div>
+ </FieldDescription>
+ </Field>
);
}
function LighthouseOptions({ launchForm }: Pick<Props, "launchForm">) {
return (
- <div className="rounded-lg border border-base-300 bg-base-200/20 p-3 space-y-2">
- <label className="label cursor-pointer justify-start gap-2 p-0">
+ <Field className="rounded-lg border border-border p-3">
+ <div className="flex items-center gap-2">
<launchForm.Field name="runLighthouse">
{(field) => (
- <input
- type="checkbox"
- className="toggle toggle-sm toggle-primary"
+ <Switch
+ id="audit-run-lighthouse"
checked={Boolean(field.state.value)}
- onChange={(event) => field.handleChange(event.target.checked)}
+ onCheckedChange={(checked) => field.handleChange(checked)}
/>
)}
</launchForm.Field>
- <span
- className="text-sm font-medium text-base-content/80"
+ <FieldLabel
+ htmlFor="audit-run-lighthouse"
title="Lighthouse measures the performance of your pages and identifies issues."
>
Include Lighthouse
- </span>
- </label>
+ </FieldLabel>
+ </div>
<launchForm.Subscribe
selector={(snapshot) => snapshot.values.runLighthouse}
>
{(runLighthouse) =>
runLighthouse ? (
- <div className="space-y-1">
- <p className="text-xs text-base-content/60">
- We choose a sample of 20 pages to audit, removing pages from
- duplicate templates.
- </p>
- </div>
+ <FieldDescription>
+ We choose a sample of 20 pages to audit, removing pages from
+ duplicate templates.
+ </FieldDescription>
) : null
}
</launchForm.Subscribe>
- </div>
+ </Field>
);
}
@@ -188,9 +190,7 @@ function LaunchErrors({ launchForm }: Pick<Props, "launchForm">) {
{(field) => {
const urlError = getFieldError(field.state.meta.errors);
- return urlError ? (
- <p className="text-sm text-error">{urlError}</p>
- ) : null;
+ return urlError ? <FieldError>{urlError}</FieldError> : null;
}}
</launchForm.Field>
@@ -199,9 +199,10 @@ function LaunchErrors({ launchForm }: Pick<Props, "launchForm">) {
const errorMessage = getFormError(submitError);
return errorMessage ? (
- <div className="alert alert-error py-2">
- <span className="text-sm">{errorMessage}</span>
- </div>
+ <Alert variant="destructive">
+ <AlertCircle />
+ <AlertTitle>{errorMessage}</AlertTitle>
+ </Alert>
) : null;
}}
</launchForm.Subscribe>
diff --git a/src/client/features/audit/launch/LaunchView.tsx b/src/client/features/audit/launch/LaunchView.tsx
index 18bb1cb3..f21eba9d 100644
--- a/src/client/features/audit/launch/LaunchView.tsx
+++ b/src/client/features/audit/launch/LaunchView.tsx
@@ -1,3 +1,5 @@
+import { ConfirmDialog } from "@/client/components/ConfirmDialog";
+import { PageHeader } from "@/client/components/PageHeader";
import { AuditHistorySection } from "@/client/features/audit/launch/AuditHistorySection";
import { LaunchFormCard } from "@/client/features/audit/launch/LaunchFormCard";
import { useLaunchController } from "@/client/features/audit/launch/useLaunchController";
@@ -27,7 +29,7 @@ export function LaunchView({
return (
<div className="px-4 py-4 md:px-6 md:py-6 pb-24 md:pb-8 overflow-auto">
<div className="mx-auto max-w-5xl space-y-4">
- <h1 className="text-2xl font-semibold">Site Audit</h1>
+ <PageHeader title="Site Audit" />
<LaunchFormCard
launchForm={controller.launchForm}
@@ -40,6 +42,18 @@ export function LaunchView({
historyQuery={controller.historyQuery}
onDelete={controller.deleteAudit}
/>
+
+ {controller.largeCrawlPages != null ? (
+ <ConfirmDialog
+ title="Start a large audit?"
+ confirmLabel="Continue"
+ onConfirm={controller.confirmLargeCrawl}
+ onClose={controller.cancelLargeCrawl}
+ >
+ You are about to crawl {controller.largeCrawlPages.toLocaleString()}{" "}
+ pages. This is okay, but it may take a while. Continue?
+ </ConfirmDialog>
+ ) : null}
</div>
</div>
);
diff --git a/src/client/features/audit/launch/useLaunchController.ts b/src/client/features/audit/launch/useLaunchController.ts
index 41f5efd7..aa0b41f2 100644
--- a/src/client/features/audit/launch/useLaunchController.ts
+++ b/src/client/features/audit/launch/useLaunchController.ts
@@ -1,3 +1,4 @@
+import { useRef, useState } from "react";
import { useForm } from "@tanstack/react-form";
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
import { toast } from "sonner";
@@ -59,6 +60,9 @@ export function useLaunchController({
: false,
});
const { startMutation, deleteMutation } = useLaunchMutations({ projectId });
+ // Pages of a large crawl waiting for the user to confirm it.
+ const [largeCrawlPages, setLargeCrawlPages] = useState<number | null>(null);
+ const largeCrawlConfirmed = useRef(false);
const launchForm = useForm({
defaultValues: { ...DEFAULT_LAUNCH_FORM_VALUES, url: initialUrl },
@@ -74,14 +78,11 @@ export function useLaunchController({
const effectiveMaxPages = commitMaxPagesInput(launchForm, maxPagesLimit);
formApi.setErrorMap({ onSubmit: undefined });
- if (effectiveMaxPages > 500) {
- const confirmed = window.confirm(
- `You are about to crawl ${effectiveMaxPages.toLocaleString()} pages. This is okay, but it may take a while. Continue?`,
- );
- if (!confirmed) {
- return;
- }
+ if (effectiveMaxPages > 500 && !largeCrawlConfirmed.current) {
+ setLargeCrawlPages(effectiveMaxPages);
+ return;
}
+ largeCrawlConfirmed.current = false;
try {
const result = await startMutation.mutateAsync({
@@ -108,6 +109,13 @@ export function useLaunchController({
maxPagesLimit,
commitMaxPagesInput: () => commitMaxPagesInput(launchForm, maxPagesLimit),
deleteAudit: (auditId: string) => deleteMutation.mutate(auditId),
+ largeCrawlPages,
+ cancelLargeCrawl: () => setLargeCrawlPages(null),
+ confirmLargeCrawl: () => {
+ setLargeCrawlPages(null);
+ largeCrawlConfirmed.current = true;
+ void launchForm.handleSubmit();
+ },
};
}
diff --git a/src/client/features/audit/results/AuditResultsTableFilters.tsx b/src/client/features/audit/results/AuditResultsTableFilters.tsx
index 2e9b086a..02ed7cd9 100644
--- a/src/client/features/audit/results/AuditResultsTableFilters.tsx
+++ b/src/client/features/audit/results/AuditResultsTableFilters.tsx
@@ -1,5 +1,18 @@
-import { RotateCcw, SlidersHorizontal } from "lucide-react";
-import type { ReactNode } from "react";
+import {
+ DataTableFilterGroup,
+ DataTableFilterPanel,
+ DataTableFilterToggle,
+ DataTableRangeFilter,
+ DataTableToolbar,
+} from "@/client/components/table/DataTableToolbar";
+import { Input } from "@/client/components/ui/input";
+import {
+ Select,
+ SelectContent,
+ SelectItem,
+ SelectTrigger,
+ SelectValue,
+} from "@/client/components/ui/select";
import type {
PagesFilters,
PerformanceFilters,
@@ -17,7 +30,7 @@ export function PagesFilterBar({
onReset: () => void;
}) {
return (
- <FilterPanel activeFilterCount={activeFilterCount} onReset={onReset}>
+ <DataTableFilterPanel activeCount={activeFilterCount} onReset={onReset}>
<div className="grid grid-cols-1 gap-3 lg:grid-cols-3">
<TextFilter
label="Search"
@@ -68,7 +81,7 @@ export function PagesFilterBar({
}
/>
</div>
- </FilterPanel>
+ </DataTableFilterPanel>
);
}
@@ -84,7 +97,7 @@ export function PerformanceFilterBar({
onReset: () => void;
}) {
return (
- <FilterPanel activeFilterCount={activeFilterCount} onReset={onReset}>
+ <DataTableFilterPanel activeCount={activeFilterCount} onReset={onReset}>
<div className="grid grid-cols-1 gap-3 lg:grid-cols-4">
<TextFilter
label="Search"
@@ -136,15 +149,12 @@ export function PerformanceFilterBar({
onMaxChange={(maxSeo) => onChange({ ...filters, maxSeo })}
/>
</div>
- </FilterPanel>
+ </DataTableFilterPanel>
);
}
-export function EmptyTableMessage({ label }: { label: string }) {
- return <div className="py-6 text-center text-base-content/60">{label}</div>;
-}
-
-export function TableFilterToggle({
+/** The toolbar above a results table: the filter toggle and the row count. */
+export function ResultsTableToolbar({
showFilters,
onToggle,
activeFilterCount,
@@ -158,25 +168,19 @@ export function TableFilterToggle({
totalCount: number;
}) {
return (
- <div className="flex flex-wrap items-center justify-between gap-3 border-b border-base-300 px-4 py-2.5">
- <button
- className={`btn btn-ghost btn-sm gap-1.5 ${showFilters ? "btn-active" : ""}`}
- onClick={onToggle}
- title="Toggle filters"
- type="button"
- >
- <SlidersHorizontal className="size-3.5" />
- Filters
- {activeFilterCount > 0 ? (
- <span className="badge badge-xs badge-primary border-0 text-primary-content">
- {activeFilterCount}
- </span>
- ) : null}
- </button>
- <span className="text-sm tabular-nums text-base-content/60">
- {resultCount.toLocaleString()} of {totalCount.toLocaleString()}
- </span>
- </div>
+ <DataTableToolbar
+ actions={
+ <span className="text-sm tabular-nums text-muted-foreground">
+ {resultCount.toLocaleString()} of {totalCount.toLocaleString()}
+ </span>
+ }
+ >
+ <DataTableFilterToggle
+ open={showFilters}
+ activeCount={activeFilterCount}
+ onToggle={onToggle}
+ />
+ </DataTableToolbar>
);
}
@@ -190,41 +194,6 @@ export function countActiveFilters<TFilters extends Record<string, string>>(
}, 0);
}
-function FilterPanel({
- activeFilterCount,
- onReset,
- children,
-}: {
- activeFilterCount: number;
- onReset: () => void;
- children: ReactNode;
-}) {
- return (
- <div className="space-y-3 border-b border-base-300 bg-gradient-to-b from-base-100 to-base-200/30 px-4 py-3">
- <div className="flex flex-wrap items-center justify-between gap-2">
- <div className="flex items-center gap-2">
- <p className="text-sm font-semibold">Refine results</p>
- {activeFilterCount > 0 ? (
- <span className="badge badge-xs badge-primary border-0 text-primary-content">
- {activeFilterCount} active
- </span>
- ) : null}
- </div>
- <button
- type="button"
- className="btn btn-xs btn-ghost gap-1"
- onClick={onReset}
- disabled={activeFilterCount === 0}
- >
- <RotateCcw className="size-3" />
- Clear all
- </button>
- </div>
- {children}
- </div>
- );
-}
-
function TextFilter({
label,
value,
@@ -239,18 +208,15 @@ function TextFilter({
onChange: (value: string) => void;
}) {
return (
- <label className="form-control gap-1.5">
- <span className="text-[11px] font-semibold uppercase tracking-wide text-base-content/60">
- {label}
- </span>
- <input
- className="input input-bordered input-sm w-full bg-base-100"
+ <DataTableFilterGroup label={label}>
+ <Input
+ aria-label={label}
type={type}
value={value}
placeholder={placeholder}
onChange={(event) => onChange(event.target.value)}
/>
- </label>
+ </DataTableFilterGroup>
);
}
@@ -268,27 +234,11 @@ function RangeFilter({
onMaxChange: (value: string) => void;
}) {
return (
- <div className="space-y-2 rounded-lg border border-base-300 bg-base-100 p-2.5">
- <p className="text-[11px] font-semibold uppercase tracking-wide text-base-content/60">
- {label}
- </p>
- <div className="grid grid-cols-2 gap-2">
- <input
- className="input input-bordered input-xs bg-base-100"
- type="number"
- value={min}
- placeholder="Min"
- onChange={(event) => onMinChange(event.target.value)}
- />
- <input
- className="input input-bordered input-xs bg-base-100"
- type="number"
- value={max}
- placeholder="Max"
- onChange={(event) => onMaxChange(event.target.value)}
- />
- </div>
- </div>
+ <DataTableRangeFilter
+ label={label}
+ min={{ value: min, onChange: (event) => onMinChange(event.target.value) }}
+ max={{ value: max, onChange: (event) => onMaxChange(event.target.value) }}
+ />
);
}
@@ -303,27 +253,30 @@ function SelectFilter<T extends string>({
options: Array<[T, string]>;
onChange: (value: T) => void;
}) {
+ const items = options.map(([optionValue, optionLabel]) => ({
+ value: optionValue,
+ label: optionLabel,
+ }));
return (
- <label className="form-control gap-1.5">
- <span className="text-[11px] font-semibold uppercase tracking-wide text-base-content/60">
- {label}
- </span>
- <select
- className="select select-bordered select-sm w-full bg-base-100"
+ <DataTableFilterGroup label={label}>
+ <Select
+ items={items}
value={value}
- onChange={(event) => {
- const selected = options.find(
- ([optionValue]) => optionValue === event.target.value,
- )?.[0];
- if (selected != null) onChange(selected);
+ onValueChange={(next) => {
+ if (next !== null) onChange(next);
}}
>
- {options.map(([optionValue, optionLabel]) => (
- <option key={optionValue} value={optionValue}>
- {optionLabel}
- </option>
- ))}
- </select>
- </label>
+ <SelectTrigger aria-label={label} className="w-full">
+ <SelectValue />
+ </SelectTrigger>
+ <SelectContent>
+ {items.map((item) => (
+ <SelectItem key={item.value} value={item.value}>
+ {item.label}
+ </SelectItem>
+ ))}
+ </SelectContent>
+ </Select>
+ </DataTableFilterGroup>
);
}
diff --git a/src/client/features/audit/results/IssuesView.tsx b/src/client/features/audit/results/IssuesView.tsx
index 3d1dd3c7..fcdae9d9 100644
--- a/src/client/features/audit/results/IssuesView.tsx
+++ b/src/client/features/audit/results/IssuesView.tsx
@@ -7,21 +7,17 @@ import {
type IssueSeverity,
} from "@/shared/audit-issues";
import type { AuditResultsData } from "@/client/features/audit/results/types";
+import { SeverityBadge } from "@/client/features/audit/shared";
+import { EmptyState } from "@/client/components/EmptyState";
type AuditIssueRow = AuditResultsData["issues"][number];
const MAX_RENDERED_URLS = 100;
-const SEVERITY_DOT: Record<IssueSeverity, string> = {
- critical: "bg-error",
- warning: "bg-warning",
- info: "bg-base-content/30",
-};
-
const SEVERITY_RULE: Record<IssueSeverity, string> = {
- critical: "border-l-error/60",
+ critical: "border-l-destructive/60",
warning: "border-l-warning/60",
- info: "border-l-base-content/20",
+ info: "border-l-info/60",
};
const SEVERITY_LABEL: Record<IssueSeverity, string> = {
@@ -93,18 +89,15 @@ export function IssuesView({ issues }: { issues: AuditIssueRow[] }) {
if (issues.length === 0) {
return (
- <div className="py-10 text-center text-base-content/60">
- <p className="font-medium">No issues recorded for this audit.</p>
- <p className="text-sm mt-1">
- Either the site is in great shape, or this audit ran before issue
- checks existed — run a new audit to get the full report.
- </p>
- </div>
+ <EmptyState
+ title="No issues recorded for this audit."
+ description="Either the site is in great shape, or this audit ran before issue checks existed — run a new audit to get the full report."
+ />
);
}
return (
- <div className="border border-base-300 rounded-lg overflow-hidden">
+ <div className="border border-border rounded-lg overflow-hidden bg-card">
{sections.map((section) => (
<IssueSection key={section.severity} section={section} />
))}
@@ -123,19 +116,14 @@ function IssueSection({
);
return (
- <div className="border-t border-base-300 first:border-t-0">
- <div className="flex items-center gap-2 bg-base-200/60 px-4 py-1.5 border-b border-base-300/60">
- <span
- className={`size-1.5 rounded-full ${SEVERITY_DOT[section.severity]}`}
- />
- <span className="text-[11px] font-semibold uppercase tracking-wider text-base-content/60">
+ <div className="border-t border-border first:border-t-0">
+ <div className="flex items-center gap-2 bg-muted/50 px-4 py-1.5 border-b border-border">
+ <SeverityBadge severity={section.severity}>
{SEVERITY_LABEL[section.severity]}
- </span>
- <span className="text-[11px] tabular-nums text-base-content/40">
- {issueCount}
- </span>
+ <span className="tabular-nums">{issueCount}</span>
+ </SeverityBadge>
</div>
- <div className="divide-y divide-base-300/60">
+ <div className="divide-y divide-border">
{section.groups.map((group) => (
<IssueRow key={group.issueType} group={group} />
))}
@@ -151,43 +139,40 @@ function IssueRow({ group }: { group: IssueGroup }) {
<div
className={
open
- ? `border-l-2 ${SEVERITY_RULE[group.severity]} bg-base-200/20`
+ ? `border-l-2 ${SEVERITY_RULE[group.severity]} bg-muted/30`
: "border-l-2 border-l-transparent"
}
>
<button
type="button"
- className="w-full flex items-center gap-3 px-4 py-2.5 text-left hover:bg-base-200/40 transition-colors"
+ className="w-full flex items-center gap-3 px-4 py-2.5 text-left hover:bg-muted/50 transition-colors"
onClick={() => setOpen((value) => !value)}
aria-expanded={open}
>
- <span
- className={`size-2 shrink-0 rounded-full ${SEVERITY_DOT[group.severity]}`}
- />
<span className="text-sm font-medium flex-1 min-w-0 truncate">
{group.title}
</span>
- <span className="text-xs tabular-nums text-base-content/50 shrink-0">
+ <span className="text-xs tabular-nums text-muted-foreground shrink-0">
{group.issues.length} {group.issues.length === 1 ? "page" : "pages"}
</span>
<ChevronRight
- className={`size-4 shrink-0 text-base-content/40 transition-transform ${
+ className={`size-4 shrink-0 text-muted-foreground transition-transform ${
open ? "rotate-90" : ""
}`}
/>
</button>
{open && (
- <div className="pl-9 pr-4 pb-4 pt-0.5 space-y-3">
+ <div className="pl-4 pr-4 pb-4 pt-0.5 space-y-3">
{group.explanation && (
- <p className="text-sm text-base-content/70 max-w-prose">
+ <p className="text-sm text-muted-foreground max-w-prose">
{group.explanation}
</p>
)}
{group.howToFix && (
<p className="text-sm max-w-prose">
<span className="font-medium">How to fix: </span>
- <span className="text-base-content/80">{group.howToFix}</span>
+ <span className="text-foreground/80">{group.howToFix}</span>
</p>
)}
<AffectedUrlList issues={group.issues} />
@@ -202,14 +187,14 @@ function AffectedUrlList({ issues }: { issues: AuditIssueRow[] }) {
const remaining = issues.length - rendered.length;
return (
- <div className="max-h-[320px] overflow-y-auto rounded border border-base-300/60 bg-base-100">
+ <div className="max-h-[320px] overflow-y-auto rounded border border-border bg-card">
{rendered.map((issue) => (
<div
key={issue.id}
- className="px-3 py-1.5 text-sm flex flex-col gap-0.5 border-b border-base-300/50 last:border-b-0"
+ className="px-3 py-1.5 text-sm flex flex-col gap-0.5 border-b border-border last:border-b-0"
>
<a
- className="link link-hover text-base-content/80 truncate"
+ className="text-foreground/80 truncate hover:underline"
href={issue.pageUrl}
target="_blank"
rel="noreferrer"
@@ -221,7 +206,7 @@ function AffectedUrlList({ issues }: { issues: AuditIssueRow[] }) {
</div>
))}
{remaining > 0 && (
- <div className="px-3 py-2 text-xs text-base-content/50">
+ <div className="px-3 py-2 text-xs text-muted-foreground">
…and {remaining} more — export the issues CSV for the full list.
</div>
)}
@@ -253,7 +238,7 @@ function IssueDetails({ detailsJson }: { detailsJson: string | null }) {
if (entries.length === 0) return null;
return (
- <span className="text-xs text-base-content/50 truncate">
+ <span className="text-xs text-muted-foreground truncate">
{entries
.map(([key, value]) => {
const rendered = Array.isArray(value)
diff --git a/src/client/features/audit/results/PagesTable.tsx b/src/client/features/audit/results/PagesTable.tsx
index 2411239f..7fd20c78 100644
--- a/src/client/features/audit/results/PagesTable.tsx
+++ b/src/client/features/audit/results/PagesTable.tsx
@@ -5,8 +5,7 @@ import {
type SortingState,
} from "@tanstack/react-table";
import { ExternalLink } from "lucide-react";
-import { AppDataTable } from "@/client/components/table/AppDataTable";
-import { useDataTable } from "@/client/components/table/DataTable";
+import { DataTable, useDataTable } from "@/client/components/table/DataTable";
import { SortableHeader } from "@/client/components/table/SortableHeader";
import {
extractHostname,
@@ -16,9 +15,8 @@ import {
import type { AuditResultsData } from "@/client/features/audit/results/types";
import {
countActiveFilters,
- EmptyTableMessage,
PagesFilterBar,
- TableFilterToggle,
+ ResultsTableToolbar,
} from "@/client/features/audit/results/AuditResultsTableFilters";
import {
EMPTY_PAGES_FILTERS,
@@ -79,7 +77,9 @@ function hasAnalyzedContent(row: PageRow): boolean {
return row.fetchClass === "ok" && !isRedirect(row);
}
-const EmptyCell = () => <span className="text-xs text-base-content/40">-</span>;
+const EmptyCell = () => (
+ <span className="text-xs text-muted-foreground">-</span>
+);
function buildPagesColumns({
canonicalHost,
@@ -98,7 +98,7 @@ function buildPagesColumns({
href={url}
target="_blank"
rel="noopener noreferrer"
- className="link link-primary inline-flex items-center gap-1 text-xs"
+ className="inline-flex items-center gap-1 text-xs text-primary hover:underline"
>
<span className="truncate">{displayPath(url, canonicalHost)}</span>
<ExternalLink className="size-3 shrink-0" />
@@ -118,7 +118,7 @@ function buildPagesColumns({
if (isRedirect(row.original)) {
const target = row.original.redirectUrl;
return (
- <span className="text-xs text-base-content/60">
+ <span className="text-xs text-muted-foreground">
→ {target ? displayPath(target, canonicalHost) : "redirect"}
</span>
);
@@ -130,7 +130,7 @@ function buildPagesColumns({
// Red only when the engine flagged it — a 200 that isn't an HTML
// document (robots.txt, security.txt) legitimately has no title.
return missingTitlePageIds.has(row.original.id) ? (
- <span className="text-error text-xs">missing</span>
+ <span className="text-destructive text-xs">missing</span>
) : (
<EmptyCell />
);
@@ -223,28 +223,33 @@ export function PagesTable({
withSorting: true,
});
+ const resetFilters = () => setFilters(EMPTY_PAGES_FILTERS);
+
return (
- <div className="space-y-3">
- <TableFilterToggle
- showFilters={showFilters}
- onToggle={() => setShowFilters((current) => !current)}
- activeFilterCount={activeFilterCount}
- resultCount={filteredPages.length}
- totalCount={pages.length}
- />
- {showFilters ? (
- <PagesFilterBar
- filters={filters}
- onChange={setFilters}
- activeFilterCount={activeFilterCount}
- onReset={() => setFilters(EMPTY_PAGES_FILTERS)}
- />
- ) : null}
- <AppDataTable
- table={table}
- className="table table-sm"
- empty={<EmptyTableMessage label="No pages match these filters." />}
- />
- </div>
+ <DataTable
+ table={table}
+ empty={{ title: "No pages crawled" }}
+ isFiltered={activeFilterCount > 0}
+ onClearFilters={resetFilters}
+ toolbar={
+ <>
+ <ResultsTableToolbar
+ showFilters={showFilters}
+ onToggle={() => setShowFilters((current) => !current)}
+ activeFilterCount={activeFilterCount}
+ resultCount={filteredPages.length}
+ totalCount={pages.length}
+ />
+ {showFilters ? (
+ <PagesFilterBar
+ filters={filters}
+ onChange={setFilters}
+ activeFilterCount={activeFilterCount}
+ onReset={resetFilters}
+ />
+ ) : null}
+ </>
+ }
+ />
);
}
diff --git a/src/client/features/audit/results/ResultsTables.tsx b/src/client/features/audit/results/ResultsTables.tsx
index 8724db80..f2203569 100644
--- a/src/client/features/audit/results/ResultsTables.tsx
+++ b/src/client/features/audit/results/ResultsTables.tsx
@@ -5,9 +5,9 @@ import {
type SortingState,
} from "@tanstack/react-table";
import { Link } from "@tanstack/react-router";
-import { AppDataTable } from "@/client/components/table/AppDataTable";
-import { useDataTable } from "@/client/components/table/DataTable";
-import { TableExportMenu } from "@/client/components/table/TableBulkActionBar";
+import { Badge } from "@/client/components/ui/badge";
+import { Button } from "@/client/components/ui/button";
+import { DataTable, useDataTable } from "@/client/components/table/DataTable";
import { SortableHeader } from "@/client/components/table/SortableHeader";
import {
extractPathname,
@@ -16,9 +16,8 @@ import {
import type { AuditResultsData } from "@/client/features/audit/results/types";
import {
countActiveFilters,
- EmptyTableMessage,
PerformanceFilterBar,
- TableFilterToggle,
+ ResultsTableToolbar,
} from "@/client/features/audit/results/AuditResultsTableFilters";
import {
EMPTY_PERFORMANCE_FILTERS,
@@ -83,31 +82,34 @@ export function PerformanceTable({
withSorting: true,
});
+ const resetFilters = () => setFilters(EMPTY_PERFORMANCE_FILTERS);
+
return (
- <div className="space-y-3">
- <TableFilterToggle
- showFilters={showFilters}
- onToggle={() => setShowFilters((current) => !current)}
- activeFilterCount={activeFilterCount}
- resultCount={filteredRows.length}
- totalCount={rows.length}
- />
- {showFilters ? (
- <PerformanceFilterBar
- filters={filters}
- onChange={setFilters}
- activeFilterCount={activeFilterCount}
- onReset={() => setFilters(EMPTY_PERFORMANCE_FILTERS)}
- />
- ) : null}
- <AppDataTable
- table={table}
- className="table table-sm"
- empty={
- <EmptyTableMessage label="No performance results match these filters." />
- }
- />
- </div>
+ <DataTable
+ table={table}
+ empty={{ title: "No Lighthouse results" }}
+ isFiltered={activeFilterCount > 0}
+ onClearFilters={resetFilters}
+ toolbar={
+ <>
+ <ResultsTableToolbar
+ showFilters={showFilters}
+ onToggle={() => setShowFilters((current) => !current)}
+ activeFilterCount={activeFilterCount}
+ resultCount={filteredRows.length}
+ totalCount={rows.length}
+ />
+ {showFilters ? (
+ <PerformanceFilterBar
+ filters={filters}
+ onChange={setFilters}
+ activeFilterCount={activeFilterCount}
+ onReset={resetFilters}
+ />
+ ) : null}
+ </>
+ }
+ />
);
}
@@ -141,14 +143,11 @@ function buildPerformanceColumns({
const failureMessage =
row.original.errorMessage ?? "Lighthouse returned no category scores";
return isFailed ? (
- <span
- className="badge badge-error badge-outline text-xs"
- title={failureMessage}
- >
+ <Badge variant="destructive" title={failureMessage}>
failed
- </span>
+ </Badge>
) : (
- <span className="badge badge-success badge-outline text-xs">ok</span>
+ <Badge variant="success">ok</Badge>
);
},
enableSorting: true,
@@ -178,7 +177,7 @@ function buildPerformanceColumns({
return value ? (
<span className="text-xs">{(value / 1000).toFixed(1)}s</span>
) : (
- <span className="text-xs text-base-content/40">-</span>
+ <span className="text-xs text-muted-foreground">-</span>
);
},
sortingFn: nullableNumberSort,
@@ -190,7 +189,7 @@ function buildPerformanceColumns({
return value != null ? (
<span className="text-xs">{value.toFixed(3)}</span>
) : (
- <span className="text-xs text-base-content/40">-</span>
+ <span className="text-xs text-muted-foreground">-</span>
);
},
sortingFn: nullableNumberSort,
@@ -202,7 +201,7 @@ function buildPerformanceColumns({
return value ? (
<span className="text-xs">{Math.round(value)}ms</span>
) : (
- <span className="text-xs text-base-content/40">-</span>
+ <span className="text-xs text-muted-foreground">-</span>
);
},
sortingFn: nullableNumberSort,
@@ -214,7 +213,7 @@ function buildPerformanceColumns({
return value ? (
<span className="text-xs">{Math.round(value)}ms</span>
) : (
- <span className="text-xs text-base-content/40">-</span>
+ <span className="text-xs text-muted-foreground">-</span>
);
},
sortingFn: nullableNumberSort,
@@ -224,35 +223,22 @@ function buildPerformanceColumns({
header: () => "Issues",
cell: ({ row }) =>
row.original.r2Key && !isLighthouseFailure(row.original) ? (
- <Link
- className="btn btn-primary btn-xs"
- to="/p/$projectId/audit/issues/$resultId"
- params={{ projectId, resultId: row.original.id }}
- search={{ auditId, category: "performance" }}
+ <Button
+ size="xs"
+ nativeButton={false}
+ render={
+ <Link
+ to="/p/$projectId/audit/issues/$resultId"
+ params={{ projectId, resultId: row.original.id }}
+ search={{ auditId, category: "performance" }}
+ />
+ }
>
View issues
- </Link>
+ </Button>
) : (
- <span className="text-xs text-base-content/40">-</span>
+ <span className="text-xs text-muted-foreground">-</span>
),
}),
];
}
-
-export function ExportDropdown({
- onExport,
-}: {
- onExport: (format: "csv" | "json" | "sheets") => void;
-}) {
- return (
- <TableExportMenu
- buttonClassName="btn btn-sm btn-ghost gap-1"
- menuClassName="dropdown-content z-10 menu p-2 shadow-lg bg-base-100 border border-base-300 rounded-box w-52"
- actions={[
- { label: "Export to Sheets", onClick: () => onExport("sheets") },
- { label: "CSV", onClick: () => onExport("csv") },
- { label: "JSON", onClick: () => onExport("json") },
- ]}
- />
- );
-}
diff --git a/src/client/features/audit/results/ResultsView.tsx b/src/client/features/audit/results/ResultsView.tsx
index 70b56bfd..9d5f16ac 100644
--- a/src/client/features/audit/results/ResultsView.tsx
+++ b/src/client/features/audit/results/ResultsView.tsx
@@ -13,10 +13,20 @@ import {
} from "@/client/features/audit/results/IssuesView";
import { PagesTable } from "@/client/features/audit/results/PagesTable";
import { ShopifyCrawlWarning } from "@/client/features/audit/results/ShopifyCrawlWarning";
+import { PerformanceTable } from "@/client/features/audit/results/ResultsTables";
import {
- ExportDropdown,
- PerformanceTable,
-} from "@/client/features/audit/results/ResultsTables";
+ BotProtectionAdvice,
+ SCORE_TEXT_CLASS,
+ scoreTone,
+ SeverityBadge,
+} from "@/client/features/audit/shared";
+import { ExportMenu } from "@/client/components/ExportMenu";
+import {
+ Alert,
+ AlertDescription,
+ AlertTitle,
+} from "@/client/components/ui/alert";
+import { Tabs, TabsList, TabsTrigger } from "@/client/components/ui/tabs";
type ResultsTab = "issues" | "pages" | "performance";
@@ -61,47 +71,35 @@ export function ResultsView({
)}
{!shopifyLimited && blockedCount > 0 && (
- <CrawlWarning
- headline={`We were blocked on ${blockedCount} ${blockedCount === 1 ? "page" : "pages"}.`}
- >
- The site's bot protection challenged our crawler, so those pages
- couldn't be audited. We don't have a workaround for this yet. Desktop
- crawlers run from your own machine and usually get past it: try{" "}
- <a
- className="link link-primary"
- href="https://github.com/PhialsBasement/LibreCrawl"
- target="_blank"
- rel="noreferrer"
- >
- LibreCrawl
- </a>{" "}
- (free, open source) or{" "}
- <a
- className="link link-primary"
- href="https://www.screamingfrog.co.uk/seo-spider/"
- target="_blank"
- rel="noreferrer"
- >
- Screaming Frog
- </a>{" "}
- (free up to 500 URLs).
- </CrawlWarning>
+ <Alert variant="warning">
+ <ShieldAlert />
+ <AlertTitle>
+ We were blocked on {blockedCount}{" "}
+ {blockedCount === 1 ? "page" : "pages"}.
+ </AlertTitle>
+ <AlertDescription>
+ The site's bot protection challenged our crawler, so those pages
+ couldn't be audited. <BotProtectionAdvice />
+ </AlertDescription>
+ </Alert>
)}
{!shopifyLimited && (rateLimitedCount > 0 || crawlStopped) && (
- <CrawlWarning
- headline={
- crawlStopped
+ <Alert variant="warning">
+ <ShieldAlert />
+ <AlertTitle>
+ {crawlStopped
? "The crawl stopped early because of the site’s rate limit."
- : `The site rate limited us on ${rateLimitedCount} ${rateLimitedCount === 1 ? "page" : "pages"}.`
- }
- >
- {crawlStopped
- ? "The requested cooldown exceeded the audit time limit, so some URLs were left unvisited. This report is incomplete. "
- : "Pages that returned 429 Too Many Requests could not be audited. "}
- Re-run the audit after the rate limit resets, or ask the site owner to
- allow the "OpenSEO-Audit" crawler.
- </CrawlWarning>
+ : `The site rate limited us on ${rateLimitedCount} ${rateLimitedCount === 1 ? "page" : "pages"}.`}
+ </AlertTitle>
+ <AlertDescription>
+ {crawlStopped
+ ? "The requested cooldown exceeded the audit time limit, so some URLs were left unvisited. This report is incomplete. "
+ : "Pages that returned 429 Too Many Requests could not be audited. "}
+ Re-run the audit after the rate limit resets, or ask the site owner
+ to allow the "OpenSEO-Audit" crawler.
+ </AlertDescription>
+ </Alert>
)}
<StatsStrip
@@ -112,69 +110,44 @@ export function ResultsView({
lighthouseSummary={stats.lighthouseSummary}
/>
- <div className="card bg-base-100 border border-base-300">
- <div className="card-body gap-3">
- <ResultsHeader
- issueCount={issues.length}
- pageCount={pages.length}
- lighthouseCount={lighthouse.length}
- hasPerformanceTab={hasPerformanceTab}
- activeTab={activeTab}
- onTabChange={onTabChange}
- onExport={(format) => {
- if (activeTab === "performance") {
- exportPerformance(lighthouse, pages, format);
- return;
- }
- if (activeTab === "issues") {
- exportIssues(issues, format);
- return;
- }
- exportPages(pages, format);
- }}
- />
+ <div className="space-y-3">
+ <ResultsHeader
+ issueCount={issues.length}
+ pageCount={pages.length}
+ lighthouseCount={lighthouse.length}
+ hasPerformanceTab={hasPerformanceTab}
+ activeTab={activeTab}
+ onTabChange={onTabChange}
+ onExport={(format) => {
+ if (activeTab === "performance") {
+ exportPerformance(lighthouse, pages, format);
+ return;
+ }
+ if (activeTab === "issues") {
+ exportIssues(issues, format);
+ return;
+ }
+ exportPages(pages, format);
+ }}
+ />
- {activeTab === "issues" && <IssuesView issues={issues} />}
- {activeTab === "pages" && (
- <PagesTable
- pages={pages}
- startUrl={audit.startUrl}
- issues={issues}
- />
- )}
- {activeTab === "performance" && lighthouse.length > 0 && (
- <PerformanceTable
- auditId={audit.id}
- projectId={projectId}
- lighthouse={lighthouse}
- pages={pages}
- />
- )}
- </div>
+ {activeTab === "issues" && <IssuesView issues={issues} />}
+ {activeTab === "pages" && (
+ <PagesTable pages={pages} startUrl={audit.startUrl} issues={issues} />
+ )}
+ {activeTab === "performance" && lighthouse.length > 0 && (
+ <PerformanceTable
+ auditId={audit.id}
+ projectId={projectId}
+ lighthouse={lighthouse}
+ pages={pages}
+ />
+ )}
</div>
</>
);
}
-/** Banner for pages the crawler could not read (bot protection, rate limits). */
-function CrawlWarning({
- headline,
- children,
-}: {
- headline: string;
- children: ReactNode;
-}) {
- return (
- <div className="flex items-start gap-3 rounded-lg border border-warning/30 bg-warning/5 px-4 py-3 text-sm">
- <ShieldAlert className="mt-0.5 size-4 shrink-0 text-warning" />
- <p>
- <span className="font-medium">{headline}</span>{" "}
- <span className="text-base-content/70">{children}</span>
- </p>
- </div>
- );
-}
-
function useResultStats(
pages: AuditResultsData["pages"],
lighthouse: AuditResultsData["lighthouse"],
@@ -250,27 +223,21 @@ function ResultsHeader({
];
return (
- <div className="flex flex-col lg:flex-row lg:items-center justify-between gap-3">
- <div role="tablist" className="tabs tabs-border w-fit">
- {tabs.map(({ label, tab }) => {
- const isActive = activeTab === tab;
-
- return (
- <button
- key={tab}
- type="button"
- role="tab"
- aria-selected={isActive}
- className={`tab ${isActive ? "tab-active" : ""}`}
- onClick={() => onTabChange(tab)}
- >
+ <div className="flex flex-wrap items-center justify-between gap-3">
+ <Tabs
+ value={activeTab}
+ onValueChange={(value: ResultsTab) => onTabChange(value)}
+ >
+ <TabsList variant="line">
+ {tabs.map(({ label, tab }) => (
+ <TabsTrigger key={tab} value={tab}>
{label}
- </button>
- );
- })}
- </div>
+ </TabsTrigger>
+ ))}
+ </TabsList>
+ </Tabs>
- <ExportDropdown onExport={onExport} />
+ <ExportMenu actions={["sheets", "csv", "json"]} onExport={onExport} />
</div>
);
}
@@ -315,13 +282,18 @@ function StatsStrip({
value: String(issues.length),
valueClass: issues.length === 0 ? "text-success" : "",
sub: issues.length > 0 && (
- <span className="flex items-center gap-2.5">
- <SeverityCount count={severityCounts.critical} dotClass="bg-error" />
- <SeverityCount count={severityCounts.warning} dotClass="bg-warning" />
- <SeverityCount
- count={severityCounts.info}
- dotClass="bg-base-content/30"
- />
+ <span className="flex flex-wrap items-center gap-1">
+ {(["critical", "warning", "info"] as const).map((severity) =>
+ severityCounts[severity] > 0 ? (
+ <SeverityBadge
+ key={severity}
+ severity={severity}
+ title={severity}
+ >
+ {severityCounts[severity]}
+ </SeverityBadge>
+ ) : null,
+ )}
</span>
),
},
@@ -359,7 +331,7 @@ function StatsStrip({
label: "Lighthouse failures",
value: String(lighthouseSummary.failed),
valueClass:
- lighthouseSummary.failed > 0 ? "text-error" : "text-success",
+ lighthouseSummary.failed > 0 ? "text-destructive" : "text-success",
},
);
}
@@ -371,11 +343,11 @@ function StatsStrip({
return (
<div
- className={`grid ${columnsClass} gap-px rounded-lg border border-base-300 bg-base-300/70 overflow-hidden`}
+ className={`grid ${columnsClass} gap-px rounded-lg border border-border bg-border overflow-hidden`}
>
{items.map((item) => (
- <div key={item.label} className="bg-base-100 px-4 py-3">
- <p className="text-[11px] uppercase tracking-wider text-base-content/50">
+ <div key={item.label} className="bg-card px-4 py-3">
+ <p className="text-[11px] uppercase tracking-wider text-muted-foreground">
{item.label}
</p>
<p
@@ -384,7 +356,7 @@ function StatsStrip({
{item.value}
</p>
{item.sub && (
- <div className="text-xs text-base-content/60 mt-1">{item.sub}</div>
+ <div className="text-xs text-muted-foreground mt-1">{item.sub}</div>
)}
</div>
))}
@@ -392,25 +364,7 @@ function StatsStrip({
);
}
-function SeverityCount({
- count,
- dotClass,
-}: {
- count: number;
- dotClass: string;
-}) {
- if (count === 0) return null;
- return (
- <span className="flex items-center gap-1 tabular-nums">
- <span className={`size-1.5 rounded-full ${dotClass}`} />
- {count}
- </span>
- );
-}
-
function scoreClass(score: number | null) {
- if (score == null) return "";
- if (score >= 90) return "text-success";
- if (score >= 50) return "text-warning";
- return "text-error";
+ const tone = scoreTone(score);
+ return tone ? SCORE_TEXT_CLASS[tone] : "";
}
diff --git a/src/client/features/audit/results/ShopifyCrawlWarning.tsx b/src/client/features/audit/results/ShopifyCrawlWarning.tsx
index 6cb3a60d..45ea74d2 100644
--- a/src/client/features/audit/results/ShopifyCrawlWarning.tsx
+++ b/src/client/features/audit/results/ShopifyCrawlWarning.tsx
@@ -6,6 +6,12 @@ import {
crawlerCredentialsQueryKey,
saveCrawlerCredentialMutationKey,
} from "@/client/features/crawler-access/CrawlerAccessForm";
+import {
+ Alert,
+ AlertDescription,
+ AlertTitle,
+} from "@/client/components/ui/alert";
+import { Button } from "@/client/components/ui/button";
import type { AuditResultsData } from "@/client/features/audit/results/types";
import { extractHostname } from "@/client/features/audit/shared";
import { startAudit } from "@/serverFunctions/audit";
@@ -82,14 +88,15 @@ export function ShopifyCrawlWarning({
});
const rerunButton = (
- <button
- type="button"
- className="btn btn-ghost btn-sm"
- disabled={rerunMutation.isPending || isSaving}
+ <Button
+ variant="outline"
+ size="sm"
+ pending={rerunMutation.isPending}
+ disabled={isSaving}
onClick={() => rerunMutation.mutate()}
>
{rerunMutation.isPending ? "Starting…" : "Re-run audit"}
- </button>
+ </Button>
);
// Until the list loads we can't tell which state applies; don't flash the
@@ -99,13 +106,9 @@ export function ShopifyCrawlWarning({
if (liveCredential) {
const signedAndStillLimited = liveCredential.id === usedCredentialId;
return (
- <div className="flex flex-wrap items-center gap-3 rounded-lg border border-base-300 px-4 py-3 text-sm">
- {signedAndStillLimited ? (
- <ShieldAlert className="size-4 shrink-0 text-warning" />
- ) : (
- <ShieldCheck className="size-4 shrink-0 text-success" />
- )}
- <p className="min-w-0 flex-1">
+ <Alert variant={signedAndStillLimited ? "warning" : "success"}>
+ {signedAndStillLimited ? <ShieldAlert /> : <ShieldCheck />}
+ <AlertDescription className="text-foreground">
{signedAndStillLimited ? (
<>
Shopify limited this crawl despite your signature. It may have
@@ -114,7 +117,6 @@ export function ShopifyCrawlWarning({
<Link
to="/p/$projectId/settings/integrations"
params={{ projectId }}
- className="link link-primary"
>
Project settings
</Link>
@@ -127,74 +129,72 @@ export function ShopifyCrawlWarning({
crawl with it.
</>
)}
- </p>
- {rerunButton}
- </div>
+ </AlertDescription>
+ <div className="col-start-2 mt-2">{rerunButton}</div>
+ </Alert>
);
}
return (
- <div className="rounded-lg border border-warning/30 bg-warning/5 px-4 py-4 text-sm">
- <div className="flex items-start gap-3">
- <ShieldAlert className="mt-0.5 size-4 shrink-0 text-warning" />
- <div className="min-w-0 space-y-3">
- {expiredCredential?.expiresAt ? (
- <>
- <p className="font-medium">
- Your Shopify signature for this store has expired.
- </p>
- <p className="text-base-content/70">
- It ran out on{" "}
- {new Date(expiredCredential.expiresAt).toLocaleDateString()}, so
- requests after that went out unsigned and Shopify limited them.
- Signatures can't be renewed: create a fresh one in Shopify admin
- and paste it below to replace the stored values.
- </p>
- </>
- ) : (
- <>
- <p className="font-medium">Shopify limited this crawl.</p>
- <p className="text-base-content/70">
- Shopify rate-limits crawlers it hasn't authorized, so parts of
- this report are missing. If you own this store, authorizing
- OpenSEO takes about a minute.
- </p>
- </>
- )}
+ <Alert variant="warning">
+ <ShieldAlert />
+ <div className="min-w-0 space-y-3">
+ {expiredCredential?.expiresAt ? (
+ <>
+ <AlertTitle>
+ Your Shopify signature for this store has expired.
+ </AlertTitle>
+ <p className="text-muted-foreground">
+ It ran out on{" "}
+ {new Date(expiredCredential.expiresAt).toLocaleDateString()}, so
+ requests after that went out unsigned and Shopify limited them.
+ Signatures can't be renewed: create a fresh one in Shopify admin
+ and paste it below to replace the stored values.
+ </p>
+ </>
+ ) : (
+ <>
+ <AlertTitle>Shopify limited this crawl.</AlertTitle>
+ <p className="text-muted-foreground">
+ Shopify rate-limits crawlers it hasn't authorized, so parts of
+ this report are missing. If you own this store, authorizing
+ OpenSEO takes about a minute.
+ </p>
+ </>
+ )}
- <ol className="list-decimal space-y-1 pl-5 text-base-content/70">
- <li>
- In Shopify admin, go to Online Store &rarr; Preferences &rarr;
- Crawler access and click Create signature.
- </li>
- <li>
- Pick the domain <span className="font-mono">{host}</span> and an
- expiry (up to 3 months).
- </li>
- <li>Paste the two values below.</li>
- </ol>
+ <ol className="list-decimal space-y-1 pl-5 text-muted-foreground">
+ <li>
+ In Shopify admin, go to Online Store &rarr; Preferences &rarr;
+ Crawler access and click Create signature.
+ </li>
+ <li>
+ Pick the domain <span className="font-mono">{host}</span> and an
+ expiry (up to 3 months).
+ </li>
+ <li>Paste the two values below.</li>
+ </ol>
- {/* Keyed by host: the report stays mounted when the audit changes. */}
- <CrawlerAccessForm
- key={host}
- projectId={projectId}
- initialHost={host}
- lockHost
- />
+ {/* Keyed by host: the report stays mounted when the audit changes. */}
+ <CrawlerAccessForm
+ key={host}
+ projectId={projectId}
+ initialHost={host}
+ lockHost
+ />
- <div className="flex flex-wrap items-center gap-4">
- {rerunButton}
- <a
- className="link link-primary"
- href={SHOPIFY_CRAWLER_ACCESS_DOC_URL}
- target="_blank"
- rel="noreferrer"
- >
- Shopify's crawler access guide
- </a>
- </div>
+ <div className="flex flex-wrap items-center gap-4">
+ {rerunButton}
+ <a
+ className="text-primary underline underline-offset-3"
+ href={SHOPIFY_CRAWLER_ACCESS_DOC_URL}
+ target="_blank"
+ rel="noreferrer"
+ >
+ Shopify's crawler access guide
+ </a>
</div>
</div>
- </div>
+ </Alert>
);
}
diff --git a/src/client/features/audit/shared.tsx b/src/client/features/audit/shared.tsx
index ffa1c89f..2a93a055 100644
--- a/src/client/features/audit/shared.tsx
+++ b/src/client/features/audit/shared.tsx
@@ -1,4 +1,16 @@
-import { AlertCircle, CheckCircle, Loader2 } from "lucide-react";
+import type { ReactNode } from "react";
+import {
+ AlertCircle,
+ CheckCircle,
+ FileWarning,
+ Info,
+ TriangleAlert,
+ type LucideIcon,
+} from "lucide-react";
+import { cn } from "cn";
+import { Badge } from "@/client/components/ui/badge";
+import { Spinner } from "@/client/components/ui/spinner";
+import type { IssueSeverity } from "@/shared/audit-issues";
export function extractPathname(url: string): string {
try {
@@ -36,43 +48,116 @@ export function formatStartedAt(dateStr: string): string {
export function StatusBadge({ status }: { status: string }) {
if (status === "running") {
return (
- <span className="badge badge-info badge-sm gap-1">
- <Loader2 className="size-3 animate-spin" /> Running
- </span>
+ <Badge variant="info">
+ <Spinner /> Running
+ </Badge>
);
}
if (status === "completed") {
return (
- <span className="badge badge-outline badge-sm gap-1 text-success/80 border-success/30 bg-success/5">
- <CheckCircle className="size-3" /> Done
- </span>
+ <Badge variant="success">
+ <CheckCircle /> Done
+ </Badge>
);
}
return (
- <span className="badge badge-error badge-sm gap-1">
- <AlertCircle className="size-3" /> Failed
- </span>
+ <Badge variant="destructive">
+ <AlertCircle /> Failed
+ </Badge>
);
}
export function HttpStatusBadge({ code }: { code: number | null }) {
- if (!code) return <span className="badge badge-ghost badge-sm">-</span>;
- if (code >= 200 && code < 300) {
- return <span className="badge badge-success badge-sm">{code}</span>;
- }
- if (code >= 300 && code < 400) {
- return <span className="badge badge-warning badge-sm">{code}</span>;
- }
- return <span className="badge badge-error badge-sm">{code}</span>;
+ if (!code) return <Badge variant="outline">-</Badge>;
+ const variant =
+ code >= 200 && code < 300
+ ? "success"
+ : code >= 300 && code < 400
+ ? "warning"
+ : "destructive";
+ return <Badge variant={variant}>{code}</Badge>;
+}
+
+type ScoreTone = "success" | "warning" | "destructive";
+
+/** Lighthouse score bands: 90 and up is good, 50 to 89 needs work, below 50 is poor. */
+export function scoreTone(score: number | null): ScoreTone | null {
+ if (score == null) return null;
+ if (score >= 90) return "success";
+ if (score >= 50) return "warning";
+ return "destructive";
}
+export const SCORE_TEXT_CLASS: Record<ScoreTone, string> = {
+ success: "text-success",
+ warning: "text-warning",
+ destructive: "text-destructive",
+};
+
export function LighthouseScoreBadge({ score }: { score: number | null }) {
- if (score == null) {
- return <span className="text-xs text-base-content/40">-</span>;
+ const tone = scoreTone(score);
+ if (tone == null) {
+ return <span className="text-xs text-muted-foreground">-</span>;
}
- const color =
- score >= 90 ? "text-success" : score >= 50 ? "text-warning" : "text-error";
- return <span className={`font-medium text-sm ${color}`}>{score}</span>;
+ return (
+ <span className={cn("text-sm font-medium", SCORE_TEXT_CLASS[tone])}>
+ {score}
+ </span>
+ );
+}
+
+const SEVERITY_BADGE: Record<
+ IssueSeverity,
+ { variant: "destructive" | "warning" | "info"; icon: LucideIcon }
+> = {
+ critical: { variant: "destructive", icon: FileWarning },
+ warning: { variant: "warning", icon: TriangleAlert },
+ info: { variant: "info", icon: Info },
+};
+
+/** The one way audit and Lighthouse pages show an issue severity. */
+export function SeverityBadge({
+ severity,
+ children,
+ title,
+}: {
+ severity: IssueSeverity;
+ children: ReactNode;
+ title?: string;
+}) {
+ const { variant, icon: Icon } = SEVERITY_BADGE[severity];
+ return (
+ <Badge variant={variant} title={title}>
+ <Icon />
+ {children}
+ </Badge>
+ );
+}
+
+/** Advice for a site whose bot protection blocked the crawler. */
+export function BotProtectionAdvice() {
+ return (
+ <>
+ We don't have a workaround for this yet. Desktop crawlers run from your
+ own machine and usually get past it: try{" "}
+ <a
+ href="https://github.com/PhialsBasement/LibreCrawl"
+ target="_blank"
+ rel="noreferrer"
+ >
+ LibreCrawl
+ </a>{" "}
+ (free, open source) or{" "}
+ <a
+ href="https://www.screamingfrog.co.uk/seo-spider/"
+ target="_blank"
+ rel="noreferrer"
+ >
+ Screaming Frog
+ </a>{" "}
+ (free up to 500 URLs).
+ </>
+ );
}
diff --git a/src/client/features/lighthouse/issues/LighthouseIssueRow.tsx b/src/client/features/lighthouse/issues/LighthouseIssueRow.tsx
index f7b093a7..c39dda95 100644
--- a/src/client/features/lighthouse/issues/LighthouseIssueRow.tsx
+++ b/src/client/features/lighthouse/issues/LighthouseIssueRow.tsx
@@ -1,11 +1,7 @@
import { useState, type ReactNode } from "react";
-import {
- ChevronRight,
- ExternalLink,
- FileWarning,
- Info,
- TriangleAlert,
-} from "lucide-react";
+import { ChevronRight, ExternalLink } from "lucide-react";
+import { TableCell, TableRow } from "@/client/components/ui/table";
+import { SeverityBadge } from "@/client/features/audit/shared";
import type { LighthouseIssue } from "./types";
export function LighthouseIssueRow({ issue }: { issue: LighthouseIssue }) {
@@ -14,74 +10,76 @@ export function LighthouseIssueRow({ issue }: { issue: LighthouseIssue }) {
return (
<>
- <tr
- className={`hover:bg-base-200/50 transition-colors ${hasDetails ? "cursor-pointer" : ""}`}
+ <TableRow
+ className={hasDetails ? "cursor-pointer" : undefined}
onClick={() => hasDetails && setOpen(!open)}
>
- <td className="py-3 pl-4 pr-2">
+ <TableCell className="py-3">
{hasDetails ? (
<ChevronRight
- className={`size-3.5 text-base-content/40 transition-transform ${open ? "rotate-90" : ""}`}
+ className={`size-3.5 text-muted-foreground transition-transform ${open ? "rotate-90" : ""}`}
/>
) : null}
- </td>
- <td className="py-3 pr-3">
- <span
- className={`badge badge-sm border ${severityBadgeClass(issue.severity)} gap-1`}
- >
- {severityIcon(issue.severity)}
+ </TableCell>
+ <TableCell className="py-3">
+ <SeverityBadge severity={issue.severity}>
{issue.severity}
- </span>
- </td>
- <td className="py-3 pr-3">
+ </SeverityBadge>
+ </TableCell>
+ <TableCell className="py-3">
<div>
<p className="font-medium text-sm leading-snug">{issue.title}</p>
{issue.displayValue ? (
- <p className="text-xs text-base-content/50 mt-0.5">
+ <p className="text-xs text-muted-foreground mt-0.5">
{issue.displayValue}
</p>
) : null}
</div>
- </td>
- <td className="py-3 pr-3 hidden sm:table-cell">
- <span className="text-xs text-base-content/50">{issue.category}</span>
- </td>
- <td className="py-3 pr-3 hidden md:table-cell text-right">
+ </TableCell>
+ <TableCell className="py-3 hidden sm:table-cell">
+ <span className="text-xs text-muted-foreground">
+ {issue.category}
+ </span>
+ </TableCell>
+ <TableCell className="py-3 hidden md:table-cell text-right">
{issue.impactMs != null || issue.impactBytes != null ? (
- <span className="text-xs tabular-nums text-base-content/50">
+ <span className="text-xs tabular-nums text-muted-foreground">
{issue.impactMs ? formatMs(issue.impactMs) : null}
{issue.impactMs && issue.impactBytes ? " / " : null}
{issue.impactBytes ? formatBytes(issue.impactBytes) : null}
</span>
) : null}
- </td>
- <td className="py-3 pr-4 text-right">
+ </TableCell>
+ <TableCell className="py-3 text-right">
{issue.score != null ? (
- <span className="text-xs tabular-nums text-base-content/50">
+ <span className="text-xs tabular-nums text-muted-foreground">
{issue.score}
</span>
) : null}
- </td>
- </tr>
+ </TableCell>
+ </TableRow>
{open ? (
- <tr className="!bg-transparent">
- <td colSpan={6} className="pb-4 pt-2 pl-[8.5rem] pr-4">
+ <TableRow className="hover:bg-transparent">
+ <TableCell
+ colSpan={6}
+ className="pb-4 pt-2 pl-10 pr-4 sm:pl-[8.5rem]"
+ >
<div className="space-y-3">
{issue.description ? (
- <div className="text-sm text-base-content/70 leading-relaxed">
+ <div className="text-sm text-muted-foreground leading-relaxed">
{renderInlineMarkdown(issue.description)}
</div>
) : null}
{issue.items.length > 0 ? (
<details className="text-sm">
- <summary className="cursor-pointer font-medium text-base-content/60 text-xs">
+ <summary className="cursor-pointer font-medium text-muted-foreground text-xs">
Affected items ({issue.items.length})
</summary>
<div className="mt-2 space-y-1.5">
{issue.items.map((item, itemIndex) => (
<pre
key={`${issue.auditKey}-${itemIndex}`}
- className="bg-base-200/60 p-2 rounded overflow-x-auto text-xs leading-relaxed"
+ className="bg-muted p-2 rounded overflow-x-auto text-xs leading-relaxed"
>
{item}
</pre>
@@ -90,8 +88,8 @@ export function LighthouseIssueRow({ issue }: { issue: LighthouseIssue }) {
</details>
) : null}
</div>
- </td>
- </tr>
+ </TableCell>
+ </TableRow>
) : null}
</>
);
@@ -129,7 +127,7 @@ function renderInlineMarkdown(markdown: string): ReactNode {
href={href}
target="_blank"
rel="noopener noreferrer"
- className="link link-primary inline-flex items-center gap-1"
+ className="inline-flex items-center gap-1 text-primary hover:underline"
>
{label}
<ExternalLink className="size-3" />
@@ -146,19 +144,3 @@ function renderInlineMarkdown(markdown: string): ReactNode {
return nodes.length ? nodes : markdown;
}
-
-function severityBadgeClass(severity: "critical" | "warning" | "info") {
- if (severity === "critical") {
- return "border-error/30 bg-error/10 text-error/80";
- }
- if (severity === "warning") {
- return "border-warning/35 bg-warning/10 text-warning/80";
- }
- return "border-info/30 bg-info/10 text-info/80";
-}
-
-function severityIcon(severity: "critical" | "warning" | "info") {
- if (severity === "critical") return <FileWarning className="size-3" />;
- if (severity === "warning") return <TriangleAlert className="size-3" />;
- return <Info className="size-3" />;
-}
diff --git a/src/client/features/lighthouse/issues/LighthouseIssuesParts.tsx b/src/client/features/lighthouse/issues/LighthouseIssuesParts.tsx
index ab8528cb..691c9b7a 100644
--- a/src/client/features/lighthouse/issues/LighthouseIssuesParts.tsx
+++ b/src/client/features/lighthouse/issues/LighthouseIssuesParts.tsx
@@ -1,13 +1,17 @@
+import { ChevronLeft } from "lucide-react";
+import { ExportMenu } from "@/client/components/ExportMenu";
+import { Spinner } from "@/client/components/Spinner";
+import { Button } from "@/client/components/ui/button";
+import { Card, CardContent } from "@/client/components/ui/card";
import {
- ChevronDown,
- Copy,
- Download,
- FileWarning,
- Info,
- Sheet,
- TriangleAlert,
-} from "lucide-react";
-import { PortalMenu } from "@/client/components/PortalMenu";
+ Table,
+ TableBody,
+ TableHead,
+ TableHeader,
+ TableRow,
+} from "@/client/components/ui/table";
+import { Tabs, TabsList, TabsTrigger } from "@/client/components/ui/tabs";
+import { SeverityBadge } from "@/client/features/audit/shared";
import type {
CategoryTab,
ExportPayload,
@@ -40,10 +44,11 @@ export function LighthouseIssuesHeader({
return (
<>
<div className="flex items-center justify-between gap-3">
- <button className="btn btn-ghost btn-sm px-2" onClick={onBack}>
- &larr; Back to Site Audit
- </button>
- <span className="text-xs text-base-content/60">
+ <Button variant="ghost" size="sm" className="-ml-2.5" onClick={onBack}>
+ <ChevronLeft data-icon="inline-start" />
+ Back to Site Audit
+ </Button>
+ <span className="text-xs text-muted-foreground">
{scannedAt
? `Scanned ${new Date(scannedAt).toLocaleString()}`
: isLoading
@@ -52,31 +57,28 @@ export function LighthouseIssuesHeader({
</span>
</div>
- <div className="card bg-base-100 border border-base-300">
- <div className="card-body py-5 gap-4">
+ <Card>
+ <CardContent className="space-y-4">
<div className="space-y-1">
<h1 className="text-2xl font-semibold">Lighthouse Issues</h1>
- <p className="text-sm text-base-content/70 break-all">
+ <p className="text-sm text-muted-foreground break-all">
{finalUrl ?? (isLoading ? "Loading URL..." : null)}
</p>
</div>
<LighthouseIssuesSummary scores={scores} metrics={metrics} />
- <div className="flex flex-wrap gap-2 text-xs">
- <span className="badge border border-error/30 bg-error/10 text-error/80 gap-1">
- <FileWarning className="size-3" />
+ <div className="flex flex-wrap gap-2">
+ <SeverityBadge severity="critical">
Critical {severityCounts.critical}
- </span>
- <span className="badge border border-warning/30 bg-warning/10 text-warning/80 gap-1">
- <TriangleAlert className="size-3" />
+ </SeverityBadge>
+ <SeverityBadge severity="warning">
Warning {severityCounts.warning}
- </span>
- <span className="badge border border-info/30 bg-info/10 text-info/80 gap-1">
- <Info className="size-3" />
+ </SeverityBadge>
+ <SeverityBadge severity="info">
Info {severityCounts.info}
- </span>
+ </SeverityBadge>
</div>
- </div>
- </div>
+ </CardContent>
+ </Card>
</>
);
}
@@ -91,8 +93,7 @@ export function LighthouseIssuesToolbar({
onCategoryChange,
onCopy,
onExport,
- onExportCsv,
- onExportSheets,
+ onExportRows,
}: {
category: CategoryTab;
categoryCounts: Record<CategoryTab, number>;
@@ -103,8 +104,8 @@ export function LighthouseIssuesToolbar({
onCategoryChange: (next: CategoryTab) => void;
onCopy: (data: ExportPayload, toastMessage: string) => void;
onExport: (data: ExportPayload) => void;
- onExportCsv: (issues: LighthouseIssue[], variant: "all" | "current") => void;
- onExportSheets: (
+ onExportRows: (
+ format: "csv" | "sheets",
issues: LighthouseIssue[],
variant: "all" | "current",
) => void;
@@ -114,8 +115,42 @@ export function LighthouseIssuesToolbar({
const categoryLabelLower = selectedCategoryLabel.toLowerCase();
+ // One menu section per scope. The saved payload has no issue rows, so it
+ // offers only the JSON formats.
+ const scopes: Array<{
+ id: string;
+ label: string;
+ actions?: Array<"copy-json" | "json">;
+ issues: LighthouseIssue[];
+ payload: ExportPayload;
+ copied: string;
+ }> = [
+ {
+ id: "current",
+ label: `${selectedCategoryLabel} issues`,
+ issues: visibleIssues,
+ payload: exportCurrentCategory,
+ copied: `Copied ${categoryLabelLower} issues`,
+ },
+ {
+ id: "all",
+ label: "All actionable issues",
+ issues: allIssues,
+ payload: { mode: "issues" },
+ copied: "Copied all actionable issues",
+ },
+ {
+ id: "full",
+ label: "Saved Lighthouse payload",
+ actions: ["copy-json", "json"],
+ issues: [],
+ payload: { mode: "full" },
+ copied: "Copied saved Lighthouse payload",
+ },
+ ];
+
return (
- <div className="sticky top-0 z-[2] -mx-2 px-2 py-2 bg-base-100/95 backdrop-blur-sm border-b border-base-300/60">
+ <div className="sticky top-0 z-[2] -mx-2 px-2 py-2 bg-card/95 backdrop-blur-sm border-b border-border">
<div className="flex flex-wrap items-center justify-between gap-3">
<CategoryTabs
category={category}
@@ -123,15 +158,21 @@ export function LighthouseIssuesToolbar({
onCategoryChange={onCategoryChange}
/>
<ExportMenu
- allIssues={allIssues}
- categoryLabelLower={categoryLabelLower}
- exportCurrentCategory={exportCurrentCategory}
- isBusy={isBusy}
- onCopy={onCopy}
- onExport={onExport}
- onExportCsv={onExportCsv}
- onExportSheets={onExportSheets}
- visibleIssues={visibleIssues}
+ actions={["sheets", "csv", "copy-json", "json"]}
+ busy={isBusy}
+ scopes={scopes}
+ onExport={(action, scopeId) => {
+ const scope = scopes.find((item) => item.id === scopeId);
+ if (!scope) return;
+ if (action === "copy-json") onCopy(scope.payload, scope.copied);
+ else if (action === "json") onExport(scope.payload);
+ else
+ onExportRows(
+ action,
+ scope.issues,
+ scopeId === "all" ? "all" : "current",
+ );
+ }}
/>
</div>
</div>
@@ -148,199 +189,21 @@ function CategoryTabs({
onCategoryChange: (next: CategoryTab) => void;
}) {
return (
- <div className="flex flex-wrap items-center gap-4">
- {categoryTabs.map((tab) => (
- <button
- key={tab}
- className={`pb-2 border-b-2 text-sm font-medium transition-colors ${
- category === tab
- ? "border-primary text-base-content"
- : "border-transparent text-base-content/60 hover:text-base-content"
- }`}
- onClick={() => onCategoryChange(tab)}
- >
- <span>{categoryLabel(tab)}</span>
- <span className="ml-1 text-xs opacity-70">
- ({categoryCounts[tab]})
- </span>
- </button>
- ))}
- </div>
- );
-}
-
-function ExportMenu({
- allIssues,
- categoryLabelLower,
- exportCurrentCategory,
- isBusy,
- onCopy,
- onExport,
- onExportCsv,
- onExportSheets,
- visibleIssues,
-}: {
- allIssues: LighthouseIssue[];
- categoryLabelLower: string;
- exportCurrentCategory: ExportPayload;
- isBusy: boolean;
- onCopy: (data: ExportPayload, toastMessage: string) => void;
- onExport: (data: ExportPayload) => void;
- onExportCsv: (issues: LighthouseIssue[], variant: "all" | "current") => void;
- onExportSheets: (
- issues: LighthouseIssue[],
- variant: "all" | "current",
- ) => void;
- visibleIssues: LighthouseIssue[];
-}) {
- return (
- <PortalMenu
- ariaLabel="Export Lighthouse issues"
- triggerClassName="btn btn-sm gap-1"
- triggerContent={
- <>
- <Download className="size-4" />
- Export
- <ChevronDown className="size-3 opacity-60" />
- </>
- }
- menuClassName="w-72 max-h-[min(30rem,70vh)] flex-nowrap overflow-y-auto"
+ <Tabs
+ value={category}
+ onValueChange={(next: CategoryTab) => onCategoryChange(next)}
>
- {(close) => (
- <>
- <li className="menu-title">
- <span>Export to Sheets</span>
- </li>
- <li>
- <button
- disabled={!visibleIssues.length}
- onClick={() => {
- close();
- onExportSheets(visibleIssues, "current");
- }}
- >
- <Sheet className="size-4" />
- Open in Sheets — {categoryLabelLower}
- </button>
- </li>
- <li>
- <button
- disabled={!allIssues.length}
- onClick={() => {
- close();
- onExportSheets(allIssues, "all");
- }}
- >
- <Sheet className="size-4" />
- Open in Sheets — all actionable
- </button>
- </li>
- <li className="menu-title">
- <span>Copy</span>
- </li>
- <li>
- <button
- disabled={isBusy}
- onClick={() => {
- close();
- onCopy(
- exportCurrentCategory,
- `Copied ${categoryLabelLower} issues`,
- );
- }}
- >
- <Copy className="size-4" />
- Copy {categoryLabelLower} issues
- </button>
- </li>
- <li>
- <button
- disabled={isBusy}
- onClick={() => {
- close();
- onCopy({ mode: "issues" }, "Copied all actionable issues");
- }}
- >
- <Copy className="size-4" />
- Copy all actionable issues
- </button>
- </li>
- <li>
- <button
- disabled={isBusy}
- onClick={() => {
- close();
- onCopy({ mode: "full" }, "Copied saved Lighthouse payload");
- }}
- >
- <Copy className="size-4" />
- Copy saved Lighthouse payload
- </button>
- </li>
- <li className="menu-title">
- <span>Download JSON</span>
- </li>
- <li>
- <button
- disabled={isBusy}
- onClick={() => {
- close();
- onExport(exportCurrentCategory);
- }}
- >
- Download {categoryLabelLower} issues
- </button>
- </li>
- <li>
- <button
- disabled={isBusy}
- onClick={() => {
- close();
- onExport({ mode: "issues" });
- }}
- >
- Download all actionable issues
- </button>
- </li>
- <li>
- <button
- disabled={isBusy}
- onClick={() => {
- close();
- onExport({ mode: "full" });
- }}
- >
- Download saved Lighthouse payload
- </button>
- </li>
- <li className="menu-title">
- <span>Download CSV</span>
- </li>
- <li>
- <button
- disabled={!visibleIssues.length}
- onClick={() => {
- close();
- onExportCsv(visibleIssues, "current");
- }}
- >
- Download {categoryLabelLower} issues
- </button>
- </li>
- <li>
- <button
- disabled={!allIssues.length}
- onClick={() => {
- close();
- onExportCsv(allIssues, "all");
- }}
- >
- Download all actionable issues
- </button>
- </li>
- </>
- )}
- </PortalMenu>
+ <TabsList variant="line" className="h-auto! flex-wrap justify-start">
+ {categoryTabs.map((tab) => (
+ <TabsTrigger key={tab} value={tab}>
+ {categoryLabel(tab)}
+ <span className="text-xs text-muted-foreground">
+ ({categoryCounts[tab]})
+ </span>
+ </TabsTrigger>
+ ))}
+ </TabsList>
+ </Tabs>
);
}
@@ -354,45 +217,37 @@ export function LighthouseIssueList({
emptyMessage?: string;
}) {
if (isLoading) {
- return <p className="text-sm text-base-content/60">Loading issues...</p>;
+ return <Spinner label="Loading issues..." />;
}
if (!issues.length) {
return (
- <p className="text-sm text-base-content/60">
+ <p className="text-sm text-muted-foreground">
{emptyMessage ?? "No actionable issues for this category."}
</p>
);
}
return (
- <table className="table table-sm w-full table-fixed">
- <colgroup>
- <col className="w-8" />
- <col className="w-24" />
- <col />
- <col className="w-28 hidden sm:table-column" />
- <col className="w-28 hidden md:table-column" />
- <col className="w-14" />
- </colgroup>
- <thead>
- <tr className="text-xs text-base-content/50 uppercase tracking-wide border-b border-base-300">
- <th />
- <th className="font-medium">Severity</th>
- <th className="font-medium">Issue</th>
- <th className="font-medium hidden sm:table-cell">Category</th>
- <th className="font-medium hidden md:table-cell text-right">
+ <Table>
+ <TableHeader>
+ <TableRow className="hover:bg-transparent">
+ <TableHead className="w-8" />
+ <TableHead className="w-24">Severity</TableHead>
+ <TableHead>Issue</TableHead>
+ <TableHead className="hidden w-28 sm:table-cell">Category</TableHead>
+ <TableHead className="hidden w-28 md:table-cell text-right">
Impact
- </th>
- <th className="font-medium text-right">Score</th>
- </tr>
- </thead>
- <tbody className="divide-y divide-base-300/60">
+ </TableHead>
+ <TableHead className="w-14 text-right">Score</TableHead>
+ </TableRow>
+ </TableHeader>
+ <TableBody>
{issues.map((issue, issueIndex) => (
<LighthouseIssueRow
key={`${issue.category}-${issue.auditKey}-${issueIndex}`}
issue={issue}
/>
))}
- </tbody>
- </table>
+ </TableBody>
+ </Table>
);
}
diff --git a/src/client/features/lighthouse/issues/LighthouseIssuesScreen.tsx b/src/client/features/lighthouse/issues/LighthouseIssuesScreen.tsx
index 6da1dfa6..a040766e 100644
--- a/src/client/features/lighthouse/issues/LighthouseIssuesScreen.tsx
+++ b/src/client/features/lighthouse/issues/LighthouseIssuesScreen.tsx
@@ -1,6 +1,5 @@
import { useMutation, useQuery } from "@tanstack/react-query";
import { useNavigate } from "@tanstack/react-router";
-import { TriangleAlert } from "lucide-react";
import { toast } from "sonner";
import {
exportAuditLighthouseIssues,
@@ -8,6 +7,7 @@ import {
} from "@/serverFunctions/lighthouse";
import { downloadFile } from "@/client/lib/download";
import { QueryError } from "@/client/components/QueryState";
+import { Card, CardContent } from "@/client/components/ui/card";
import { getErrorCode } from "@/client/lib/error-messages";
import { exportRows } from "@/client/lib/exportRows";
import type { CategoryTab, ExportPayload, LighthouseIssue } from "./types";
@@ -74,11 +74,11 @@ export function LighthouseIssuesScreen({
allIssues: issuesQuery.data?.issues ?? [],
});
- const showsLegacyPayloadNotice =
- issuesQuery.data != null && !issuesQuery.data.hasIssueDetails;
- const emptyMessage = showsLegacyPayloadNotice
- ? "This audit was saved without issue-level Lighthouse details. Re-run the audit to populate this screen."
- : undefined;
+ // Runs stored before issue details were kept have no issues to list.
+ const emptyMessage =
+ issuesQuery.data != null && !issuesQuery.data.hasIssueDetails
+ ? "This Lighthouse run was saved without issue details. Re-run the audit to see them."
+ : undefined;
return (
<div className="px-4 py-3 md:px-6 md:py-4 pb-24 md:pb-8 overflow-auto">
@@ -99,8 +99,8 @@ export function LighthouseIssuesScreen({
severityCounts={severityCounts}
/>
- <div className="card bg-base-100 border border-base-300">
- <div className="card-body gap-4">
+ <Card>
+ <CardContent className="space-y-4">
{issuesQuery.isError ? (
<QueryError
error={issuesQuery.error}
@@ -115,17 +115,6 @@ export function LighthouseIssuesScreen({
/>
) : null}
- {showsLegacyPayloadNotice ? (
- <div className="alert alert-warning">
- <TriangleAlert className="size-4" />
- <span>
- This Lighthouse run was stored before issue details were
- preserved. Re-run the audit to see category counts and issue
- cards.
- </span>
- </div>
- ) : null}
-
<LighthouseIssuesToolbar
category={category}
categoryCounts={categoryCounts}
@@ -145,20 +134,15 @@ export function LighthouseIssuesScreen({
onExport={(data) => {
void runExport(data);
}}
- onExportCsv={(rows, variant) =>
- runExportRows("csv", rows, variant)
- }
- onExportSheets={(rows, variant) =>
- runExportRows("sheets", rows, variant)
- }
+ onExportRows={runExportRows}
/>
<LighthouseIssueList
issues={visibleIssues}
isLoading={issuesQuery.isLoading}
emptyMessage={emptyMessage}
/>
- </div>
- </div>
+ </CardContent>
+ </Card>
</div>
</div>
);
diff --git a/src/client/features/lighthouse/issues/LighthouseIssuesSummary.tsx b/src/client/features/lighthouse/issues/LighthouseIssuesSummary.tsx
index 2a742229..a85337e6 100644
--- a/src/client/features/lighthouse/issues/LighthouseIssuesSummary.tsx
+++ b/src/client/features/lighthouse/issues/LighthouseIssuesSummary.tsx
@@ -1,3 +1,5 @@
+import { cn } from "cn";
+import { SCORE_TEXT_CLASS, scoreTone } from "@/client/features/audit/shared";
import type { LighthouseMetrics, LighthouseScores } from "./types";
export function LighthouseIssuesSummary({
@@ -24,16 +26,16 @@ export function LighthouseIssuesSummary({
</div>
) : null}
{metricItems.length > 0 ? (
- <div className="grid grid-cols-2 sm:grid-cols-4 gap-x-4 gap-y-1 rounded-box border border-base-300 bg-base-200/25 px-4 py-3">
+ <div className="grid grid-cols-2 sm:grid-cols-4 gap-x-4 gap-y-1 rounded-lg border border-border bg-muted/30 px-4 py-3">
{metricItems.map((metric) => (
<div
key={metric.label}
className="flex items-baseline justify-between gap-2 py-1"
>
- <span className="text-xs text-base-content/50 uppercase tracking-wide">
+ <span className="text-xs text-muted-foreground uppercase tracking-wide">
{metric.label}
</span>
- <span className="text-sm font-semibold tabular-nums text-base-content">
+ <span className="text-sm font-semibold tabular-nums text-foreground">
{metric.value}
</span>
</div>
@@ -44,22 +46,15 @@ export function LighthouseIssuesSummary({
);
}
-function scoreColor(score: number | null) {
- if (score == null) return "text-base-content/40";
- if (score >= 90) return "text-success";
- if (score >= 50) return "text-warning";
- return "text-error";
-}
-
-function scoreStrokeColor(score: number | null) {
- if (score == null) return "stroke-base-content/20";
- if (score >= 90) return "stroke-success";
- if (score >= 50) return "stroke-warning";
- return "stroke-error";
-}
+const SCORE_STROKE_CLASS = {
+ success: "stroke-success",
+ warning: "stroke-warning",
+ destructive: "stroke-destructive",
+};
function ScoreGauge({ label, score }: { label: string; score: number | null }) {
const displayScore = score ?? 0;
+ const tone = scoreTone(score);
const radius = 28;
const circumference = 2 * Math.PI * radius;
const progress = (displayScore / 100) * circumference;
@@ -74,9 +69,9 @@ function ScoreGauge({ label, score }: { label: string; score: number | null }) {
r={radius}
fill="none"
strokeWidth="4"
- className="stroke-base-300/60"
+ className="stroke-border"
/>
- {score != null ? (
+ {tone != null ? (
<circle
cx="32"
cy="32"
@@ -85,17 +80,20 @@ function ScoreGauge({ label, score }: { label: string; score: number | null }) {
strokeWidth="4"
strokeLinecap="round"
strokeDasharray={`${progress} ${circumference}`}
- className={scoreStrokeColor(score)}
+ className={SCORE_STROKE_CLASS[tone]}
/>
) : null}
</svg>
<span
- className={`absolute inset-0 flex items-center justify-center text-lg font-bold ${scoreColor(score)}`}
+ className={cn(
+ "absolute inset-0 flex items-center justify-center text-lg font-bold",
+ tone ? SCORE_TEXT_CLASS[tone] : "text-muted-foreground",
+ )}
>
{score ?? "-"}
</span>
</div>
- <span className="text-[11px] text-base-content/55 text-center leading-tight">
+ <span className="text-[11px] text-muted-foreground text-center leading-tight">
{label}
</span>
</div>