brackt/app/components/league/MyLeaguesCard.tsx
Chris Parsons 2bc1173621 Responsive league row layout and mobile polish
- League rows stack avatar+name on top, stats full-width below on mobile
- Stats spread to right side on sm+ screens with border separator on mobile
- Tighter padding on mobile (px-3/py-3), full padding on sm+
- Card headers and content use px-3 sm:px-6 to reduce mobile gutters
- Two-column home layout deferred to lg breakpoint (tablet gets stacked)
- Active leagues sorted by completion percentage descending
- Default rank 1 / 0 points for active leagues with no scoring events yet
- Fix ordinal bug for 11th/12th/13th; add aria-labels to rank change indicators
- Remove dead StatDivider className prop

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-15 19:50:39 -07:00

64 lines
1.9 KiB
TypeScript

import { Shield } from "lucide-react";
import { Link } from "react-router";
import { Card, CardContent } from "~/components/ui/card";
import { SectionCardHeader } from "~/components/ui/SectionCardHeader";
import { LeagueRow, type LeagueRowProps } from "./LeagueRow";
const STATUS_ORDER: Record<LeagueRowProps["status"], number> = {
draft: 0,
active: 1,
pre_draft: 2,
completed: 3,
};
interface MyLeaguesCardProps {
leagues: LeagueRowProps[];
viewAllUrl?: string;
}
export function MyLeaguesCard({ leagues, viewAllUrl }: MyLeaguesCardProps) {
const sorted = leagues.toSorted((a, b) => {
const statusDiff = STATUS_ORDER[a.status] - STATUS_ORDER[b.status];
if (statusDiff !== 0) return statusDiff;
if (a.status === "active") {
return (b.completionPercentage ?? 0) - (a.completionPercentage ?? 0);
}
return 0;
});
const right = viewAllUrl ? (
<Link
to={viewAllUrl}
className="text-xs font-semibold uppercase tracking-wide text-electric hover:underline"
>
View All Leagues
</Link>
) : undefined;
return (
<Card className="bg-[#181b22] gap-2">
<SectionCardHeader icon={Shield} title="My Leagues" right={right} />
<CardContent className="px-3 sm:px-6">
{sorted.length === 0 ? (
<div className="py-4 text-center">
<p className="text-sm text-muted-foreground mb-3">
You aren&apos;t a member of any leagues yet.
</p>
<Link
to="/leagues/new"
className="text-sm font-medium text-primary hover:underline"
>
Create your first league
</Link>
</div>
) : (
<div className="space-y-3">
{sorted.map((league) => (
<LeagueRow key={league.leagueId} {...league} />
))}
</div>
)}
</CardContent>
</Card>
);
}