⚡ Project management that doesn't become the project. Boards, Gantt charts, and GitHub integration. Self-host it or use Kaneo Cloud.
TypeScript honoissue-managementissue-trackerjira-alternativekanbanlinear-alternativemcpproject-managementreactself-hostedtypescript
import { Link } from "@tanstack/react-router";
import { Plus } from "lucide-react";
import { useTranslation } from "react-i18next";
import { Button } from "@/components/ui/button";
import { Skeleton } from "@/components/ui/skeleton";
import icons from "@/constants/project-icons";
import useGetProjects from "@/hooks/queries/project/use-get-projects";
import { useBoardHoverPrefetch } from "@/hooks/use-board-hover-prefetch";
import { SectionHeader } from "./section-header";
type HomeProjectsProps = {
workspaceId: string;
onCreateProject?: () => void;
};
const VISIBLE_PROJECTS = 3;
export function HomeProjects({
workspaceId,
onCreateProject,
}: HomeProjectsProps) {
const { t } = useTranslation();
const {
data: projects,
isPending,
isError,
} = useGetProjects({ workspaceId }, true);
const boardHoverPrefetch = useBoardHoverPrefetch(workspaceId);
return (
<section className="flex flex-col gap-3">
<SectionHeader
title={t("workspace:home.projects.title")}
action={
<Link
to="/dashboard/workspace/$workspaceId/projects"
params={{ workspaceId }}
className="shrink-0 font-medium text-[13px] text-muted-foreground hover:text-foreground"
>
{t("workspace:home.projects.all")}
</Link>
}
/>
{isPending ? (
<div className="delayed-reveal">
<Skeleton
aria-label={t("common:empty.loading")}
className="h-28 w-full"
/>
</div>
) : isError && !projects ? (
<p role="alert" className="text-muted-foreground text-sm">
{t("workspace:home.projects.loadError")}
</p>
) : !projects?.length ? (
<div className="flex flex-col items-start gap-3 rounded-lg border border-border bg-card p-5">
<div className="flex flex-col gap-1">
<p className="font-medium text-foreground text-sm">
{t("workspace:projects.emptyTitle")}
</p>
<p className="text-muted-foreground text-sm">
{onCreateProject
? t("workspace:projects.emptyDescription")
: t("workspace:projects.emptyDescriptionReadOnly")}
</p>
</div>
{onCreateProject ? (
<Button size="sm" variant="outline" onClick={onCreateProject}>
<Plus />
{t("workspace:projects.createProject")}
</Button>
) : null}
</div>
) : (
<div className="grid gap-3 sm:grid-cols-3">
{projects.slice(0, VISIBLE_PROJECTS).map((project) => {
const ProjectIcon =
icons[project.icon as keyof typeof icons] || icons.Layout;
const { completionPercentage, totalTasks } = project.statistics;
return (
<Link
key={project.id}
to="/dashboard/workspace/$workspaceId/project/$projectId/board"
params={{ workspaceId, projectId: project.id }}
{...boardHoverPrefetch(project.id)}
className="flex flex-col gap-3.5 rounded-lg border border-border p-3.5 outline-none transition-colors hover:bg-accent/40 focus-visible:ring-2 focus-visible:ring-ring"
>
<div className="flex items-center gap-2">
<ProjectIcon
aria-hidden="true"
className="size-4 shrink-0 text-muted-foreground"
/>
<span className="min-w-0 flex-1 truncate font-medium text-foreground text-sm">
{project.name}
</span>
<span className="text-muted-foreground text-xs tabular-nums">
{completionPercentage}%
</span>
</div>
<div className="h-1 overflow-hidden rounded-full bg-muted">
<div
className="h-full rounded-full bg-foreground/80"
style={{ width: `${completionPercentage}%` }}
/>
</div>
<span className="text-muted-foreground text-xs">
{t("workspace:home.projects.tasks", { count: totalTasks })}
</span>
</Link>
);
})}
</div>
)}
</section>
);
}