sanity-plugin-seo-copilot 0.1.2 → 0.2.0
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.
- package/dist/index.js +4729 -895
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +4722 -888
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/components/ChatPanel.tsx +87 -69
- package/src/components/FeedbackButton.tsx +2 -2
- package/src/components/KeywordBadge.tsx +50 -50
- package/src/components/KeywordPanel.tsx +97 -226
- package/src/components/PlacementIndicators.tsx +80 -76
- package/src/components/SEOCopilotPanel.tsx +712 -165
- package/src/components/ScoreDonut.tsx +158 -0
- package/src/components/SeedKeywordInput.tsx +128 -125
- package/src/components/ShimmerLoader.tsx +119 -0
- package/src/components/TabBar.tsx +370 -0
- package/src/components/styles.ts +66 -0
- package/src/components/tabs/AEOTab.tsx +573 -0
- package/src/components/tabs/LinkingTab.tsx +343 -0
- package/src/components/tabs/MetaTab.tsx +417 -0
- package/src/components/tabs/SummaryTab.tsx +384 -0
- package/src/components/tabs/TechnicalTab.tsx +776 -0
- package/src/hooks/useDocumentContent.ts +216 -99
- package/src/hooks/useKeywordAnalysis.ts +28 -8
- package/src/hooks/useSEOChat.ts +38 -11
- package/src/lib/api.ts +109 -13
- package/src/lib/geoAnalysis.ts +109 -0
- package/src/lib/persistence.ts +69 -0
- package/src/lib/scoring.ts +147 -0
- package/src/lib/summary.ts +504 -0
- package/src/lib/types.ts +197 -108
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
// Hand-rolled SVG donut showing how topic / freshness / section-fit each contributed
|
|
2
|
+
// to a Linking suggestion's composite score. Inline-styled - works inside Sanity Studio sandbox.
|
|
3
|
+
// Hover the donut for the raw sub-scores (the surest way to read tiny segments).
|
|
4
|
+
|
|
5
|
+
import { useState } from "react";
|
|
6
|
+
import { MJH_BLUE, MJH_GOLD } from "./styles";
|
|
7
|
+
|
|
8
|
+
interface ScoreDonutProps {
|
|
9
|
+
size?: number;
|
|
10
|
+
strokeWidth?: number;
|
|
11
|
+
topic: number;
|
|
12
|
+
freshness: number;
|
|
13
|
+
sectionFit: number;
|
|
14
|
+
/** Pre-computed composite (0-100). If omitted, computed from defaults 60/25/15. */
|
|
15
|
+
composite?: number;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const W = { topic: 0.6, freshness: 0.25, sectionFit: 0.15 } as const;
|
|
19
|
+
// Colorblind-safe trio: blue + gold + purple. Green was dropped - blue+green fails
|
|
20
|
+
// for deuteranopia (~5% of men). Purple is distinct from both blue and gold under
|
|
21
|
+
// every common colorblindness simulation.
|
|
22
|
+
const COLORS = { topic: MJH_BLUE, freshness: MJH_GOLD, sectionFit: "#9B59B6" };
|
|
23
|
+
const TRACK = "#eef2f7";
|
|
24
|
+
|
|
25
|
+
export function ScoreDonut({
|
|
26
|
+
size = 64,
|
|
27
|
+
strokeWidth = 9,
|
|
28
|
+
topic,
|
|
29
|
+
freshness,
|
|
30
|
+
sectionFit,
|
|
31
|
+
composite,
|
|
32
|
+
}: ScoreDonutProps) {
|
|
33
|
+
const [hovered, setHovered] = useState(false);
|
|
34
|
+
const radius = (size - strokeWidth) / 2;
|
|
35
|
+
const circumference = 2 * Math.PI * radius;
|
|
36
|
+
|
|
37
|
+
// Weighted contributions (points the segment actually contributed to composite).
|
|
38
|
+
const cTopic = topic * W.topic;
|
|
39
|
+
const cFresh = freshness * W.freshness;
|
|
40
|
+
const cSection = sectionFit * W.sectionFit;
|
|
41
|
+
const compositeValue = composite != null ? composite : Math.round(cTopic + cFresh + cSection);
|
|
42
|
+
|
|
43
|
+
// Each segment renders as a fraction of the full ring (weighted maxes sum to 100,
|
|
44
|
+
// so a perfect 100 fills the donut).
|
|
45
|
+
const seg = (contribution: number) => (contribution / 100) * circumference;
|
|
46
|
+
// A small transparent gap between segments so adjacent colors don't bleed together.
|
|
47
|
+
const GAP = Math.min(2.5, circumference * 0.02);
|
|
48
|
+
const drawn = (fullLen: number) => (fullLen > 0 ? Math.max(0.75, fullLen - GAP) : 0);
|
|
49
|
+
|
|
50
|
+
const topicLen = seg(cTopic);
|
|
51
|
+
const freshLen = seg(cFresh);
|
|
52
|
+
const sectionLen = seg(cSection);
|
|
53
|
+
|
|
54
|
+
const Slice = ({ color, fullLen, offset }: { color: string; fullLen: number; offset: number }) => (
|
|
55
|
+
<circle
|
|
56
|
+
cx={size / 2}
|
|
57
|
+
cy={size / 2}
|
|
58
|
+
r={radius}
|
|
59
|
+
fill="none"
|
|
60
|
+
stroke={color}
|
|
61
|
+
strokeWidth={strokeWidth}
|
|
62
|
+
strokeLinecap="butt"
|
|
63
|
+
strokeDasharray={`${drawn(fullLen)} ${circumference}`}
|
|
64
|
+
strokeDashoffset={-offset}
|
|
65
|
+
/>
|
|
66
|
+
);
|
|
67
|
+
|
|
68
|
+
return (
|
|
69
|
+
<div
|
|
70
|
+
style={{ position: "relative", width: size, height: size, flexShrink: 0 }}
|
|
71
|
+
onMouseEnter={() => setHovered(true)}
|
|
72
|
+
onMouseLeave={() => setHovered(false)}
|
|
73
|
+
>
|
|
74
|
+
<svg width={size} height={size} viewBox={`0 0 ${size} ${size}`} style={{ transform: "rotate(-90deg)" }}>
|
|
75
|
+
<circle cx={size / 2} cy={size / 2} r={radius} fill="none" stroke={TRACK} strokeWidth={strokeWidth} />
|
|
76
|
+
<Slice color={COLORS.topic} fullLen={topicLen} offset={0} />
|
|
77
|
+
<Slice color={COLORS.freshness} fullLen={freshLen} offset={topicLen} />
|
|
78
|
+
<Slice color={COLORS.sectionFit} fullLen={sectionLen} offset={topicLen + freshLen} />
|
|
79
|
+
</svg>
|
|
80
|
+
<div
|
|
81
|
+
style={{
|
|
82
|
+
position: "absolute",
|
|
83
|
+
inset: 0,
|
|
84
|
+
display: "flex",
|
|
85
|
+
flexDirection: "column",
|
|
86
|
+
alignItems: "center",
|
|
87
|
+
justifyContent: "center",
|
|
88
|
+
fontVariantNumeric: "tabular-nums",
|
|
89
|
+
lineHeight: 1,
|
|
90
|
+
}}
|
|
91
|
+
>
|
|
92
|
+
<span style={{ fontSize: Math.max(11, size / 5.5), fontWeight: 700, color: "#1f2937" }}>
|
|
93
|
+
{compositeValue}%
|
|
94
|
+
</span>
|
|
95
|
+
<span style={{ fontSize: Math.max(7, size / 11), fontWeight: 700, color: "#4b5563", letterSpacing: "0.05em", marginTop: 1 }}>
|
|
96
|
+
MATCH
|
|
97
|
+
</span>
|
|
98
|
+
</div>
|
|
99
|
+
|
|
100
|
+
{hovered && (
|
|
101
|
+
<div
|
|
102
|
+
role="tooltip"
|
|
103
|
+
style={{
|
|
104
|
+
position: "absolute",
|
|
105
|
+
left: "50%",
|
|
106
|
+
top: -6,
|
|
107
|
+
transform: "translate(-50%, -100%)",
|
|
108
|
+
background: "#1f2937",
|
|
109
|
+
color: "#ffffff",
|
|
110
|
+
borderRadius: 8,
|
|
111
|
+
padding: "7px 9px",
|
|
112
|
+
fontSize: 10.5,
|
|
113
|
+
lineHeight: 1.5,
|
|
114
|
+
whiteSpace: "nowrap",
|
|
115
|
+
boxShadow: "0 4px 14px rgba(0,0,0,0.25)",
|
|
116
|
+
zIndex: 20,
|
|
117
|
+
pointerEvents: "none",
|
|
118
|
+
}}
|
|
119
|
+
>
|
|
120
|
+
<SubScoreRow color={COLORS.topic} label="Topic" value={topic} />
|
|
121
|
+
<SubScoreRow color={COLORS.freshness} label="Freshness" value={freshness} />
|
|
122
|
+
<SubScoreRow color={COLORS.sectionFit} label="Section fit" value={sectionFit} />
|
|
123
|
+
</div>
|
|
124
|
+
)}
|
|
125
|
+
</div>
|
|
126
|
+
);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
function SubScoreRow({ color, label, value }: { color: string; label: string; value: number }) {
|
|
130
|
+
return (
|
|
131
|
+
<div style={{ display: "flex", alignItems: "center", gap: 6 }}>
|
|
132
|
+
<span style={{ width: 7, height: 7, borderRadius: "50%", background: color, display: "inline-block", flexShrink: 0 }} />
|
|
133
|
+
<span style={{ flex: 1 }}>{label}</span>
|
|
134
|
+
<span style={{ fontWeight: 700, fontVariantNumeric: "tabular-nums" }}>{Math.round(value)}/100</span>
|
|
135
|
+
</div>
|
|
136
|
+
);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
export function ScoreDonutLegend() {
|
|
140
|
+
// The percentages here are the WEIGHTS each signal contributes to the composite,
|
|
141
|
+
// not the article's score on that signal. Phrased so editors don't misread it.
|
|
142
|
+
return (
|
|
143
|
+
<div style={{ display: "flex", gap: 10, fontSize: 9, color: "rgba(0,0,0,0.55)", alignItems: "center", flexWrap: "wrap" }}>
|
|
144
|
+
<LegendDot color={COLORS.topic} label="Topic match (60% of score)" />
|
|
145
|
+
<LegendDot color={COLORS.freshness} label="Freshness (25%)" />
|
|
146
|
+
<LegendDot color={COLORS.sectionFit} label="Section fit (15%)" />
|
|
147
|
+
</div>
|
|
148
|
+
);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
function LegendDot({ color, label }: { color: string; label: string }) {
|
|
152
|
+
return (
|
|
153
|
+
<span style={{ display: "inline-flex", alignItems: "center", gap: 4 }}>
|
|
154
|
+
<span style={{ width: 7, height: 7, borderRadius: "50%", background: color, display: "inline-block" }} />
|
|
155
|
+
{label}
|
|
156
|
+
</span>
|
|
157
|
+
);
|
|
158
|
+
}
|
|
@@ -1,125 +1,128 @@
|
|
|
1
|
-
import { useState, useRef } from "react";
|
|
2
|
-
import { MJH_GOLD } from "./styles";
|
|
3
|
-
|
|
4
|
-
interface SeedKeywordInputProps {
|
|
5
|
-
seeds: string[];
|
|
6
|
-
onSeedsChange: (seeds: string[]) => void;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
function parseSeedInput(input: string): string[] {
|
|
10
|
-
return input
|
|
11
|
-
.split(/[,\n]+/)
|
|
12
|
-
.map((s) => s.trim())
|
|
13
|
-
.filter((s) => s.length > 0);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export function SeedKeywordInput({ seeds, onSeedsChange }: SeedKeywordInputProps) {
|
|
17
|
-
const [inputValue, setInputValue] = useState("");
|
|
18
|
-
const inputRef = useRef<HTMLTextAreaElement>(null);
|
|
19
|
-
|
|
20
|
-
const handleAdd = () => {
|
|
21
|
-
const parsed = parseSeedInput(inputValue);
|
|
22
|
-
if (parsed.length > 0) {
|
|
23
|
-
const combined = [...new Set([...seeds, ...parsed])];
|
|
24
|
-
onSeedsChange(combined);
|
|
25
|
-
setInputValue("");
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
const handleRemove = (term: string) => {
|
|
30
|
-
onSeedsChange(seeds.filter((s) => s !== term));
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
const handleKeyDown = (e: React.KeyboardEvent) => {
|
|
34
|
-
if (e.key === "Enter" && !e.shiftKey) {
|
|
35
|
-
e.preventDefault();
|
|
36
|
-
handleAdd();
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
return (
|
|
41
|
-
<div style={{
|
|
42
|
-
borderRadius: 14,
|
|
43
|
-
background: "
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
</
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
1
|
+
import { useState, useRef } from "react";
|
|
2
|
+
import { MJH_GOLD } from "./styles";
|
|
3
|
+
|
|
4
|
+
interface SeedKeywordInputProps {
|
|
5
|
+
seeds: string[];
|
|
6
|
+
onSeedsChange: (seeds: string[]) => void;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
function parseSeedInput(input: string): string[] {
|
|
10
|
+
return input
|
|
11
|
+
.split(/[,\n]+/)
|
|
12
|
+
.map((s) => s.trim())
|
|
13
|
+
.filter((s) => s.length > 0);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function SeedKeywordInput({ seeds, onSeedsChange }: SeedKeywordInputProps) {
|
|
17
|
+
const [inputValue, setInputValue] = useState("");
|
|
18
|
+
const inputRef = useRef<HTMLTextAreaElement>(null);
|
|
19
|
+
|
|
20
|
+
const handleAdd = () => {
|
|
21
|
+
const parsed = parseSeedInput(inputValue);
|
|
22
|
+
if (parsed.length > 0) {
|
|
23
|
+
const combined = [...new Set([...seeds, ...parsed])];
|
|
24
|
+
onSeedsChange(combined);
|
|
25
|
+
setInputValue("");
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const handleRemove = (term: string) => {
|
|
30
|
+
onSeedsChange(seeds.filter((s) => s !== term));
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const handleKeyDown = (e: React.KeyboardEvent) => {
|
|
34
|
+
if (e.key === "Enter" && !e.shiftKey) {
|
|
35
|
+
e.preventDefault();
|
|
36
|
+
handleAdd();
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
return (
|
|
41
|
+
<div style={{
|
|
42
|
+
borderRadius: 14,
|
|
43
|
+
background: "rgba(255,255,255,0.55)",
|
|
44
|
+
backdropFilter: "blur(16px) saturate(170%)",
|
|
45
|
+
WebkitBackdropFilter: "blur(16px) saturate(170%)",
|
|
46
|
+
boxShadow: "inset 0 0 0 1px rgba(255,255,255,0.85), inset 1.5px 2px 1px -1px rgba(255,255,255,1), inset -2px -3px 2px -1px rgba(255,255,255,0.6), 0 2px 6px rgba(0,0,0,0.07), 0 10px 26px rgba(0,0,0,0.08)",
|
|
47
|
+
padding: "12px 14px",
|
|
48
|
+
}}>
|
|
49
|
+
<span style={{ fontSize: 10.5, textTransform: "uppercase", letterSpacing: "0.06em", color: "#4b5563", fontWeight: 600 }}>
|
|
50
|
+
Desired Keywords
|
|
51
|
+
</span>
|
|
52
|
+
|
|
53
|
+
{/* Seed tags */}
|
|
54
|
+
{seeds.length > 0 && (
|
|
55
|
+
<div style={{ display: "flex", flexWrap: "wrap", gap: 5, marginTop: 8 }}>
|
|
56
|
+
{seeds.map((seed) => (
|
|
57
|
+
<span key={seed} style={{
|
|
58
|
+
display: "inline-flex",
|
|
59
|
+
alignItems: "center",
|
|
60
|
+
gap: 5,
|
|
61
|
+
padding: "3px 10px",
|
|
62
|
+
borderRadius: 99,
|
|
63
|
+
fontSize: 11.5,
|
|
64
|
+
fontWeight: 500,
|
|
65
|
+
background: `rgba(230,192,27,0.12)`,
|
|
66
|
+
color: "#92810F",
|
|
67
|
+
transition: "all 150ms",
|
|
68
|
+
}}>
|
|
69
|
+
{seed}
|
|
70
|
+
<button
|
|
71
|
+
onClick={() => handleRemove(seed)}
|
|
72
|
+
aria-label={`Remove ${seed}`}
|
|
73
|
+
style={{ background: "none", border: "none", cursor: "pointer", padding: 0, fontSize: 14, color: "#8B7310", lineHeight: 1 }}
|
|
74
|
+
>
|
|
75
|
+
×
|
|
76
|
+
</button>
|
|
77
|
+
</span>
|
|
78
|
+
))}
|
|
79
|
+
</div>
|
|
80
|
+
)}
|
|
81
|
+
|
|
82
|
+
{/* Input area - always visible */}
|
|
83
|
+
<div style={{ marginTop: 8 }}>
|
|
84
|
+
<textarea
|
|
85
|
+
ref={inputRef}
|
|
86
|
+
value={inputValue}
|
|
87
|
+
onChange={(e) => setInputValue(e.target.value)}
|
|
88
|
+
onKeyDown={handleKeyDown}
|
|
89
|
+
placeholder="Enter 2-3 word phrases for best results"
|
|
90
|
+
rows={2}
|
|
91
|
+
style={{
|
|
92
|
+
width: "100%",
|
|
93
|
+
padding: "8px 10px",
|
|
94
|
+
fontSize: 12.5,
|
|
95
|
+
borderRadius: 10,
|
|
96
|
+
border: "1px solid #e2e8f0",
|
|
97
|
+
background: "#fafbfc",
|
|
98
|
+
resize: "vertical",
|
|
99
|
+
outline: "none",
|
|
100
|
+
fontFamily: "inherit",
|
|
101
|
+
boxSizing: "border-box",
|
|
102
|
+
}}
|
|
103
|
+
/>
|
|
104
|
+
<button
|
|
105
|
+
onClick={handleAdd}
|
|
106
|
+
disabled={!inputValue.trim()}
|
|
107
|
+
style={{
|
|
108
|
+
marginTop: 4,
|
|
109
|
+
padding: "4px 12px",
|
|
110
|
+
fontSize: 11,
|
|
111
|
+
fontWeight: 600,
|
|
112
|
+
borderRadius: 6,
|
|
113
|
+
border: "none",
|
|
114
|
+
background: inputValue.trim() ? MJH_GOLD : "#e5e7eb",
|
|
115
|
+
color: inputValue.trim() ? "#ffffff" : "#9ca3af",
|
|
116
|
+
cursor: inputValue.trim() ? "pointer" : "not-allowed",
|
|
117
|
+
transition: "all 150ms",
|
|
118
|
+
}}
|
|
119
|
+
>
|
|
120
|
+
Add
|
|
121
|
+
</button>
|
|
122
|
+
<div style={{ marginTop: 4, fontSize: 10, color: "#4b5563" }}>
|
|
123
|
+
Two- and three-word phrases give sharper results than single words.
|
|
124
|
+
</div>
|
|
125
|
+
</div>
|
|
126
|
+
</div>
|
|
127
|
+
);
|
|
128
|
+
}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
// ShimmerLoader - pulsating MJH-bar loader + rotating shimmer text.
|
|
2
|
+
// The three bars echo the MJH logo (shifting heights) and animate via the
|
|
3
|
+
// bar-shift keyframes injected globally by SEOCopilotPanel's INJECTED_CSS.
|
|
4
|
+
// The text uses a scoped shimmer keyframe injected once on first mount.
|
|
5
|
+
|
|
6
|
+
import { useEffect, useState } from "react";
|
|
7
|
+
import { MJH_GOLD } from "./styles";
|
|
8
|
+
|
|
9
|
+
let keyframesInjected = false;
|
|
10
|
+
|
|
11
|
+
const KEYFRAMES = `
|
|
12
|
+
@keyframes seo-copilot-text-shimmer {
|
|
13
|
+
0% { background-position: -100% center; }
|
|
14
|
+
100% { background-position: 100% center; }
|
|
15
|
+
}
|
|
16
|
+
`;
|
|
17
|
+
|
|
18
|
+
interface LoaderBarsProps {
|
|
19
|
+
color?: string;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// Three gold bars that shift height - the MJH "pulsating bars" loader.
|
|
23
|
+
function LoaderBars({ color = MJH_GOLD }: LoaderBarsProps) {
|
|
24
|
+
return (
|
|
25
|
+
<div
|
|
26
|
+
role="status"
|
|
27
|
+
aria-label="Loading"
|
|
28
|
+
style={{ display: "inline-flex", alignItems: "flex-end", gap: 2, height: 14, flexShrink: 0 }}
|
|
29
|
+
>
|
|
30
|
+
{[1, 2, 3].map((i) => (
|
|
31
|
+
<div
|
|
32
|
+
key={i}
|
|
33
|
+
style={{
|
|
34
|
+
width: 6,
|
|
35
|
+
height: 8,
|
|
36
|
+
borderRadius: 2,
|
|
37
|
+
background: color,
|
|
38
|
+
animation: `bar-shift-${i} 1.4s ease-in-out infinite`,
|
|
39
|
+
}}
|
|
40
|
+
/>
|
|
41
|
+
))}
|
|
42
|
+
</div>
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
interface ShimmerLoaderProps {
|
|
47
|
+
messages: string[];
|
|
48
|
+
intervalMs?: number;
|
|
49
|
+
textSize?: number;
|
|
50
|
+
iconColor?: string;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export function ShimmerLoader({
|
|
54
|
+
messages,
|
|
55
|
+
intervalMs = 1500,
|
|
56
|
+
textSize = 14,
|
|
57
|
+
iconColor = MJH_GOLD,
|
|
58
|
+
}: ShimmerLoaderProps) {
|
|
59
|
+
const [idx, setIdx] = useState(0);
|
|
60
|
+
|
|
61
|
+
useEffect(() => {
|
|
62
|
+
if (typeof window !== "undefined" && !keyframesInjected) {
|
|
63
|
+
keyframesInjected = true;
|
|
64
|
+
const style = document.createElement("style");
|
|
65
|
+
style.dataset.seoCopilotKeyframes = "1";
|
|
66
|
+
style.innerHTML = KEYFRAMES;
|
|
67
|
+
document.head.appendChild(style);
|
|
68
|
+
}
|
|
69
|
+
}, []);
|
|
70
|
+
|
|
71
|
+
useEffect(() => {
|
|
72
|
+
if (messages.length <= 1) return;
|
|
73
|
+
const id = setInterval(() => {
|
|
74
|
+
setIdx((i) => (i + 1) % messages.length);
|
|
75
|
+
}, intervalMs);
|
|
76
|
+
return () => clearInterval(id);
|
|
77
|
+
}, [messages.length, intervalMs]);
|
|
78
|
+
|
|
79
|
+
const text = messages[idx] || messages[0] || "";
|
|
80
|
+
|
|
81
|
+
return (
|
|
82
|
+
<div
|
|
83
|
+
style={{
|
|
84
|
+
display: "inline-flex",
|
|
85
|
+
alignItems: "center",
|
|
86
|
+
gap: 8,
|
|
87
|
+
fontSize: textSize,
|
|
88
|
+
fontWeight: 500,
|
|
89
|
+
letterSpacing: "0.01em",
|
|
90
|
+
}}
|
|
91
|
+
>
|
|
92
|
+
<LoaderBars color={iconColor} />
|
|
93
|
+
<span
|
|
94
|
+
style={{
|
|
95
|
+
backgroundImage:
|
|
96
|
+
"linear-gradient(90deg, rgb(113 113 122) 0%, rgb(113 113 122) 40%, rgb(24 24 27) 50%, rgb(113 113 122) 60%, rgb(113 113 122) 100%)",
|
|
97
|
+
backgroundSize: "200% auto",
|
|
98
|
+
backgroundClip: "text",
|
|
99
|
+
WebkitBackgroundClip: "text",
|
|
100
|
+
color: "transparent",
|
|
101
|
+
animation: "seo-copilot-text-shimmer 2s ease-in-out infinite",
|
|
102
|
+
}}
|
|
103
|
+
>
|
|
104
|
+
{text}
|
|
105
|
+
</span>
|
|
106
|
+
</div>
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export const DEFAULT_GENERATE_ALL_MESSAGES = [
|
|
111
|
+
"Processing",
|
|
112
|
+
"Gathering keyword data",
|
|
113
|
+
"Running deep analysis",
|
|
114
|
+
"Scanning for AEO opportunities",
|
|
115
|
+
"Finding internal links",
|
|
116
|
+
"Auditing meta and structure",
|
|
117
|
+
"Cross-checking score components",
|
|
118
|
+
"Compiling summary",
|
|
119
|
+
];
|