forked from rajun/ar-test
feat: add project card
This commit is contained in:
parent
db2b168521
commit
aaebb28a23
47
app/components/projects/list/project-card.tsx
Normal file
47
app/components/projects/list/project-card.tsx
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
import { memo } from 'react';
|
||||||
|
import { Link } from 'react-router';
|
||||||
|
import { Pencil } from 'lucide-react';
|
||||||
|
import { Badge } from '~/components/ui/badge';
|
||||||
|
import { Button } from '~/components/ui/button';
|
||||||
|
import { Card } from '~/components/ui/card';
|
||||||
|
import { LogoTile } from '~/components/ui/logo-tile';
|
||||||
|
import { Text } from '~/components/ui/text';
|
||||||
|
import { ROUTES } from '~/data/routes';
|
||||||
|
import { formatDate } from '~/lib/format';
|
||||||
|
import { toBrand } from '~/services/asset-media';
|
||||||
|
import type { Project, ProjectSummary } from '~/types/project';
|
||||||
|
|
||||||
|
interface ProjectCardProps {
|
||||||
|
project: ProjectSummary;
|
||||||
|
onEdit: (project: Project) => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const ProjectCard = memo(function ProjectCard({ project, onEdit }: ProjectCardProps) {
|
||||||
|
return (
|
||||||
|
<Card interactive className='relative flex flex-col gap-3.5 p-3'>
|
||||||
|
<LogoTile brand={toBrand(project)} size='card'>
|
||||||
|
{!project.logo && (
|
||||||
|
<Badge tone='light' className='absolute top-2.5 right-2.5'>
|
||||||
|
<Text as='span' variant='stamp' tone='inherit'>No logo · text fallback</Text>
|
||||||
|
</Badge>
|
||||||
|
)}
|
||||||
|
</LogoTile>
|
||||||
|
<div className='flex items-center justify-between gap-2.5 px-0.5 pb-0.5'>
|
||||||
|
<div className='flex min-w-0 flex-col gap-1'>
|
||||||
|
<div className='flex min-w-0 items-center gap-2'>
|
||||||
|
<Link to={ROUTES.project(project.id)} className='min-w-0 after:absolute after:inset-0'>
|
||||||
|
<Text as='h3' variant='heading' truncate>{project.name}</Text>
|
||||||
|
</Link>
|
||||||
|
{project.status === 'archived' && <Badge>Archived</Badge>}
|
||||||
|
</div>
|
||||||
|
<Text variant='caption'>
|
||||||
|
{project.assetCount} {project.assetCount === 1 ? 'asset' : 'assets'} · {formatDate(project.created)}
|
||||||
|
</Text>
|
||||||
|
</div>
|
||||||
|
<Button variant='ghost' size='icon' className='relative z-10' aria-label={`Edit ${project.name}`} onClick={() => onEdit(project)}>
|
||||||
|
<Pencil size={14} />
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</Card>
|
||||||
|
);
|
||||||
|
});
|
||||||
Loading…
x
Reference in New Issue
Block a user