Skip to content

Commit 3e64553

Browse files
magicnightclaude
andcommitted
feat: add clickable navigation to market cards
- HeroCard and NewsPredictionCard accept optional href prop - Cards link to /markets/[id] for full market detail view - Homepage hero + trending cards, explore page cards all linked - Hover states added for visual feedback Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent c885e65 commit 3e64553

4 files changed

Lines changed: 19 additions & 4 deletions

File tree

newspredict/src/app/explore/page.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ export default function ExplorePage() {
2626
yesPercent: Math.round((m.yesPrice || 0.5) * 100),
2727
noPercent: Math.round((m.noPrice || 0.5) * 100),
2828
isHot: m.volume > 100,
29+
href: `/markets/${m.id}`,
2930
}));
3031

3132
return (

newspredict/src/app/page.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ export default async function HomePage() {
6060
yesPercent: Math.round((m.yesPrice || 0.5) * 100),
6161
noPercent: Math.round((m.noPrice || 0.5) * 100),
6262
isHot: m.volume > 100,
63+
href: `/markets/${m.id}`,
6364
}));
6465
const quickPoll = markets[1] || markets[0] || null;
6566
const resolvedCard = resolved[0] || null;
@@ -87,6 +88,7 @@ export default async function HomePage() {
8788
noPercent={Math.round((hero.noPrice || 0.5) * 100)}
8889
volume={hero.volume > 0 ? `$${hero.volume}` : '$0'}
8990
isLive={hero.status === 'open'}
91+
href={`/markets/${hero.id}`}
9092
/>
9193
) : (
9294
<div className="rounded-xl border border-[var(--border)] p-6 text-center text-[var(--muted)] text-sm">

newspredict/src/components/cards/hero-card.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
'use client';
22

3+
import Link from 'next/link';
4+
35
interface HeroCardProps {
46
title: string;
57
category: string;
@@ -9,6 +11,7 @@ interface HeroCardProps {
911
isLive?: boolean;
1012
viewerCount?: string;
1113
imageUrl?: string;
14+
href?: string;
1215
}
1316

1417
export function HeroCard({
@@ -20,9 +23,12 @@ export function HeroCard({
2023
isLive,
2124
viewerCount,
2225
imageUrl,
26+
href,
2327
}: HeroCardProps) {
28+
const Wrapper = href ? Link : 'div';
29+
const wrapperProps = href ? { href } : {};
2430
return (
25-
<div className="rounded-2xl overflow-hidden bg-[var(--card)]">
31+
<Wrapper {...wrapperProps as any} className="block rounded-2xl overflow-hidden bg-[var(--card)] hover:ring-1 hover:ring-[var(--accent)]/30 transition-all">
2632
<div
2733
className="relative h-40 flex items-end p-4"
2834
style={{
@@ -60,6 +66,6 @@ export function HeroCard({
6066
<span>${volume} vol</span>
6167
</div>
6268
</div>
63-
</div>
69+
</Wrapper>
6470
);
6571
}

newspredict/src/components/cards/news-prediction-card.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
'use client';
22

3+
import Link from 'next/link';
4+
35
interface NewsPredictionCardProps {
46
title: string;
57
category: string;
68
yesPercent: number;
79
noPercent: number;
810
isHot?: boolean;
911
imageUrl?: string;
12+
href?: string;
1013
}
1114

1215
export function NewsPredictionCard({
@@ -16,9 +19,12 @@ export function NewsPredictionCard({
1619
noPercent,
1720
isHot,
1821
imageUrl,
22+
href,
1923
}: NewsPredictionCardProps) {
24+
const Wrapper = href ? Link : 'div';
25+
const wrapperProps = href ? { href } : {};
2026
return (
21-
<div className="flex gap-3 bg-[var(--card)] rounded-xl p-3">
27+
<Wrapper {...wrapperProps as any} className="flex gap-3 bg-[var(--card)] rounded-xl p-3 hover:bg-[var(--card-hover)] transition-colors block">
2228
<div
2329
className="w-[72px] h-[72px] rounded-lg shrink-0"
2430
style={{
@@ -39,6 +45,6 @@ export function NewsPredictionCard({
3945
{isHot && <span className="text-xs ml-auto">Hot</span>}
4046
</div>
4147
</div>
42-
</div>
48+
</Wrapper>
4349
);
4450
}

0 commit comments

Comments
 (0)