website refactor
This commit is contained in:
@@ -1,11 +1,12 @@
|
||||
'use client';
|
||||
|
||||
import { Icon } from '@/ui/Icon';
|
||||
import { Stack } from '@/ui/primitives/Stack';
|
||||
import { Surface } from '@/ui/primitives/Surface';
|
||||
import { Panel } from '@/ui/Panel';
|
||||
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from '@/ui/Table';
|
||||
import { Text } from '@/ui/Text';
|
||||
import { PositionBadge } from '@/ui/ResultRow';
|
||||
import { TrendingUp, Trophy } from 'lucide-react';
|
||||
import React from 'react';
|
||||
|
||||
interface StandingsEntry {
|
||||
position: number;
|
||||
@@ -23,94 +24,63 @@ interface StandingsTableShellProps {
|
||||
|
||||
export function StandingsTableShell({ standings, title = 'Championship Standings' }: StandingsTableShellProps) {
|
||||
return (
|
||||
<Surface variant="dark" border rounded="lg" overflow="hidden">
|
||||
<Stack px={6} py={4} borderBottom borderColor="border-charcoal-outline" bg="bg-iron-gray/20">
|
||||
<Stack direction="row" align="center" justify="between">
|
||||
<Stack direction="row" align="center" gap={2}>
|
||||
<Icon icon={Trophy} size={4} color="text-warning-amber" />
|
||||
<Text weight="bold" letterSpacing="wider" size="sm" display="block">
|
||||
{title.toUpperCase()}
|
||||
</Text>
|
||||
</Stack>
|
||||
<Stack px={2} py={0.5} rounded="md" bg="bg-charcoal-outline/50">
|
||||
<Text size="xs" color="text-gray-400" weight="medium">{standings.length} Drivers</Text>
|
||||
</Stack>
|
||||
</Stack>
|
||||
</Stack>
|
||||
|
||||
<Table>
|
||||
<TableHead>
|
||||
<TableRow>
|
||||
<TableHeader w="4rem">Pos</TableHeader>
|
||||
<TableHeader>Driver</TableHeader>
|
||||
<TableHeader textAlign="center">Wins</TableHeader>
|
||||
<TableHeader textAlign="center">Podiums</TableHeader>
|
||||
<TableHeader textAlign="right">Points</TableHeader>
|
||||
</TableRow>
|
||||
</TableHead>
|
||||
<TableBody>
|
||||
{standings.map((entry) => (
|
||||
<TableRow key={entry.driverName}>
|
||||
<TableCell>
|
||||
<PositionBadge position={entry.position} />
|
||||
</TableCell>
|
||||
<TableCell>
|
||||
<Stack direction="row" align="center" gap={3}>
|
||||
<Text weight="bold" color="text-white">{entry.driverName}</Text>
|
||||
{entry.change !== undefined && entry.change !== 0 && (
|
||||
<Stack direction="row" align="center" gap={0.5}>
|
||||
<Icon
|
||||
icon={TrendingUp}
|
||||
size={3}
|
||||
color={entry.change > 0 ? 'text-performance-green' : 'text-error-red'}
|
||||
transform={entry.change < 0 ? 'rotate(180deg)' : undefined}
|
||||
/>
|
||||
<Text size="xs" color={entry.change > 0 ? 'text-performance-green' : 'text-error-red'}>
|
||||
{Math.abs(entry.change)}
|
||||
</Text>
|
||||
</Stack>
|
||||
)}
|
||||
</Stack>
|
||||
</TableCell>
|
||||
<TableCell textAlign="center">
|
||||
<Text size="sm" color={entry.wins > 0 ? 'text-white' : 'text-gray-500'}>{entry.wins}</Text>
|
||||
</TableCell>
|
||||
<TableCell textAlign="center">
|
||||
<Text size="sm" color={entry.podiums > 0 ? 'text-white' : 'text-gray-500'}>{entry.podiums}</Text>
|
||||
</TableCell>
|
||||
<TableCell textAlign="right">
|
||||
<Text weight="bold" color="text-primary-blue">{entry.points}</Text>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
))}
|
||||
</TableBody>
|
||||
</Table>
|
||||
</Surface>
|
||||
);
|
||||
}
|
||||
|
||||
function PositionBadge({ position }: { position: number }) {
|
||||
const isPodium = position <= 3;
|
||||
const colors = {
|
||||
1: 'text-warning-amber bg-warning-amber/10 border-warning-amber/20',
|
||||
2: 'text-gray-300 bg-gray-300/10 border-gray-300/20',
|
||||
3: 'text-orange-400 bg-orange-400/10 border-orange-400/20',
|
||||
};
|
||||
|
||||
return (
|
||||
<Stack
|
||||
center
|
||||
w={8}
|
||||
h={8}
|
||||
rounded="md"
|
||||
border={isPodium}
|
||||
bg={isPodium ? colors[position as keyof typeof colors].split(' ')[1] : undefined}
|
||||
color={isPodium ? colors[position as keyof typeof colors].split(' ')[0] : 'text-gray-500'}
|
||||
borderColor={isPodium ? colors[position as keyof typeof colors].split(' ')[2] : undefined}
|
||||
<Panel
|
||||
title={title}
|
||||
variant="dark"
|
||||
padding={0}
|
||||
footer={
|
||||
<Text size="xs" variant="low">{standings.length} Drivers</Text>
|
||||
}
|
||||
>
|
||||
<Text size="sm" weight="bold">
|
||||
{position}
|
||||
</Text>
|
||||
</Stack>
|
||||
<div style={{ overflowX: 'auto' }}>
|
||||
<Table>
|
||||
<TableHead>
|
||||
<TableRow>
|
||||
<TableHeader w="4rem">Pos</TableHeader>
|
||||
<TableHeader>Driver</TableHeader>
|
||||
<TableHeader textAlign="center">Wins</TableHeader>
|
||||
<TableHeader textAlign="center">Podiums</TableHeader>
|
||||
<TableHeader textAlign="right">Points</TableHeader>
|
||||
</TableRow>
|
||||
</TableHead>
|
||||
<TableBody>
|
||||
{standings.map((entry) => (
|
||||
<TableRow key={entry.driverName}>
|
||||
<TableCell>
|
||||
<PositionBadge position={entry.position} />
|
||||
</TableCell>
|
||||
<TableCell>
|
||||
<div style={{ display: 'flex', alignItems: 'center', gap: '0.75rem' }}>
|
||||
<Text weight="bold" variant="high">{entry.driverName}</Text>
|
||||
{entry.change !== undefined && entry.change !== 0 && (
|
||||
<div style={{ display: 'flex', alignItems: 'center', gap: '0.125rem' }}>
|
||||
<Icon
|
||||
icon={TrendingUp}
|
||||
size={3}
|
||||
intent={entry.change > 0 ? 'success' : 'critical'}
|
||||
style={{ transform: entry.change < 0 ? 'rotate(180deg)' : undefined }}
|
||||
/>
|
||||
<Text size="xs" variant={entry.change > 0 ? 'success' : 'critical'}>
|
||||
{Math.abs(entry.change)}
|
||||
</Text>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</TableCell>
|
||||
<TableCell textAlign="center">
|
||||
<Text size="sm" variant={entry.wins > 0 ? 'high' : 'low'}>{entry.wins}</Text>
|
||||
</TableCell>
|
||||
<TableCell textAlign="center">
|
||||
<Text size="sm" variant={entry.podiums > 0 ? 'high' : 'low'}>{entry.podiums}</Text>
|
||||
</TableCell>
|
||||
<TableCell textAlign="right">
|
||||
<Text weight="bold" variant="primary">{entry.points}</Text>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
))}
|
||||
</TableBody>
|
||||
</Table>
|
||||
</div>
|
||||
</Panel>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user