sanity-plugin-seo-copilot 0.2.15 → 0.2.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/README.md +63 -50
  2. package/dist/index.js +841 -782
  3. package/dist/index.mjs +763 -704
  4. package/package.json +62 -64
  5. package/dist/index.js.map +0 -1
  6. package/dist/index.mjs.map +0 -1
  7. package/sanity.json +0 -3
  8. package/src/components/ChatPanel.tsx +0 -311
  9. package/src/components/ConfigContext.tsx +0 -22
  10. package/src/components/FeedbackButton.tsx +0 -218
  11. package/src/components/KeywordBadge.tsx +0 -50
  12. package/src/components/KeywordPanel.tsx +0 -1234
  13. package/src/components/OnboardingPopup.tsx +0 -108
  14. package/src/components/PlacementIndicators.tsx +0 -80
  15. package/src/components/ReportProblemButton.tsx +0 -212
  16. package/src/components/SEOCopilotPanel.tsx +0 -1287
  17. package/src/components/ScoreDonut.tsx +0 -158
  18. package/src/components/SeedKeywordInput.tsx +0 -128
  19. package/src/components/ShimmerLoader.tsx +0 -123
  20. package/src/components/TabBar.tsx +0 -373
  21. package/src/components/styles.ts +0 -158
  22. package/src/components/tabs/AEOTab.tsx +0 -585
  23. package/src/components/tabs/LinkingTab.tsx +0 -446
  24. package/src/components/tabs/MetaTab.tsx +0 -431
  25. package/src/components/tabs/SummaryTab.tsx +0 -405
  26. package/src/components/tabs/TechnicalTab.tsx +0 -933
  27. package/src/hooks/useDocumentContent.ts +0 -48
  28. package/src/hooks/useKeywordAnalysis.ts +0 -292
  29. package/src/hooks/useSEOChat.ts +0 -254
  30. package/src/index.ts +0 -18
  31. package/src/inspector.ts +0 -58
  32. package/src/lib/api.ts +0 -262
  33. package/src/lib/apiKey.ts +0 -30
  34. package/src/lib/documentExtract.ts +0 -422
  35. package/src/lib/geoAnalysis.ts +0 -122
  36. package/src/lib/persistence.ts +0 -69
  37. package/src/lib/scoring.ts +0 -197
  38. package/src/lib/summary.ts +0 -645
  39. package/src/lib/types.ts +0 -212
  40. package/src/lib/utils.ts +0 -35
  41. package/v2-incompatible.js +0 -10
