Files
gridpilot.gg/apps/website/ui/DriverHeaderPanel.tsx
2026-01-17 15:46:55 +01:00

110 lines
2.8 KiB
TypeScript

import React from 'react';
import { Box } from './Box';
import { Text } from './Text';
import { Stack } from './Stack';
import { Image } from './Image';
import { RatingBadge } from './RatingBadge';
interface DriverHeaderPanelProps {
name: string;
avatarUrl?: string;
nationality: string;
rating: number;
globalRank?: number | null;
bio?: string | null;
actions?: React.ReactNode;
}
export function DriverHeaderPanel({
name,
avatarUrl,
nationality,
rating,
globalRank,
bio,
actions
}: DriverHeaderPanelProps) {
const defaultAvatar = 'https://cdn.gridpilot.com/avatars/default.png';
return (
<Box
bg="bg-panel-gray"
rounded="xl"
border
borderColor="border-charcoal-outline"
overflow="hidden"
position="relative"
>
{/* Background Accent */}
<Box
position="absolute"
top={0}
left={0}
right={0}
height="24"
bg="bg-gradient-to-r from-primary-blue/20 to-transparent"
opacity={0.5}
/>
<Box p={6} position="relative">
<Stack direction={{ base: 'col', md: 'row' }} gap={6} align="start" className="md:items-center">
{/* Avatar */}
<Box
width="32"
height="32"
rounded="2xl"
overflow="hidden"
border
borderColor="border-charcoal-outline"
bg="bg-graphite-black"
flexShrink={0}
>
<Image
src={avatarUrl || defaultAvatar}
alt={name}
fill
objectFit="cover"
/>
</Box>
{/* Info */}
<Box flexGrow={1}>
<Stack gap={2}>
<Stack direction="row" align="center" gap={3} wrap>
<Text as="h1" size="3xl" weight="bold" color="text-white">
{name}
</Text>
<RatingBadge rating={rating} size="lg" />
</Stack>
<Stack direction="row" align="center" gap={4} wrap>
<Text size="sm" color="text-gray-400">
{nationality}
</Text>
{globalRank !== undefined && globalRank !== null && (
<Text size="sm" color="text-gray-400">
Global Rank: <Text color="text-warning-amber" weight="semibold">#{globalRank}</Text>
</Text>
)}
</Stack>
{bio && (
<Text size="sm" color="text-gray-400" className="max-w-2xl mt-2" lineClamp={2}>
{bio}
</Text>
)}
</Stack>
</Box>
{/* Actions */}
{actions && (
<Box flexShrink={0}>
{actions}
</Box>
)}
</Stack>
</Box>
</Box>
);
}