feat(result-screen): add onRegenerate prop to ResultScreen component.

This commit is contained in:
shay
2026-04-20 13:56:43 -04:00
parent 58fd6fbe67
commit a88561073a
3 changed files with 33 additions and 14 deletions
+1
View File
@@ -278,6 +278,7 @@ export default function App() {
generatedSvg={generatedSvg}
generateError={generateError}
onBack={handleBack}
onRegenerate={handleGenerate}
/>
)}
</div>
@@ -15,9 +15,10 @@ type Props = {
generatedSvg: string | null
generateError: string | null
onBack: () => void
onRegenerate: () => void
}
export function ResultScreen({ username, generating, generatedSvg, generateError, onBack }: Props) {
export function ResultScreen({ username, generating, generatedSvg, generateError, onBack, onRegenerate }: Props) {
const safeSvg = useMemo(() => (generatedSvg ? sanitizeSvg(generatedSvg) : ''), [generatedSvg])
const [copied, setCopied] = useState(false)
const embedUrl = `${window.location.origin}/api/${encodeURIComponent(username)}`
@@ -35,7 +36,7 @@ export function ResultScreen({ username, generating, generatedSvg, generateError
return (
<div className="min-h-screen flex flex-col items-center animate-fade-in-up">
<div className="w-full max-w-3xl px-6 pt-6">
<div className="w-full max-w-3xl px-6 pt-6 flex items-center justify-between">
<button
onClick={onBack}
className="flex items-center gap-1.5 text-xs text-gray-400 hover:text-gray-600 transition-colors"
@@ -45,6 +46,28 @@ export function ResultScreen({ username, generating, generatedSvg, generateError
</svg>
Back
</button>
<button
onClick={onRegenerate}
disabled={generating}
title="Re-render the widget from the most recent cached data. Does not re-fetch from GitHub."
className="flex items-center gap-1.5 text-xs text-gray-500 hover:text-gray-800 disabled:opacity-40 disabled:cursor-not-allowed transition-colors"
>
<svg
width="14"
height="14"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
strokeWidth="2"
strokeLinecap="round"
strokeLinejoin="round"
className={generating ? 'animate-spin-slow' : ''}
>
<path d="M21 12a9 9 0 1 1-3-6.7L21 8" />
<path d="M21 3v5h-5" />
</svg>
{generating ? 'Regenerating…' : 'Regenerate'}
</button>
</div>
<div className="flex-1 flex flex-col items-center justify-center px-6 pb-12 w-full max-w-3xl">