feat: add node calssification

This commit is contained in:
2026-03-10 21:34:39 +01:00
parent eed880e7ef
commit 87c46c25c6
8 changed files with 79 additions and 19 deletions

View File

@@ -30,6 +30,7 @@ import {
ContextMenu,
ContextMenuContent,
ContextMenuItem,
ContextMenuLabel,
ContextMenuSeparator,
ContextMenuSub,
ContextMenuSubContent,
@@ -52,6 +53,7 @@ import { ClipboardPaste, FolderOpen, FileStack, CircleDotDashed } from 'lucide-r
import { DEFAULT_NODE_STYLE, getDefaultDataForType, getNextNodeId } from '@/lib/flowUtils'
import {
getRegisteredNodeTypes,
getRegisteredNodeTypesGroupedByClassification,
getRegisteredNodeTypeIds,
getDefaultStyle,
isConnectionAllowed,
@@ -594,17 +596,25 @@ export function CanvasPage({ projectId }: CanvasPageProps) {
<ContextMenuSub>
<ContextMenuSubTrigger>Create Node</ContextMenuSubTrigger>
<ContextMenuSubContent className="w-44">
<ContextMenuGroup>
{getRegisteredNodeTypes().map((desc, index) => (
<React.Fragment key={desc.id}>
{index === 2 ? <ContextMenuSeparator /> : null}
<ContextMenuItem onSelect={() => createNode(desc.id)}>
{desc.menuIcon}
{desc.menuLabel}
</ContextMenuItem>
</React.Fragment>
))}
</ContextMenuGroup>
{getRegisteredNodeTypesGroupedByClassification().map(
(group, groupIndex) =>
group.types.length > 0 && (
<React.Fragment key={group.classification}>
{groupIndex > 0 && <ContextMenuSeparator />}
<ContextMenuGroup>
<ContextMenuLabel className="text-muted-foreground">
{group.label}
</ContextMenuLabel>
{group.types.map((desc) => (
<ContextMenuItem key={desc.id} onSelect={() => createNode(desc.id)}>
{desc.menuIcon}
{desc.menuLabel}
</ContextMenuItem>
))}
</ContextMenuGroup>
</React.Fragment>
)
)}
</ContextMenuSubContent>
</ContextMenuSub>
<ContextMenuSeparator />

View File

@@ -21,7 +21,7 @@ import { Plus, ListTodo } from 'lucide-react'
import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip'
import { useSidebar } from '@/components/ui/sidebar'
import { usePlatform } from './platformContext'
import { getProjectIcon } from './icon-map'
import { getProjectIcon } from '../../lib/iconMap'
import { NewProjectDialog } from './NewProjectDialog'
import type { Project } from './types'
@@ -132,7 +132,7 @@ export function AppSidebar() {
<SidebarMenuButton asChild tooltip="All projects" isActive={!selectedProjectId}>
<Link to="/projects">
<ListTodo className="size-4" />
<span>All projects</span>
<span>Pleroma</span>
</Link>
</SidebarMenuButton>
</SidebarMenuItem>

View File

@@ -17,7 +17,7 @@ import { Input } from '@/components/ui/input'
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select'
import { Plus } from 'lucide-react'
import { PROJECT_ICON_IDS, type Project, type ProjectIconId } from './types'
import { getProjectIcon } from './icon-map'
import { getProjectIcon } from '../../lib/iconMap'
type NewProjectDialogProps = {
onCreate: (project: Project) => void

View File

@@ -49,7 +49,7 @@ import {
Network,
} from 'lucide-react'
import { usePlatform } from './platformContext'
import { getProjectIcon } from './icon-map'
import { getProjectIcon } from '../../lib/iconMap'
import {
loadGraphFromStorage,
removeGraphFromStorage,
@@ -319,7 +319,7 @@ export function ProjectsPage() {
<TooltipProvider>
<div className="flex flex-wrap items-center gap-3">
<h1 className="p-3 scroll-m-20 text-4xl font-extrabold tracking-tight text-balance">
Hi, David
Hi, Demiurge
</h1>
</div>
<div className="flex flex-col gap-4 rounded-lg border bg-card p-4 text-card-foreground shadow-sm">
@@ -393,7 +393,7 @@ export function ProjectsPage() {
onKeyDown={(e) => {
if (e.key === 'Enter' || e.key === ' ') {
e.preventDefault()
;(e.currentTarget as HTMLElement).click()
; (e.currentTarget as HTMLElement).click()
}
}}
aria-label="Create new project"

View File

@@ -1,40 +0,0 @@
/**
* Map project icon ids to Lucide icons for the sidebar.
* Only Lucide "Animals" category icons are allowed for projects.
*/
import {
Bird,
Bug,
Cat,
Dog,
Egg,
Fish,
Rabbit,
Rat,
Shrimp,
Snail,
Squirrel,
Turtle,
type LucideIcon,
} from 'lucide-react'
import type { ProjectIconId } from './types'
export const PROJECT_ICON_MAP: Record<ProjectIconId, LucideIcon> = {
bird: Bird,
bug: Bug,
cat: Cat,
dog: Dog,
fish: Fish,
rat: Rat,
rabbit: Rabbit,
squirrel: Squirrel,
turtle: Turtle,
snail: Snail,
shrimp: Shrimp,
egg: Egg
}
export function getProjectIcon(iconId: string): LucideIcon {
return PROJECT_ICON_MAP[iconId as ProjectIconId] ?? Cat
}