Initial commit

This commit is contained in:
Jack Levy
2026-02-28 21:08:19 -05:00
commit e418dd9ae0
85 changed files with 5261 additions and 0 deletions

View File

@@ -0,0 +1,81 @@
import Link from "next/link";
import { TrendingUp, Calendar, User } from "lucide-react";
import { Bill } from "@/lib/types";
import { billLabel, cn, formatDate, partyBadgeColor, trendColor } from "@/lib/utils";
import { FollowButton } from "./FollowButton";
interface BillCardProps {
bill: Bill;
compact?: boolean;
}
export function BillCard({ bill, compact = false }: BillCardProps) {
const label = billLabel(bill.bill_type, bill.bill_number);
const score = bill.latest_trend?.composite_score;
const tags = bill.latest_brief?.topic_tags?.slice(0, 3) || [];
return (
<div className="bg-card border border-border rounded-lg p-4 hover:border-primary/30 transition-colors">
<div className="flex items-start justify-between gap-3">
<div className="flex-1 min-w-0">
<div className="flex items-center gap-2 mb-1.5 flex-wrap">
<span className="text-xs font-mono font-semibold text-muted-foreground bg-muted px-1.5 py-0.5 rounded">
{label}
</span>
<span className="text-xs text-muted-foreground">
{bill.chamber}
</span>
{tags.map((tag) => (
<span
key={tag}
className="text-xs px-1.5 py-0.5 rounded-full bg-accent text-accent-foreground"
>
{tag}
</span>
))}
</div>
<Link href={`/bills/${bill.bill_id}`}>
<h3 className="text-sm font-medium leading-snug hover:text-primary transition-colors line-clamp-2">
{bill.short_title || bill.title || "Untitled Bill"}
</h3>
</Link>
{!compact && bill.sponsor && (
<div className="flex items-center gap-1.5 mt-1.5 text-xs text-muted-foreground">
<User className="w-3 h-3" />
<Link href={`/members/${bill.sponsor.bioguide_id}`} className="hover:text-foreground transition-colors">
{bill.sponsor.name}
</Link>
{bill.sponsor.party && (
<span className={cn("px-1 py-0.5 rounded text-xs font-medium", partyBadgeColor(bill.sponsor.party))}>
{bill.sponsor.party}
</span>
)}
{bill.sponsor.state && (
<span>{bill.sponsor.state}</span>
)}
</div>
)}
</div>
<div className="flex flex-col items-end gap-2 shrink-0">
<FollowButton type="bill" value={bill.bill_id} />
{score !== undefined && score > 0 && (
<div className={cn("flex items-center gap-1 text-xs font-medium", trendColor(score))}>
<TrendingUp className="w-3 h-3" />
{Math.round(score)}
</div>
)}
</div>
</div>
{!compact && bill.latest_action_text && (
<p className="mt-2 text-xs text-muted-foreground line-clamp-2 border-t border-border pt-2">
<Calendar className="w-3 h-3 inline mr-1" />
{formatDate(bill.latest_action_date)} {bill.latest_action_text}
</p>
)}
</div>
);
}

View File

@@ -0,0 +1,44 @@
"use client";
import { Heart } from "lucide-react";
import { useAddFollow, useIsFollowing, useRemoveFollow } from "@/lib/hooks/useFollows";
import { cn } from "@/lib/utils";
interface FollowButtonProps {
type: "bill" | "member" | "topic";
value: string;
label?: string;
}
export function FollowButton({ type, value, label }: FollowButtonProps) {
const existing = useIsFollowing(type, value);
const add = useAddFollow();
const remove = useRemoveFollow();
const isFollowing = !!existing;
const isPending = add.isPending || remove.isPending;
const handleClick = () => {
if (isFollowing && existing) {
remove.mutate(existing.id);
} else {
add.mutate({ type, value });
}
};
return (
<button
onClick={handleClick}
disabled={isPending}
className={cn(
"flex items-center gap-1.5 px-3 py-1.5 rounded-md text-sm font-medium transition-colors",
isFollowing
? "bg-red-100 text-red-700 hover:bg-red-200 dark:bg-red-900/30 dark:text-red-400"
: "bg-muted text-muted-foreground hover:bg-accent hover:text-foreground"
)}
>
<Heart className={cn("w-3.5 h-3.5", isFollowing && "fill-current")} />
{isFollowing ? "Unfollow" : label || "Follow"}
</button>
);
}

View File

@@ -0,0 +1,63 @@
"use client";
import Link from "next/link";
import { usePathname } from "next/navigation";
import {
LayoutDashboard,
FileText,
Users,
Tags,
Heart,
Settings,
Landmark,
} from "lucide-react";
import { cn } from "@/lib/utils";
import { ThemeToggle } from "./ThemeToggle";
const NAV = [
{ href: "/", label: "Dashboard", icon: LayoutDashboard },
{ href: "/bills", label: "Bills", icon: FileText },
{ href: "/members", label: "Members", icon: Users },
{ href: "/topics", label: "Topics", icon: Tags },
{ href: "/following", label: "Following", icon: Heart },
{ href: "/settings", label: "Settings", icon: Settings },
];
export function Sidebar() {
const pathname = usePathname();
return (
<aside className="w-56 shrink-0 border-r border-border bg-card flex flex-col">
<div className="p-4 border-b border-border flex items-center gap-2">
<Landmark className="w-5 h-5 text-primary" />
<span className="font-semibold text-sm">PocketVeto</span>
</div>
<nav className="flex-1 p-3 space-y-1">
{NAV.map(({ href, label, icon: Icon }) => {
const active = href === "/" ? pathname === "/" : pathname.startsWith(href);
return (
<Link
key={href}
href={href}
className={cn(
"flex items-center gap-3 px-3 py-2 rounded-md text-sm transition-colors",
active
? "bg-primary text-primary-foreground"
: "text-muted-foreground hover:bg-accent hover:text-accent-foreground"
)}
>
<Icon className="w-4 h-4 shrink-0" />
{label}
</Link>
);
})}
</nav>
<div className="p-3 border-t border-border flex items-center justify-between">
<span className="text-xs text-muted-foreground">Theme</span>
<ThemeToggle />
</div>
</aside>
);
}

View File

@@ -0,0 +1,19 @@
"use client";
import { Moon, Sun } from "lucide-react";
import { useTheme } from "next-themes";
export function ThemeToggle() {
const { theme, setTheme } = useTheme();
return (
<button
onClick={() => setTheme(theme === "dark" ? "light" : "dark")}
className="p-1.5 rounded-md hover:bg-accent transition-colors text-muted-foreground hover:text-foreground"
aria-label="Toggle theme"
>
<Sun className="w-4 h-4 hidden dark:block" />
<Moon className="w-4 h-4 dark:hidden" />
</button>
);
}