freat: renaming

This commit is contained in:
2026-03-15 14:11:11 +01:00
parent 2326bbe035
commit 04c039bdde
18 changed files with 455 additions and 462 deletions

View File

@@ -1,5 +1,5 @@
/**
* Platform sidebar: All projects, Recently used, New project.
* Platform sidebar: Recollections, Recently used, New recollection.
*/
import React, { useCallback, useMemo } from 'react'
@@ -21,32 +21,30 @@ import { Plus, Settings, Triangle } from 'lucide-react'
import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip'
import { useSidebar } from '@/components/ui/sidebar'
import { usePlatform } from './KosmosContext'
import { getProjectIcon } from '@/lib/iconMap'
import { NewProjectDialog } from './NewProjectDialog'
import { getRecollectionIcon } from '@/lib/iconMap'
import { NewRecollectionDialog } from './NewRecollectionDialog'
import { SettingsDialog } from './SettingsDialog'
import type { Project } from './types'
import type { Recollection } from './types'
export function KosmosSidebar() {
const { state, setOpen } = useSidebar()
const isCollapsed = state === 'collapsed'
const { orderedProjects, createProject, recentProjectIds } = usePlatform()
const recentProjects = useMemo(() => {
const byId = new Map(orderedProjects.map((p) => [p.id, p]))
return recentProjectIds.map((id) => byId.get(id)).filter((p): p is Project => p != null)
}, [orderedProjects, recentProjectIds])
const { orderedRecollections, createRecollection, recentRecollectionIds } = usePlatform()
const recentRecollections = useMemo(() => {
const byId = new Map(orderedRecollections.map((p) => [p.id, p]))
return recentRecollectionIds.map((id) => byId.get(id)).filter((p): p is Recollection => p != null)
}, [orderedRecollections, recentRecollectionIds])
const navigate = useNavigate()
const location = useLocation()
const { projectId: selectedProjectId } = useParams<{ projectId: string }>()
const isKeroma = location.pathname === '/keroma'
const { recollectionId: selectedRecollectionId } = useParams<{ recollectionId: string }>()
const handleSelectRecollection = useCallback((id: string) => navigate(`/recollections/${id}`), [navigate])
const handleSelectProject = useCallback((id: string) => navigate(`/projects/${id}`), [navigate])
const handleCreateProject = useCallback(
(project: Parameters<typeof createProject>[0]) => {
createProject(project)
navigate(`/projects/${project.id}`)
const handleCreateRecollection = useCallback(
(recollection: Parameters<typeof createRecollection>[0]) => {
createRecollection(recollection)
navigate(`/recollections/${recollection.id}`)
},
[createProject, navigate]
[createRecollection, navigate]
)
return (
@@ -99,7 +97,7 @@ export function KosmosSidebar() {
</Tooltip>
) : (
<SidebarMenuButton asChild size="lg" tooltip="Zoë" className="font-semibold font-serif">
<Link to="/projects">
<Link to="/recollections">
<span className="flex size-8 min-w-8 items-center justify-center rounded-lg bg-sidebar-primary text-sidebar-primary-foreground dark:bg-white dark:text-black">
<span
className="size-6 shrink-0 rounded-[2px] opacity-90"
@@ -132,39 +130,31 @@ export function KosmosSidebar() {
<SidebarGroup>
<SidebarMenu>
<SidebarMenuItem>
<SidebarMenuButton asChild tooltip="All projects" isActive={location.pathname === '/projects' && !selectedProjectId}>
<Link to="/projects">
<SidebarMenuButton asChild tooltip="Recollections" isActive={location.pathname === '/recollections' && !selectedRecollectionId}>
<Link to="/recollections">
<Triangle className="size-4" />
<span>Pleroma</span>
</Link>
</SidebarMenuButton>
</SidebarMenuItem>
<SidebarMenuItem>
<SidebarMenuButton asChild tooltip="Keroma" isActive={isKeroma}>
<Link to="/keroma">
<Triangle className="size-4 rotate-180" />
<span>Keroma</span>
<span>Recollections</span>
</Link>
</SidebarMenuButton>
</SidebarMenuItem>
</SidebarMenu>
</SidebarGroup>
{recentProjects.length > 0 && (
{recentRecollections.length > 0 && (
<SidebarGroup>
<SidebarGroupLabel className="group-data-[collapsible=icon]:hidden">Recently used</SidebarGroupLabel>
<SidebarMenu>
{recentProjects.map((project) => {
const Icon = getProjectIcon(project.iconId)
const isActive = selectedProjectId === project.id
{recentRecollections.map((recollection) => {
const Icon = getRecollectionIcon(recollection.iconId)
const isActive = selectedRecollectionId === recollection.id
return (
<SidebarMenuItem key={project.id}>
<SidebarMenuItem key={recollection.id}>
<SidebarMenuButton
tooltip={project.name}
tooltip={recollection.name}
isActive={isActive}
onClick={() => handleSelectProject(project.id)}
onClick={() => handleSelectRecollection(recollection.id)}
>
<Icon className="size-4" />
<span>{project.name}</span>
<span>{recollection.name}</span>
</SidebarMenuButton>
</SidebarMenuItem>
)
@@ -175,13 +165,13 @@ export function KosmosSidebar() {
<SidebarGroup>
<SidebarMenu>
<SidebarMenuItem>
<NewProjectDialog
onCreate={handleCreateProject}
existingNames={orderedProjects.map((p) => p.name)}
<NewRecollectionDialog
onCreate={handleCreateRecollection}
existingNames={orderedRecollections.map((p) => p.name)}
trigger={
<SidebarMenuButton className="text-sidebar-foreground/70 w-full cursor-pointer">
<Plus className="size-4" />
<span>{orderedProjects.length === 0 ? 'Create your first project' : 'New project'}</span>
<span>{orderedRecollections.length === 0 ? 'Create your first recollection' : 'New recollection'}</span>
</SidebarMenuButton>
}
/>