Skip to content

Commit c8365f3

Browse files
yethikrishnaclaude
andcommitted
fix: live GitHub stars counter + database configured
- StarsCounter now fetches real star count from GitHub API (was hardcoded at 2,847) - Animates counting up to the live value - Graceful fallback to 0 if API fails - Database tables pushed to Neon PostgreSQL via Drizzle Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 0baa19d commit c8365f3

1 file changed

Lines changed: 21 additions & 5 deletions

File tree

web/src/components/FeatureShowcase.tsx

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -150,24 +150,40 @@ function AgentOrbit() {
150150

151151
function StarsCounter() {
152152
const [count, setCount] = useState(0)
153+
const [liveStars, setLiveStars] = useState<number | null>(null)
153154
const ref = useRef<HTMLDivElement>(null)
154155
const isInView = useInView(ref, { once: true, amount: 0.5 })
155156

157+
// Fetch live star count from GitHub API
156158
useEffect(() => {
157-
if (!isInView) return
158-
const target = 2847 // Fake star count for visual effect
159-
const duration = 2000
159+
fetch('https://api.github.com/repos/yethikrishna/levelcode')
160+
.then(res => res.json())
161+
.then(data => {
162+
if (data.stargazers_count != null) {
163+
setLiveStars(data.stargazers_count)
164+
}
165+
})
166+
.catch(() => {
167+
// Fallback if API fails - just show 0
168+
})
169+
}, [])
170+
171+
// Animate counting up to the live value
172+
useEffect(() => {
173+
if (!isInView || liveStars === null) return
174+
const target = liveStars
175+
if (target === 0) { setCount(0); return }
176+
const duration = Math.min(2000, target * 20) // Scale duration with count
160177
const start = Date.now()
161178
const iv = setInterval(() => {
162179
const elapsed = Date.now() - start
163180
const progress = Math.min(elapsed / duration, 1)
164-
// Ease-out cubic
165181
const eased = 1 - Math.pow(1 - progress, 3)
166182
setCount(Math.floor(eased * target))
167183
if (progress >= 1) clearInterval(iv)
168184
}, 16)
169185
return () => clearInterval(iv)
170-
}, [isInView])
186+
}, [isInView, liveStars])
171187

172188
return (
173189
<div ref={ref} className="flex items-center gap-3">

0 commit comments

Comments
 (0)