mirror of
https://github.com/ShayManor/github-readme-stats.git
synced 2026-12-02 11:53:48 +05:30
feat(result-screen): add onRegenerate prop to ResultScreen component.
This commit is contained in:
@@ -278,6 +278,7 @@ export default function App() {
|
|||||||
generatedSvg={generatedSvg}
|
generatedSvg={generatedSvg}
|
||||||
generateError={generateError}
|
generateError={generateError}
|
||||||
onBack={handleBack}
|
onBack={handleBack}
|
||||||
|
onRegenerate={handleGenerate}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -15,9 +15,10 @@ type Props = {
|
|||||||
generatedSvg: string | null
|
generatedSvg: string | null
|
||||||
generateError: string | null
|
generateError: string | null
|
||||||
onBack: () => void
|
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 safeSvg = useMemo(() => (generatedSvg ? sanitizeSvg(generatedSvg) : ''), [generatedSvg])
|
||||||
const [copied, setCopied] = useState(false)
|
const [copied, setCopied] = useState(false)
|
||||||
const embedUrl = `${window.location.origin}/api/${encodeURIComponent(username)}`
|
const embedUrl = `${window.location.origin}/api/${encodeURIComponent(username)}`
|
||||||
@@ -35,7 +36,7 @@ export function ResultScreen({ username, generating, generatedSvg, generateError
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="min-h-screen flex flex-col items-center animate-fade-in-up">
|
<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
|
<button
|
||||||
onClick={onBack}
|
onClick={onBack}
|
||||||
className="flex items-center gap-1.5 text-xs text-gray-400 hover:text-gray-600 transition-colors"
|
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>
|
</svg>
|
||||||
Back
|
Back
|
||||||
</button>
|
</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>
|
||||||
|
|
||||||
<div className="flex-1 flex flex-col items-center justify-center px-6 pb-12 w-full max-w-3xl">
|
<div className="flex-1 flex flex-col items-center justify-center px-6 pb-12 w-full max-w-3xl">
|
||||||
|
|||||||
@@ -86,20 +86,15 @@ def compute_grade(github_data: dict, custom_tags: list[str] = None) -> GradeData
|
|||||||
active_weeks.add((iso[0], iso[1]))
|
active_weeks.add((iso[0], iso[1]))
|
||||||
except ValueError:
|
except ValueError:
|
||||||
continue
|
continue
|
||||||
consistency_score = min(len(active_weeks) / 40 * 100, 100)
|
|
||||||
|
|
||||||
# Weights sum to 1.0. Commits dominates (the user's actual output),
|
# Weights sum to 1.0
|
||||||
# consistency is the second-biggest (rewards sustained work over the
|
|
||||||
# last year, not just lifetime totals). Stars is softened two ways:
|
|
||||||
# its weight drops from 0.20 to 0.12, and the cap rises from 200 to
|
|
||||||
# 300 so each individual star contributes less to maxing the factor.
|
|
||||||
per_factor = {
|
per_factor = {
|
||||||
"commits": (min(commits / 2000 * 100, 100), 0.33),
|
"commits": (min(commits / 3000 * 100, 100), 0.33),
|
||||||
"consistency": (consistency_score, 0.22),
|
"consistency": (min(len(active_weeks) / 40 * 100, 100), 0.22),
|
||||||
"repos": (min(repo_count / 30 * 100, 100), 0.15),
|
"repos": (min(repo_count / 40 * 100, 100), 0.15),
|
||||||
"stars": (min(stars / 300 * 100, 100), 0.12),
|
"stars": (min(stars / 200 * 100, 100), 0.11),
|
||||||
"forks": (min(forks / 50 * 100, 100), 0.08),
|
"forks": (min(forks / 20 * 100, 100), 0.08),
|
||||||
"activity": (min(len(events) / 80 * 100, 100), 0.07),
|
"activity": (min(len(events) / 80 * 100, 100), 0.08),
|
||||||
"followers": (min(followers / 100 * 100, 100), 0.03),
|
"followers": (min(followers / 100 * 100, 100), 0.03),
|
||||||
}
|
}
|
||||||
scores = {k: v for k, (v, _w) in per_factor.items()}
|
scores = {k: v for k, (v, _w) in per_factor.items()}
|
||||||
|
|||||||
Reference in New Issue
Block a user