Files
gridpilot.gg/apps/website/components/drivers/DriverHeaderPanel.tsx
2026-01-19 14:07:49 +01:00

111 lines
2.9 KiB
TypeScript

import { RatingBadge } from '@/components/drivers/RatingBadge';
import { Image } from '@/ui/Image';
import { Stack } from '@/ui/Stack';
import { Text } from '@/ui/Text';
import React from 'react';
interface DriverHeaderPanelProps {
name: string;
avatarUrl?: string;
nationality: string;
rating: number;
ratingLabel: string;
globalRankLabel?: string | null;
bio?: string | null;
actions?: React.ReactNode;
}
export function DriverHeaderPanel({
name,
avatarUrl,
nationality,
rating,
ratingLabel,
globalRankLabel,
bio,
actions
}: DriverHeaderPanelProps) {
const defaultAvatar = 'https://cdn.gridpilot.com/avatars/default.png';
return (
<Stack
bg="bg-panel-gray"
rounded="xl"
border
borderColor="border-charcoal-outline"
overflow="hidden"
position="relative"
>
{/* Background Accent */}
<Stack
position="absolute"
top={0}
left={0}
right={0}
height="24"
bg="bg-gradient-to-r from-primary-blue/20 to-transparent"
opacity={0.5}
/>
<Stack p={6} position="relative">
<Stack direction={{ base: 'col', md: 'row' }} gap={6} align="start" className="md:items-center">
{/* Avatar */}
<Stack
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"
/>
</Stack>
{/* Info */}
<Stack 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} ratingLabel={ratingLabel} size="lg" />
</Stack>
<Stack direction="row" align="center" gap={4} wrap>
<Text size="sm" color="text-gray-400">
{nationality}
</Text>
{globalRankLabel && (
<Text size="sm" color="text-gray-400">
Global Rank: <Text color="text-warning-amber" weight="semibold">{globalRankLabel}</Text>
</Text>
)}
</Stack>
{bio && (
<Text size="sm" color="text-gray-400" className="max-w-2xl mt-2" lineClamp={2}>
{bio}
</Text>
)}
</Stack>
</Stack>
{/* Actions */}
{actions && (
<Stack flexShrink={0}>
{actions}
</Stack>
)}
</Stack>
</Stack>
</Stack>
);
}