website refactor
This commit is contained in:
@@ -5,10 +5,10 @@ import { CountryFlagDisplay } from '@/lib/display-objects/CountryFlagDisplay';
|
||||
import { Button } from '@/ui/Button';
|
||||
import { Heading } from '@/ui/Heading';
|
||||
import { Image } from '@/ui/Image';
|
||||
import { Stack } from '@/ui/primitives/Stack';
|
||||
import { Surface } from '@/ui/primitives/Surface';
|
||||
import { ProfileHero, ProfileAvatar, ProfileStatsGroup, ProfileStat } from '@/ui/ProfileHero';
|
||||
import { Text } from '@/ui/Text';
|
||||
import { Calendar, Globe, Star, Trophy, UserPlus } from 'lucide-react';
|
||||
import React from 'react';
|
||||
|
||||
interface ProfileHeaderProps {
|
||||
driver: {
|
||||
@@ -36,103 +36,63 @@ export function ProfileHeader({
|
||||
isOwnProfile,
|
||||
}: ProfileHeaderProps) {
|
||||
return (
|
||||
<header>
|
||||
<Surface variant="muted" rounded="xl" border padding={6} backgroundColor="#141619" borderColor="#23272B">
|
||||
<Stack direction="row" align="center" gap={8} wrap>
|
||||
{/* Avatar with telemetry-style border */}
|
||||
<Stack position="relative">
|
||||
<Stack
|
||||
width="6rem"
|
||||
height="6rem"
|
||||
rounded="md"
|
||||
border
|
||||
borderColor="#23272B"
|
||||
p={0.5}
|
||||
backgroundColor="#0C0D0F"
|
||||
>
|
||||
<Stack width="100%" height="100%" rounded="sm" overflow="hidden">
|
||||
<Image
|
||||
src={driver.avatarUrl || mediaConfig.avatars.defaultFallback}
|
||||
alt={driver.name}
|
||||
width={96}
|
||||
height={96}
|
||||
objectFit="cover"
|
||||
fullWidth
|
||||
fullHeight
|
||||
/>
|
||||
</Stack>
|
||||
</Stack>
|
||||
</Stack>
|
||||
<ProfileHero variant="muted">
|
||||
<div style={{ display: 'flex', alignItems: 'center', gap: '2rem', flexWrap: 'wrap' }}>
|
||||
<ProfileAvatar>
|
||||
<Image
|
||||
src={driver.avatarUrl || mediaConfig.avatars.defaultFallback}
|
||||
alt={driver.name}
|
||||
width={96}
|
||||
height={96}
|
||||
objectFit="cover"
|
||||
/>
|
||||
</ProfileAvatar>
|
||||
|
||||
{/* Driver Info */}
|
||||
<Stack flexGrow={1} minWidth="0">
|
||||
<Stack direction="row" align="center" gap={3} mb={1}>
|
||||
<Heading level={1} fontSize="1.5rem">
|
||||
{driver.name}
|
||||
</Heading>
|
||||
<Text size="2xl" aria-label={`Country: ${driver.country}`}>
|
||||
{CountryFlagDisplay.fromCountryCode(driver.country).toString()}
|
||||
<div style={{ flex: 1, minWidth: '200px' }}>
|
||||
<div style={{ display: 'flex', alignItems: 'center', gap: '0.75rem', marginBottom: '0.25rem' }}>
|
||||
<Heading level={1}>{driver.name}</Heading>
|
||||
<Text size="2xl" aria-label={`Country: ${driver.country}`}>
|
||||
{CountryFlagDisplay.fromCountryCode(driver.country).toString()}
|
||||
</Text>
|
||||
</div>
|
||||
|
||||
<div style={{ display: 'flex', alignItems: 'center', gap: '1rem' }}>
|
||||
<div style={{ display: 'flex', alignItems: 'center', gap: '0.375rem' }}>
|
||||
<Globe size={14} color="var(--ui-color-text-low)" />
|
||||
<Text size="xs" font="mono" variant="low">ID: {driver.iracingId}</Text>
|
||||
</div>
|
||||
<div style={{ display: 'flex', alignItems: 'center', gap: '0.375rem' }}>
|
||||
<Calendar size={14} color="var(--ui-color-text-low)" />
|
||||
<Text size="xs" variant="low">
|
||||
Joined {new Date(driver.joinedAt).toLocaleDateString('en-US', { month: 'short', year: 'numeric' })}
|
||||
</Text>
|
||||
</Stack>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<Stack direction="row" align="center" gap={4} color="#9ca3af">
|
||||
<Stack direction="row" align="center" gap={1.5}>
|
||||
<Globe size={14} />
|
||||
<Text size="xs" font="mono">ID: {driver.iracingId}</Text>
|
||||
</Stack>
|
||||
<Stack width="1px" height="12px" backgroundColor="#23272B" />
|
||||
<Stack direction="row" align="center" gap={1.5}>
|
||||
<Calendar size={14} />
|
||||
<Text size="xs">
|
||||
Joined {new Date(driver.joinedAt).toLocaleDateString('en-US', { month: 'short', year: 'numeric' })}
|
||||
</Text>
|
||||
</Stack>
|
||||
</Stack>
|
||||
</Stack>
|
||||
|
||||
{/* Stats Grid */}
|
||||
<Stack direction="row" align="center" gap={6}>
|
||||
{stats && (
|
||||
<>
|
||||
<Stack>
|
||||
<Stack gap={0.5}>
|
||||
<Text size="xs" color="#6b7280" weight="bold" letterSpacing="0.05em">RATING</Text>
|
||||
<Stack direction="row" align="center" gap={1.5}>
|
||||
<Star size={14} color="#198CFF" />
|
||||
<Text font="mono" size="lg" weight="bold" color="#198CFF">{stats.rating}</Text>
|
||||
</Stack>
|
||||
</Stack>
|
||||
</Stack>
|
||||
<Stack width="1px" height="32px" backgroundColor="#23272B" />
|
||||
<Stack>
|
||||
<Stack gap={0.5}>
|
||||
<Text size="xs" color="#6b7280" weight="bold" letterSpacing="0.05em">GLOBAL RANK</Text>
|
||||
<Stack direction="row" align="center" gap={1.5}>
|
||||
<Trophy size={14} color="#FFBE4D" />
|
||||
<Text font="mono" size="lg" weight="bold" color="#FFBE4D">#{globalRank}</Text>
|
||||
</Stack>
|
||||
</Stack>
|
||||
</Stack>
|
||||
</>
|
||||
)}
|
||||
</Stack>
|
||||
|
||||
{/* Actions */}
|
||||
{!isOwnProfile && onAddFriend && (
|
||||
<Stack ml="auto">
|
||||
<Button
|
||||
variant={friendRequestSent ? 'secondary' : 'primary'}
|
||||
onClick={onAddFriend}
|
||||
disabled={friendRequestSent}
|
||||
size="sm"
|
||||
icon={<UserPlus size={16} />}
|
||||
>
|
||||
{friendRequestSent ? 'Request Sent' : 'Add Friend'}
|
||||
</Button>
|
||||
</Stack>
|
||||
<ProfileStatsGroup>
|
||||
{stats && (
|
||||
<React.Fragment>
|
||||
<ProfileStat label="RATING" value={stats.rating} intent="primary" />
|
||||
<ProfileStat label="GLOBAL RANK" value={`#${globalRank}`} intent="warning" />
|
||||
</React.Fragment>
|
||||
)}
|
||||
</Stack>
|
||||
</Surface>
|
||||
</header>
|
||||
</ProfileStatsGroup>
|
||||
|
||||
{!isOwnProfile && onAddFriend && (
|
||||
<div style={{ marginLeft: 'auto' }}>
|
||||
<Button
|
||||
variant={friendRequestSent ? 'secondary' : 'primary'}
|
||||
onClick={onAddFriend}
|
||||
disabled={friendRequestSent}
|
||||
size="sm"
|
||||
icon={<UserPlus size={16} />}
|
||||
>
|
||||
{friendRequestSent ? 'Request Sent' : 'Add Friend'}
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</ProfileHero>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user