Skip to content

Open source alternative to Semrush and Ahrefs

Polish the Keyword Research toolbar and SERP analysis (EVE-356) (#772)

Carter Smithcde5c7ab354a
diff --git a/src/client/components/ExportMenu.tsx b/src/client/components/ExportMenu.tsx
index 69a560a3..50f0e5b2 100644
--- a/src/client/components/ExportMenu.tsx
+++ b/src/client/components/ExportMenu.tsx
@@ -72,7 +72,7 @@ export function ExportMenu<A extends ExportAction>({
<DropdownMenuTrigger
render={
<Button
- variant="ghost"
+ variant="outline"
size="sm"
pending={busy}
disabled={disabled}
diff --git a/src/client/components/SerpLocationCombobox.tsx b/src/client/components/SerpLocationCombobox.tsx
index 5eca6657..7dd3fdeb 100644
--- a/src/client/components/SerpLocationCombobox.tsx
+++ b/src/client/components/SerpLocationCombobox.tsx
@@ -116,7 +116,9 @@ export function SerpLocationCombobox({
</InputGroupAddon>
</ComboboxInput>
</div>
- <ComboboxContent anchor={anchor}>
+ {/* Full labels such as "Orange County, California, United States" are
+ wider than a compact field, so the list sizes to its content. */}
+ <ComboboxContent anchor={anchor} className="w-max">
<ComboboxEmpty>{emptyMessage}</ComboboxEmpty>
<ComboboxList>
{(item: LocationItem) => (
diff --git a/src/client/components/table/DataTableToolbar.tsx b/src/client/components/table/DataTableToolbar.tsx
index 26819f93..f0efdab2 100644
--- a/src/client/components/table/DataTableToolbar.tsx
+++ b/src/client/components/table/DataTableToolbar.tsx
@@ -35,7 +35,7 @@ export function DataTableFilterToggle({
onToggle: () => void;
}) {
return (
- <Button variant="ghost" size="sm" aria-expanded={open} onClick={onToggle}>
+ <Button variant="outline" size="sm" aria-expanded={open} onClick={onToggle}>
<SlidersHorizontal data-icon="inline-start" />
Filters
{activeCount > 0 ? (
diff --git a/src/client/components/table/ExportToSheetsButton.tsx b/src/client/components/table/ExportToSheetsButton.tsx
deleted file mode 100644
index 08ec9e8c..00000000
--- a/src/client/components/table/ExportToSheetsButton.tsx
+++ /dev/null
@@ -1,44 +0,0 @@
-import { Sheet } from "lucide-react";
-import { useState } from "react";
-import type { CsvValue } from "@/client/lib/csv";
-import { exportTableToSheets } from "@/client/lib/exportToSheets";
-import { Button } from "@/client/components/ui/button";
-
-type Props = {
- headers: string[];
- /**
- * Full filtered/sorted dataset (not a UI-paginated slice). Emit raw numeric
- * values (not formatted strings) so Sheets parses them as numbers.
- */
- rows: CsvValue[][];
- /** PostHog `source_feature` for the `data:export_sheets` event. */
- feature: string;
-};
-
-export function ExportToSheetsButton({ headers, rows, feature }: Props) {
- const [busy, setBusy] = useState(false);
-
- const handleClick = async () => {
- if (busy) return;
- setBusy(true);
- try {
- await exportTableToSheets({ headers, rows, feature });
- } finally {
- setBusy(false);
- }
- };
-
- return (
- <Button
- variant="ghost"
- size="sm"
- onClick={handleClick}
- disabled={rows.length === 0}
- pending={busy}
- title="Copy table and open a new Google Sheet"
- >
- {busy ? null : <Sheet data-icon="inline-start" />}
- Export to Sheets
- </Button>
- );
-}
diff --git a/src/client/features/keywords/components/SerpAnalysisCard.tsx b/src/client/features/keywords/components/SerpAnalysisCard.tsx
index 00898e86..33ddd249 100644
--- a/src/client/features/keywords/components/SerpAnalysisCard.tsx
+++ b/src/client/features/keywords/components/SerpAnalysisCard.tsx
@@ -2,11 +2,12 @@ import { useMemo } from "react";
import { createColumnHelper } from "@tanstack/react-table";
import { ExternalLink, Globe } from "lucide-react";
import { ErrorState } from "@/client/components/ErrorState";
+import { ExportMenu } from "@/client/components/ExportMenu";
import { Button } from "@/client/components/ui/button";
import { DataTable, useDataTable } from "@/client/components/table/DataTable";
import { DataTableToolbar } from "@/client/components/table/DataTableToolbar";
-import { ExportToSheetsButton } from "@/client/components/table/ExportToSheetsButton";
import { TablePagination } from "@/client/components/table/TablePagination";
+import { exportRows } from "@/client/lib/exportRows";
import type { SerpResultItem } from "@/types/keywords";
import { safeHttpUrl } from "@/shared/safe-url";
@@ -107,33 +108,42 @@ export function SerpAnalysisCard({
<DataTableToolbar
actions={
hasItems ? (
- <ExportToSheetsButton
- headers={["Rank", "Title", "URL", "Domain"]}
- rows={items.map((item) => [
- item.rank,
- item.title ?? "",
- item.url,
- item.domain,
- ])}
- feature="serp_analysis"
+ <ExportMenu
+ actions={["sheets", "csv"]}
+ onExport={(format) =>
+ void exportRows({
+ format,
+ feature: "serp_analysis",
+ headers: ["Rank", "Title", "URL", "Domain"],
+ rows: items.map((item) => [
+ item.rank,
+ item.title ?? "",
+ item.url,
+ item.domain,
+ ]),
+ filename: "serp-analysis",
+ })
+ }
/>
) : null
}
>
- <h3 className="flex min-w-0 items-center gap-1.5 text-sm font-semibold">
- <Globe className="size-3.5 shrink-0" />
- SERP Analysis
- {keyword ? (
- <span className="truncate font-normal text-muted-foreground">
- : {keyword}
+ <div className="flex min-w-0 flex-col">
+ <h3 className="flex min-w-0 items-center gap-1.5 text-sm font-semibold">
+ <Globe className="size-3.5 shrink-0" />
+ SERP Analysis
+ {keyword ? (
+ <span className="truncate font-normal text-muted-foreground">
+ : {keyword}
+ </span>
+ ) : null}
+ </h3>
+ {hasItems ? (
+ <span className="text-xs text-muted-foreground">
+ {items.length} organic results
</span>
) : null}
- </h3>
- {hasItems ? (
- <span className="text-xs text-muted-foreground">
- {items.length} organic results
- </span>
- ) : null}
+ </div>
</DataTableToolbar>
{error && hasItems ? (
<div className="border-b border-border px-4 py-3">
diff --git a/src/client/features/keywords/page/KeywordAreaField.tsx b/src/client/features/keywords/page/KeywordAreaField.tsx
index d6aeabae..236d2b32 100644
--- a/src/client/features/keywords/page/KeywordAreaField.tsx
+++ b/src/client/features/keywords/page/KeywordAreaField.tsx
@@ -23,7 +23,7 @@ export function KeywordAreaField({ locationCode, value, onChange }: Props) {
return (
<div
- className="col-span-2 w-full lg:w-60 lg:shrink-0"
+ className="col-span-2 w-full lg:w-44 lg:shrink-0"
onFocus={() => setFocused(true)}
title="Get search volume for one city, county, or region. Leave empty for the whole country."
>
@@ -31,7 +31,7 @@ export function KeywordAreaField({ locationCode, value, onChange }: Props) {
value={value}
onChange={onChange}
countryCode={countryCode}
- placeholder="City or county (optional)"
+ placeholder="City (optional)"
/>
</div>
);
diff --git a/src/client/features/rank-tracking/RankTrackingTableToolbar.tsx b/src/client/features/rank-tracking/RankTrackingTableToolbar.tsx
index af114072..ccf3639c 100644
--- a/src/client/features/rank-tracking/RankTrackingTableToolbar.tsx
+++ b/src/client/features/rank-tracking/RankTrackingTableToolbar.tsx
@@ -72,7 +72,7 @@ export function RankTrackingTableToolbar({
)}
<Button
- variant="ghost"
+ variant="outline"
size="sm"
aria-pressed={showFilters}
className="aria-pressed:bg-muted aria-pressed:text-foreground"
diff --git a/src/client/features/saved-keywords/SavedKeywordsHeader.tsx b/src/client/features/saved-keywords/SavedKeywordsHeader.tsx
index 08668685..77640867 100644
--- a/src/client/features/saved-keywords/SavedKeywordsHeader.tsx
+++ b/src/client/features/saved-keywords/SavedKeywordsHeader.tsx
@@ -31,7 +31,7 @@ export function SavedKeywordsHeader({
actions={
<>
<Button
- variant="ghost"
+ variant="outline"
size="sm"
title="Fetch new volume, difficulty, and CPC"
disabled={disabled || metricsRefreshing}