From af5c2ac270fbc188d04bab3a876a9abc034fbc0f Mon Sep 17 00:00:00 2001 From: Nicolas Corder Date: Wed, 25 Mar 2026 12:39:28 -0700 Subject: [PATCH 1/6] Refactor popup into focused components and modules - Extract styles, hook, and utilities from 1887-line index.tsx into separate files - Create ScrapeView, CrawlView, ScrapeOptions, ResultCard, ApiKeyEditor, Toast components - Reduce index.tsx to ~570 lines of orchestration and effects --- src/popup/components/ApiKeyEditor.tsx | 41 + src/popup/components/CrawlView.tsx | 188 +++ src/popup/components/ResultCard.tsx | 44 + src/popup/components/ScrapeOptions.tsx | 73 ++ src/popup/components/ScrapeView.tsx | 84 ++ src/popup/components/Toast.tsx | 10 + src/popup/index.tsx | 1547 ++---------------------- src/popup/styles.ts | 486 ++++++++ src/popup/usePopupLogic.ts | 248 ++++ src/popup/utils.ts | 190 +++ 10 files changed, 1478 insertions(+), 1433 deletions(-) create mode 100644 src/popup/components/ApiKeyEditor.tsx create mode 100644 src/popup/components/CrawlView.tsx create mode 100644 src/popup/components/ResultCard.tsx create mode 100644 src/popup/components/ScrapeOptions.tsx create mode 100644 src/popup/components/ScrapeView.tsx create mode 100644 src/popup/components/Toast.tsx create mode 100644 src/popup/styles.ts create mode 100644 src/popup/usePopupLogic.ts create mode 100644 src/popup/utils.ts diff --git a/src/popup/components/ApiKeyEditor.tsx b/src/popup/components/ApiKeyEditor.tsx new file mode 100644 index 0000000..32a6fd4 --- /dev/null +++ b/src/popup/components/ApiKeyEditor.tsx @@ -0,0 +1,41 @@ +import { styles } from "../styles"; + +type Props = { + apiKeyDraft: string; + isApiConfigured: boolean; + onDraftChange: (value: string) => void; + onSave: () => void; + onCancel: () => void; +}; + +export const ApiKeyEditor = ({ + apiKeyDraft, + isApiConfigured, + onDraftChange, + onSave, + onCancel, +}: Props) => ( +
+ + onDraftChange(event.target.value)} + /> +

Stored locally in your browser.

+
+ + {isApiConfigured ? ( + + ) : null} +
+
+); diff --git a/src/popup/components/CrawlView.tsx b/src/popup/components/CrawlView.tsx new file mode 100644 index 0000000..0bb776b --- /dev/null +++ b/src/popup/components/CrawlView.tsx @@ -0,0 +1,188 @@ +import type { CrawlStatusResponseBody } from "~lib/firecrawl"; + +import { + DEFAULT_CRAWL_FORM, + type CrawlFormState, + type CrawlStage, + type SitemapMode, +} from "../types"; +import { styles } from "../styles"; +import { getStatusDotStyle } from "../utils"; + +type Props = { + isCrawling: boolean; + tabUrl: string; + crawlStage: CrawlStage; + crawlForm: CrawlFormState; + crawlStatus: CrawlStatusResponseBody | undefined; + crawlStatusSummary: string | undefined; + crawlJobId: string | undefined; + isPolling: boolean; + onCrawlStart: () => void; + onUpdateForm: (field: F, value: CrawlFormState[F]) => void; +}; + +export const CrawlView = ({ + isCrawling, + tabUrl, + crawlStage, + crawlForm, + crawlStatus, + crawlStatusSummary, + crawlJobId, + isPolling, + onCrawlStart, + onUpdateForm, +}: Props) => ( +
+ +
+