Files
multica/packages/views/projects/components/project-icon.tsx
Naiyuan Qing e268ee3e71 refactor(views): centralize project icon rendering and fix nav active state (#1738)
Extract <ProjectIcon> with sm/md/lg sizes and a single 📁 fallback,
replacing 9 inline render sites that had drifted into 6 different
sizes and a mixed FolderKanban/emoji fallback.

Two visible fixes fall out of the centralization:
- ProjectPicker trigger now shows the selected project's icon (most
  visibly in the issue detail right Properties panel, where it had
  always been a generic FolderKanban).
- Sidebar parent nav (Projects, Issues, Settings, ...) now stays
  highlighted on child detail routes via a small isNavActive helper.
  Pinned items keep strict equality.

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-27 14:42:56 +08:00

32 lines
772 B
TypeScript

import type { Project } from "@multica/core/types";
import { cn } from "@multica/ui/lib/utils";
export type ProjectIconSize = "sm" | "md" | "lg";
export interface ProjectIconProps {
project?: Pick<Project, "icon"> | null;
size?: ProjectIconSize;
className?: string;
}
const SIZE_CLASS: Record<ProjectIconSize, string> = {
sm: "size-3.5 text-xs leading-none",
md: "size-4 text-sm leading-none",
lg: "size-6 text-2xl leading-none",
};
export function ProjectIcon({ project, size = "sm", className }: ProjectIconProps) {
return (
<span
aria-hidden="true"
className={cn(
"inline-flex shrink-0 items-center justify-center",
SIZE_CLASS[size],
className,
)}
>
{project?.icon || "📁"}
</span>
);
}