package/sanity.json DELETED
@@ -1,3 +0,0 @@
1
- {
2
- "parts": []
3
- }
@@ -1,311 +0,0 @@
1
- import { useState, useRef, useEffect } from "react";
2
- import ReactMarkdown from "react-markdown";
3
- import remarkGfm from "remark-gfm";
4
- import { LoadingBars } from "./SEOCopilotPanel";
5
- import { MJH_GOLD, MJH_BLUE, USER_BLUE, USER_BLUE_BORDER, MJH_SLATE } from "./styles";
6
- import { usePersistentState } from "../lib/persistence";
7
- import type { ChatMessage } from "../lib/types";
8
-
9
- interface ChatPanelProps {
10
- messages: ChatMessage[];
11
- isStreaming: boolean;
12
- sendMessage: (text: string) => Promise<void>;
13
- clearChat: () => void;
14
- documentId?: string;
15
- }
16
-
17
- const SUGGESTIONS = [
18
- "What keywords am I missing?",
19
- "How do I optimize for AEO?",
20
- "Chat about primary and supporting keywords",
21
- "What semantically related terms should I include?",
22
- ];
23
-
24
- function LogoIcon() {
25
- return (
26
- <svg width="16" height="16" viewBox="0 0 16 16" fill="none">
27
- <rect x="1" y="3" width="4" height="10" rx="1" fill={MJH_GOLD} opacity="1" />
28
- <rect x="6" y="1" width="4" height="14" rx="1" fill={MJH_GOLD} opacity="0.85" />
29
- <rect x="11" y="5" width="4" height="8" rx="1" fill={MJH_GOLD} opacity="0.6" />
30
- </svg>
31
- );
32
- }
33
-
34
- export function ChatPanel({ messages, isStreaming, sendMessage, clearChat, documentId }: ChatPanelProps) {
35
- // Input is per-doc and persisted - if a user types a question, undocks, the text stays.
36
- const inputKey = documentId ? `seo-copilot-chat-input-${documentId}` : "seo-copilot-chat-input-default";
37
- const [input, setInput] = usePersistentState<string>(inputKey, "");
38
- const [inputFocused, setInputFocused] = useState(false);
39
- const [hoveredSuggestion, setHoveredSuggestion] = useState<number | null>(null);
40
- const [clearHovered, setClearHovered] = useState(false);
41
- const messagesEndRef = useRef<HTMLDivElement>(null);
42
-
43
- useEffect(() => {
44
- messagesEndRef.current?.scrollIntoView({ behavior: "smooth" });
45
- }, [messages]);
46
-
47
- // Input is persisted per-doc via usePersistentState - no manual reset needed.
48
- // The key changes when documentId changes, so the new doc's input loads automatically.
49
-
50
- const handleSend = () => {
51
- const trimmed = input.trim();
52
- if (!trimmed || isStreaming) return;
53
- setInput("");
54
- sendMessage(trimmed);
55
- };
56
-
57
- const handleKeyDown = (e: React.KeyboardEvent) => {
58
- if (e.key === "Enter" && !e.shiftKey) {
59
- e.preventDefault();
60
- handleSend();
61
- }
62
- };
63
-
64
- const showTypingBars = isStreaming && (
65
- messages.length === 0 ||
66
- messages[messages.length - 1].role === "user" ||
67
- (messages[messages.length - 1].role === "assistant" && !messages[messages.length - 1].content)
68
- );
69
-
70
- return (
71
- <div
72
- style={{
73
- position: "relative",
74
- flex: 1,
75
- minHeight: 0,
76
- // Transparent: the blue chat-zone gradient (CHAT_ZONE_BG) lives on the
77
- // shared wrapper one level up, so the toggle bar, these messages, and the
78
- // composer all sit on ONE continuous gradient with no seam. The glass
79
- // bubbles + composer frost over it.
80
- background: "transparent",
81
- }}
82
- >
83
- {/* Absolute inner creates a definite-height context so flex children respect bounds */}
84
- <div style={{ position: "absolute", top: 0, left: 0, right: 0, bottom: 0, display: "flex", flexDirection: "column" }}>
85
- {/* Messages Area - scrollable */}
86
- <div style={{ flex: 1, overflowY: "auto", padding: 12, minHeight: 0 }}>
87
- {messages.length === 0 && !isStreaming ? (
88
- <div style={{ display: "flex", flexDirection: "column", gap: 12 }}>
89
- {/* Welcome */}
90
- <div style={{ display: "flex", alignItems: "center", gap: 8, marginBottom: 4 }}>
91
- <LogoIcon />
92
- <span style={{ fontSize: 12, fontWeight: 600, color: "#4b5563" }}>
93
- Welcome to SEO Copilot! Ask anything about your content.
94
- </span>
95
- </div>
96
- {/* Suggestion prompts */}
97
- {SUGGESTIONS.map((s, i) => (
98
- <button
99
- key={i}
100
- onClick={() => sendMessage(s)}
101
- onMouseEnter={() => setHoveredSuggestion(i)}
102
- onMouseLeave={() => setHoveredSuggestion(null)}
103
- style={{
104
- width: "100%",
105
- textAlign: "left",
106
- padding: "10px 14px",
107
- borderRadius: 12,
108
- fontSize: 12.5,
109
- color: "#1f2937",
110
- background: hoveredSuggestion === i ? USER_BLUE : "rgba(255,255,255,0.5)",
111
- backdropFilter: "blur(16px) saturate(170%)",
112
- WebkitBackdropFilter: "blur(16px) saturate(170%)",
113
- border: `1px solid ${hoveredSuggestion === i ? USER_BLUE_BORDER : "rgba(255,255,255,0.6)"}`,
114
- boxShadow: "inset 0 0 0 1px rgba(255,255,255,0.4), 0 1px 2px rgba(0,0,0,0.04)",
115
- cursor: "pointer",
116
- transition: "all 200ms ease",
117
- }}
118
- >
119
- {s}
120
- </button>
121
- ))}
122
- </div>
123
- ) : (
124
- <div style={{ display: "flex", flexDirection: "column", gap: 12 }}>
125
- {messages.map((msg, i) => {
126
- // Skip empty assistant messages (typing bars show instead)
127
- if (msg.role === "assistant" && !msg.content) return null;
128
- return (
129
- <div
130
- key={i}
131
- style={{
132
- display: "flex",
133
- justifyContent: msg.role === "user" ? "flex-end" : "flex-start",
134
- animation: "fade-up 0.2s ease-out forwards",
135
- }}
136
- >
137
- <div
138
- style={{
139
- maxWidth: "88%",
140
- padding: "10px 14px",
141
- fontSize: 12.5,
142
- lineHeight: 1.65,
143
- borderRadius: 18,
144
- ...(msg.role === "user"
145
- ? {
146
- background: USER_BLUE,
147
- border: `1px solid ${USER_BLUE_BORDER}`,
148
- boxShadow: "0 1px 3px rgba(0,93,172,0.08)",
149
- borderBottomRightRadius: 6,
150
- color: "#1e293b",
151
- }
152
- : {
153
- background: "rgba(255,255,255,0.55)",
154
- backdropFilter: "blur(16px) saturate(170%)",
155
- WebkitBackdropFilter: "blur(16px) saturate(170%)",
156
- boxShadow: "inset 0 0 0 1px rgba(255,255,255,0.5), 0 1px 3px rgba(0,0,0,0.06)",
157
- borderBottomLeftRadius: 6,
158
- color: "#1f2937",
159
- }),
160
- }}
161
- >
162
- {msg.role === "assistant" ? (
163
- <div className="prose-chat">
164
- <ReactMarkdown remarkPlugins={[remarkGfm]}>{msg.content}</ReactMarkdown>
165
- </div>
166
- ) : (
167
- <span style={{ whiteSpace: "pre-wrap" }}>{msg.content}</span>
168
- )}
169
- {isStreaming && i === messages.length - 1 && msg.role === "assistant" && msg.content && (
170
- <span style={{ display: "inline-flex", alignItems: "flex-end", gap: 2, height: 10, marginLeft: 4, verticalAlign: "middle" }}>
171
- {[1, 2, 3].map((n) => (
172
- <span
173
- key={n}
174
- style={{
175
- width: 2,
176
- height: 6,
177
- borderRadius: 1,
178
- background: MJH_GOLD,
179
- animation: `bar-shift-${n} 1.4s ease-in-out infinite`,
180
- }}
181
- />
182
- ))}
183
- </span>
184
- )}
185
- </div>
186
- </div>
187
- );
188
- })}
189
-
190
- {/* Typing bars */}
191
- {showTypingBars && (
192
- <div style={{ display: "flex", justifyContent: "flex-start" }}>
193
- <div
194
- style={{
195
- padding: 12,
196
- borderRadius: 16,
197
- borderBottomLeftRadius: 4,
198
- background: "rgba(255,255,255,0.55)",
199
- backdropFilter: "blur(16px) saturate(170%)",
200
- WebkitBackdropFilter: "blur(16px) saturate(170%)",
201
- boxShadow: "inset 0 0 0 1px rgba(255,255,255,0.5), 0 1px 3px rgba(0,0,0,0.06)",
202
- }}
203
- >
204
- <LoadingBars size="xs" />
205
- </div>
206
- </div>
207
- )}
208
-
209
- <div ref={messagesEndRef} />
210
- </div>
211
- )}
212
- </div>
213
-
214
- {/* Input bar - sits at the very bottom of the panel, fully opaque so no
215
- panel gold bleeds through. Clear is folded in as a trash icon on the
216
- left so there's no separate strip beneath the input. */}
217
- <div
218
- style={{
219
- display: "flex",
220
- alignItems: "center",
221
- gap: 8,
222
- padding: 12,
223
- borderTop: "1px solid rgba(255,255,255,0.55)",
224
- background: "rgba(255,255,255,0.4)",
225
- backdropFilter: "blur(16px) saturate(170%)",
226
- WebkitBackdropFilter: "blur(16px) saturate(170%)",
227
- boxShadow: "inset 0 1px 0 rgba(255,255,255,0.65), 0 -3px 10px rgba(0,0,0,0.04)",
228
- flexShrink: 0,
229
- }}
230
- >
231
- {messages.length > 0 && (
232
- <button
233
- onClick={clearChat}
234
- onMouseEnter={() => !isStreaming && setClearHovered(true)}
235
- onMouseLeave={() => setClearHovered(false)}
236
- title="Clear conversation"
237
- aria-label="Clear conversation"
238
- disabled={isStreaming}
239
- style={{
240
- background: "none",
241
- border: "none",
242
- cursor: isStreaming ? "not-allowed" : "pointer",
243
- padding: 4,
244
- display: "flex",
245
- alignItems: "center",
246
- color: isStreaming ? "#d1d5db" : clearHovered ? "#ef4444" : "#9ca3af",
247
- transition: "color 150ms",
248
- flexShrink: 0,
249
- opacity: isStreaming ? 0.4 : 1,
250
- }}
251
- >
252
- <svg width="14" height="14" viewBox="0 0 20 20" fill="currentColor">
253
- <path fillRule="evenodd" d="M8.75 1A2.75 2.75 0 006 3.75v.443c-.795.077-1.584.176-2.365.298a.75.75 0 10.23 1.482l.149-.022.841 10.518A2.75 2.75 0 007.596 19h4.807a2.75 2.75 0 002.742-2.53l.841-10.519.149.023a.75.75 0 00.23-1.482A41.03 41.03 0 0014 4.193V3.75A2.75 2.75 0 0011.25 1h-2.5zM10 4c.84 0 1.673.025 2.5.075V3.75c0-.69-.56-1.25-1.25-1.25h-2.5c-.69 0-1.25.56-1.25 1.25v.325C8.327 4.025 9.16 4 10 4zM8.58 7.72a.75.75 0 00-1.5.06l.3 7.5a.75.75 0 101.5-.06l-.3-7.5zm4.34.06a.75.75 0 10-1.5-.06l-.3 7.5a.75.75 0 101.5.06l.3-7.5z" clipRule="evenodd" />
254
- </svg>
255
- </button>
256
- )}
257
- <input
258
- type="text"
259
- value={input}
260
- onChange={(e) => setInput(e.target.value)}
261
- onKeyDown={handleKeyDown}
262
- onFocus={() => setInputFocused(true)}
263
- onBlur={() => setInputFocused(false)}
264
- placeholder="Ask about SEO..."
265
- disabled={isStreaming}
266
- style={{
267
- flex: 1,
268
- padding: "8px 12px",
269
- fontSize: 12,
270
- color: "#1f2937",
271
- borderRadius: 12,
272
- border: `1px solid ${inputFocused ? MJH_BLUE : "rgba(255,255,255,0.8)"}`,
273
- background: "rgba(255,255,255,0.6)",
274
- backdropFilter: "blur(8px)",
275
- WebkitBackdropFilter: "blur(8px)",
276
- boxShadow: inputFocused
277
- ? "0 0 0 3px rgba(0,93,172,0.12), inset 0 0 0 1px rgba(255,255,255,0.5)"
278
- : "inset 0 0 0 1px rgba(255,255,255,0.5), 0 1px 2px rgba(0,0,0,0.04)",
279
- outline: "none",
280
- opacity: isStreaming ? 0.4 : 1,
281
- transition: "border-color 150ms, box-shadow 150ms",
282
- }}
283
- />
284
- <button
285
- onClick={handleSend}
286
- disabled={isStreaming || !input.trim()}
287
- style={{
288
- padding: "8px 12px",
289
- borderRadius: 12,
290
- border: "none",
291
- color: "#ffffff",
292
- background: "linear-gradient(135deg, rgba(0,93,172,0.88), rgba(0,74,138,0.96))",
293
- backdropFilter: "blur(10px) saturate(160%)",
294
- WebkitBackdropFilter: "blur(10px) saturate(160%)",
295
- boxShadow: "inset 0 1px 1px rgba(255,255,255,0.45), inset 0 -1px 2px rgba(0,0,0,0.2), 0 2px 7px rgba(0,93,172,0.32)",
296
- cursor: isStreaming || !input.trim() ? "not-allowed" : "pointer",
297
- opacity: isStreaming || !input.trim() ? 0.4 : 1,
298
- transition: "all 150ms",
299
- display: "flex",
300
- alignItems: "center",
301
- }}
302
- >
303
- <svg width="16" height="16" viewBox="0 0 20 20" fill="currentColor">
304
- <path d="M3.105 2.289a.75.75 0 00-.826.95l1.414 4.925A1.5 1.5 0 005.135 9.25h6.115a.75.75 0 010 1.5H5.135a1.5 1.5 0 00-1.442 1.086l-1.414 4.926a.75.75 0 00.826.95 28.896 28.896 0 0015.293-7.154.75.75 0 000-1.115A28.897 28.897 0 003.105 2.289z" />
305
- </svg>
306
- </button>
307
- </div>
308
- </div>
309
- </div>
310
- );
311
- }
@@ -1,22 +0,0 @@
1
- import { createContext, useContext, type ReactNode } from "react";
2
- import type { SEOCopilotConfig } from "../index";
3
-
4
- const ConfigContext = createContext<SEOCopilotConfig>({
5
- apiUrl: "http://localhost:3000",
6
- });
7
-
8
- export function ConfigProvider({
9
- config,
10
- children,
11
- }: {
12
- config: SEOCopilotConfig;
13
- children: ReactNode;
14
- }) {
15
- return (
16
- <ConfigContext.Provider value={config}>{children}</ConfigContext.Provider>
17
- );
18
- }
19
-
20
- export function useConfig(): SEOCopilotConfig {
21
- return useContext(ConfigContext);
22
- }
@@ -1,218 +0,0 @@
1
- import { useState, useRef, useEffect } from "react";
2
- import { useCurrentUser } from "sanity";
3
- import { useConfig } from "./ConfigContext";
4
- import { submitFeedback } from "../lib/api";
5
-
6
- interface FeedbackButtonProps {
7
- suggestionType: string;
8
- suggestionText: string;
9
- documentId?: string;
10
- publication?: string;
11
- }
12
-
13
- export function FeedbackButton({ suggestionType, suggestionText, documentId, publication }: FeedbackButtonProps) {
14
- const { apiUrl } = useConfig();
15
- const sanityUser = useCurrentUser();
16
- const [vote, setVote] = useState<"up" | "down" | null>(null);
17
- const [showReasonPopup, setShowReasonPopup] = useState(false);
18
- const [reason, setReason] = useState("");
19
- const [submitted, setSubmitted] = useState(false);
20
- const popupRef = useRef<HTMLDivElement>(null);
21
- const inputRef = useRef<HTMLInputElement>(null);
22
- const submitTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);
23
-
24
- useEffect(() => {
25
- return () => { if (submitTimerRef.current) clearTimeout(submitTimerRef.current); };
26
- }, []);
27
-
28
- // Close popup on outside click
29
- useEffect(() => {
30
- if (!showReasonPopup) return;
31
- const handler = (e: MouseEvent) => {
32
- if (popupRef.current && !popupRef.current.contains(e.target as Node)) {
33
- setShowReasonPopup(false);
34
- }
35
- };
36
- document.addEventListener("mousedown", handler);
37
- return () => document.removeEventListener("mousedown", handler);
38
- }, [showReasonPopup]);
39
-
40
- // Focus input when popup opens
41
- useEffect(() => {
42
- if (showReasonPopup) {
43
- setTimeout(() => inputRef.current?.focus(), 50);
44
- }
45
- }, [showReasonPopup]);
46
-
47
- const handleVote = async (v: "up" | "down") => {
48
- if (v === "down" && vote !== "down") {
49
- setVote("down");
50
- setShowReasonPopup(true);
51
- setSubmitted(false);
52
- // Submit the vote immediately
53
- try {
54
- await submitFeedback(apiUrl, {
55
- suggestion_type: suggestionType,
56
- suggestion_text: suggestionText,
57
- vote: "down",
58
- document_id: documentId,
59
- publication,
60
- user_id: sanityUser?.id,
61
- });
62
- } catch { /* silent */ }
63
- return;
64
- }
65
-
66
- const newVote = vote === v ? null : v;
67
- setVote(newVote);
68
- setShowReasonPopup(false);
69
- if (newVote) {
70
- try {
71
- await submitFeedback(apiUrl, {
72
- suggestion_type: suggestionType,
73
- suggestion_text: suggestionText,
74
- vote: newVote,
75
- document_id: documentId,
76
- publication,
77
- user_id: sanityUser?.id,
78
- });
79
- } catch { /* silent */ }
80
- }
81
- };
82
-
83
- const handleSubmitReason = async () => {
84
- const trimmed = reason.trim();
85
- if (trimmed) {
86
- try {
87
- await submitFeedback(apiUrl, {
88
- suggestion_type: suggestionType + "_reason",
89
- suggestion_text: suggestionText + " | REASON: " + trimmed,
90
- vote: "down",
91
- document_id: documentId,
92
- publication,
93
- user_id: sanityUser?.id,
94
- });
95
- } catch { /* silent */ }
96
- }
97
- setSubmitted(true);
98
- submitTimerRef.current = setTimeout(() => {
99
- setShowReasonPopup(false);
100
- setReason("");
101
- }, 1000);
102
- };
103
-
104
- return (
105
- <div style={{ display: "flex", alignItems: "center", gap: 2, flexShrink: 0, position: "relative" }}>
106
- <button
107
- onClick={() => handleVote("up")}
108
- style={{
109
- background: "none",
110
- border: "none",
111
- cursor: "pointer",
112
- padding: 1,
113
- fontSize: 12,
114
- color: vote === "up" ? "#16a34a" : "#d1d5db",
115
- transition: "color 150ms",
116
- lineHeight: 1,
117
- display: "flex",
118
- }}
119
- title="Good suggestion"
120
- >
121
- <svg width="12" height="12" viewBox="0 0 20 20" fill="currentColor">
122
- <path d="M1 8.25a1.25 1.25 0 112.5 0v7.5a1.25 1.25 0 11-2.5 0v-7.5zM11 3V1.7c0-.268.14-.526.395-.607A2 2 0 0114 3c0 .995-.182 1.948-.514 2.826-.204.54.166 1.174.744 1.174h2.52c1.243 0 2.261 1.01 2.146 2.247a23.864 23.864 0 01-1.341 5.974 1.637 1.637 0 01-1.555 1.029H6.5V7.5L11 3z" />
123
- </svg>
124
- </button>
125
- <button
126
- onClick={() => handleVote("down")}
127
- style={{
128
- background: "none",
129
- border: "none",
130
- cursor: "pointer",
131
- padding: 1,
132
- fontSize: 12,
133
- color: vote === "down" ? "#dc2626" : "#d1d5db",
134
- transition: "color 150ms",
135
- lineHeight: 1,
136
- display: "flex",
137
- }}
138
- title="Not helpful"
139
- >
140
- <svg width="12" height="12" viewBox="0 0 20 20" fill="currentColor">
141
- <path d="M19 11.75a1.25 1.25 0 11-2.5 0v-7.5a1.25 1.25 0 112.5 0v7.5zM9 17v1.3c0 .268-.14.526-.395.607A2 2 0 016 17c0-.995.182-1.948.514-2.826.204-.54-.166-1.174-.744-1.174H3.25c-1.243 0-2.261-1.01-2.146-2.247a23.864 23.864 0 011.341-5.974A1.637 1.637 0 014 3.75h9.5V12.5L9 17z" />
142
- </svg>
143
- </button>
144
-
145
- {/* Thumbs down reason popup */}
146
- {showReasonPopup && (
147
- <div
148
- ref={popupRef}
149
- style={{
150
- position: "absolute",
151
- top: "100%",
152
- right: 0,
153
- marginTop: 4,
154
- width: 220,
155
- padding: 10,
156
- borderRadius: 10,
157
- background: "#ffffff",
158
- boxShadow: "0 4px 16px rgba(0,0,0,0.15), 0 1px 4px rgba(0,0,0,0.1)",
159
- zIndex: 100,
160
- border: "1px solid #e5e7eb",
161
- }}
162
- >
163
- {submitted ? (
164
- <div style={{ fontSize: 11, color: "#16a34a", textAlign: "center", padding: "4px 0" }}>
165
- Thanks for the feedback!
166
- </div>
167
- ) : (
168
- <>
169
- <div style={{ fontSize: 11, fontWeight: 600, color: "#1f2937", marginBottom: 6 }}>
170
- Sorry! What went wrong?
171
- </div>
172
- <input
173
- ref={inputRef}
174
- type="text"
175
- value={reason}
176
- onChange={(e) => setReason(e.target.value)}
177
- onKeyDown={(e) => { if (e.key === "Enter") handleSubmitReason(); }}
178
- placeholder="Tell us what to improve..."
179
- style={{
180
- width: "100%",
181
- padding: "5px 8px",
182
- fontSize: 11,
183
- borderRadius: 6,
184
- border: "1px solid #e5e7eb",
185
- outline: "none",
186
- fontFamily: "inherit",
187
- boxSizing: "border-box",
188
- }}
189
- />
190
- <div style={{ display: "flex", justifyContent: "flex-end", marginTop: 6, gap: 4 }}>
191
- <button
192
- onClick={() => { setShowReasonPopup(false); setReason(""); }}
193
- style={{
194
- padding: "3px 8px", fontSize: 10, borderRadius: 4,
195
- border: "1px solid #e5e7eb", background: "#ffffff", color: "#4b5563",
196
- cursor: "pointer",
197
- }}
198
- >
199
- Skip
200
- </button>
201
- <button
202
- onClick={handleSubmitReason}
203
- style={{
204
- padding: "3px 8px", fontSize: 10, borderRadius: 4,
205
- border: "none", background: "#dc2626", color: "#ffffff",
206
- cursor: "pointer", fontWeight: 600,
207
- }}
208
- >
209
- Submit
210
- </button>
211
- </div>
212
- </>
213
- )}
214
- </div>
215
- )}
216
- </div>
217
- );
218
- }
@@ -1,50 +0,0 @@
1
- import { MJH_BLUE } from "./styles";
2
- import { PlacementIndicators } from "./PlacementIndicators";
3
- import type { KeywordPlacement } from "../lib/types";
4
-
5
- interface KeywordBadgeProps {
6
- term: string;
7
- volume?: number | null;
8
- type: "primary" | "supporting" | "missing";
9
- inContent?: boolean;
10
- placement?: KeywordPlacement;
11
- }
12
-
13
- const colorMap = {
14
- primary: { bg: "rgba(220,252,231,0.8)", text: "#166534" },
15
- supporting: { bg: "rgba(0,93,172,0.1)", text: MJH_BLUE },
16
- missing: { bg: "rgba(230,192,27,0.15)", text: "#8B7310" },
17
- };
18
-
19
- function formatVolume(volume: number | null | undefined): string {
20
- if (volume === null || volume === undefined) return "";
21
- if (volume === 0) return "N/A";
22
- return volume.toLocaleString();
23
- }
24
-
25
- export function KeywordBadge({ term, volume, type, inContent, placement }: KeywordBadgeProps) {
26
- const colors = colorMap[type];
27
- const volumeStr = formatVolume(volume);
28
-
29
- return (
30
- <div style={{ display: "flex", alignItems: "center", gap: 6, padding: "2px 0", flexWrap: "wrap" }}>
31
- <span
32
- style={{
33
- borderRadius: 99,
34
- padding: "2px 10px",
35
- fontSize: 12,
36
- fontWeight: 500,
37
- whiteSpace: "nowrap",
38
- background: colors.bg,
39
- color: colors.text,
40
- }}
41
- >
42
- {term}
43
- </span>
44
- {volumeStr && (
45
- <span style={{ fontSize: 12, color: "#4b5563" }}>{volumeStr === "N/A" ? volumeStr : `${volumeStr}/mo`}</span>
46
- )}
47
- <PlacementIndicators placement={placement} />
48
- </div>
49
- );
50
- }