⚡ 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 { Check, ChevronsUpDown, Plus } from "lucide-react";
import { useState } from "react";
import { useTranslation } from "react-i18next";
import { Button } from "@/components/ui/button";
import {
Popover,
PopoverContent,
PopoverTrigger,
} from "@/components/ui/popover";
import icons from "@/constants/project-icons";
import useGetProjects from "@/hooks/queries/project/use-get-projects";
import { cn } from "@/lib/cn";
type MobileProjectNavProps = {
workspaceId: string;
projectId: string;
projectName?: string;
onSelectProject: (projectId: string) => void;
onAddProject: () => void;
};
export default function MobileProjectNav({
workspaceId,
projectId,
projectName,
onSelectProject,
onAddProject,
}: MobileProjectNavProps) {
const { t } = useTranslation();
const [open, setOpen] = useState(false);
const { data: projects = [] } = useGetProjects({ workspaceId });
const currentProject = projects?.find((project) => project.id === projectId);
const CurrentIcon =
icons[currentProject?.icon as keyof typeof icons] || icons.Layout;
const select = (action: () => void) => () => {
setOpen(false);
action();
};
return (
<Popover open={open} onOpenChange={setOpen}>
<PopoverTrigger
render={
<Button
variant="ghost"
size="sm"
aria-label={t("navigation:projectList.switcherLabel")}
className="h-8 min-w-0 max-w-full gap-1.5 px-2"
/>
}
>
<CurrentIcon className="size-4 shrink-0" />
<span className="truncate font-medium text-sm">
{projectName ?? currentProject?.name}
</span>
<ChevronsUpDown className="size-3.5 shrink-0 text-muted-foreground" />
</PopoverTrigger>
<PopoverContent align="start" className="w-72 p-2">
<div className="space-y-3">
<div className="space-y-1">
<p className="px-1 text-[11px] font-medium tracking-wide text-muted-foreground uppercase">
{t("navigation:sidebar.projects")}
</p>
<div className="max-h-56 space-y-0.5 overflow-y-auto">
{(projects ?? []).map((project) => {
const Icon =
icons[project.icon as keyof typeof icons] || icons.Layout;
const isCurrentProject = project.id === projectId;
return (
<button
key={project.id}
type="button"
onClick={select(() => onSelectProject(project.id))}
className={cn(
"flex h-10 w-full items-center gap-2 rounded-md px-2.5 text-left text-sm transition-colors",
isCurrentProject
? "bg-accent text-foreground"
: "text-muted-foreground hover:bg-accent hover:text-foreground",
)}
>
<Icon className="size-4 shrink-0" />
<span className="flex-1 truncate">{project.name}</span>
{isCurrentProject && <Check className="size-4" />}
</button>
);
})}
</div>
</div>
<button
type="button"
onClick={select(onAddProject)}
className="flex h-10 w-full items-center gap-2 rounded-md border border-border px-2.5 text-left text-sm text-foreground transition-colors hover:bg-accent"
>
<Plus className="size-4" />
{t("navigation:projectList.addProject")}
</button>
</div>
</PopoverContent>
</Popover>
);
}