diff --git a/src/components/ProjectDetailsDialog.tsx b/src/components/ProjectDetailsDialog.tsx index 6ce4a5fe..c728f898 100644 --- a/src/components/ProjectDetailsDialog.tsx +++ b/src/components/ProjectDetailsDialog.tsx @@ -40,6 +40,7 @@ import { import JSZip from 'jszip'; import { Separator } from './ui/separator'; import { DotAI } from '@/lib/DotAI'; +import { LabelSelector } from '@/components/labels/LabelSelector'; interface ProjectDetailsDialogProps { project: Project; @@ -244,7 +245,7 @@ export function ProjectDetailsDialog({ project, open, onOpenChange, onProjectDel e.preventDefault()}> - + {project.name} @@ -262,7 +263,7 @@ export function ProjectDetailsDialog({ project, open, onOpenChange, onProjectDel
Total Cost: - ${totalCost.toFixed(6)} + ${totalCost.toFixed(2)}
)} @@ -317,6 +318,9 @@ export function ProjectDetailsDialog({ project, open, onOpenChange, onProjectDel + {/* Labels */} + + {/* Export Project Button */} diff --git a/src/components/ProjectSidebar.tsx b/src/components/ProjectSidebar.tsx index f2cd9c7d..108f5f5a 100644 --- a/src/components/ProjectSidebar.tsx +++ b/src/components/ProjectSidebar.tsx @@ -1,28 +1,40 @@ import React, { useEffect, useState, useMemo } from 'react'; import { useNavigate } from 'react-router-dom'; import { useTranslation } from 'react-i18next'; -import { Plus, Folder, GitBranch, Loader2, ChevronDown, Star, Columns2, X, Settings, HelpCircle, Search } from 'lucide-react'; +import { Plus, Folder, GitBranch, Loader2, ChevronDown, ChevronRight, Star, Columns2, X, Settings, HelpCircle, Search, Tag, Folders } from 'lucide-react'; import { Button } from '@/components/ui/button'; import { Skeleton } from '@/components/ui/skeleton'; import { Input } from '@/components/ui/input'; import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger } from '@/components/ui/dropdown-menu'; +import { Collapsible, CollapsibleContent, CollapsibleTrigger } from '@/components/ui/collapsible'; import { useProjects } from '@/hooks/useProjects'; import { useProjectSessionStatus } from '@/hooks/useProjectSessionStatus'; import { useLocalStorage } from '@/hooks/useLocalStorage'; import { useIsMobile } from '@/hooks/useIsMobile'; +import { useLabels } from '@/hooks/useLabels'; +import { getLabelColor } from '@/lib/labels'; +import { useProjectLabels } from '@/hooks/useProjectLabels'; import type { Project } from '@/lib/ProjectsManager'; import { cn } from '@/lib/utils'; import { useQueryClient } from '@tanstack/react-query'; import { ShakespeareLogo } from '@/components/ShakespeareLogo'; +import { LabelsManageDialog } from '@/components/labels/LabelsManageDialog'; interface ProjectItemProps { project: Project; isSelected: boolean; onSelect: (project: Project) => void; isFavorite?: boolean; + labelColor?: string; } -const ProjectItem: React.FC = ({ project, isSelected, onSelect, isFavorite }) => { +const ProjectItem: React.FC = ({ + project, + isSelected, + onSelect, + isFavorite, + labelColor, +}) => { const navigate = useNavigate(); const { hasRunningSessions } = useProjectSessionStatus(project.id); @@ -31,6 +43,15 @@ const ProjectItem: React.FC = ({ project, isSelected, onSelect navigate(`/project/${project.id}`); }; + // Determine folder icon color - always show colored icons when label exists + const getFolderColorClass = () => { + if (labelColor) { + const colorConfig = getLabelColor(labelColor as Parameters[0]); + return colorConfig.text; + } + return 'text-primary'; + }; + return (
= ({ project, isSelected, onSelect {hasRunningSessions ? ( ) : ( - + )}
@@ -60,10 +81,8 @@ const ProjectItem: React.FC = ({ project, isSelected, onSelect {/* Star indicator - only shown when favorited */} {isFavorite && ( -
-
- -
+
+
)}
@@ -75,6 +94,78 @@ const ProjectItem: React.FC = ({ project, isSelected, onSelect ProjectItem.displayName = 'ProjectItem'; +/** Label group header component */ +interface LabelGroupHeaderProps { + labelName: string; + labelColor: string; + isCollapsed: boolean; + onToggle: () => void; + projectCount?: number; +} + +const LabelGroupHeader: React.FC = ({ + labelName, + labelColor, + isCollapsed, + onToggle, + projectCount = 0, +}) => { + const colorConfig = getLabelColor(labelColor as Parameters[0]); + + return ( + + ); +}; + +/** Other projects group header component */ +interface OtherProjectsGroupHeaderProps { + isCollapsed: boolean; + onToggle: () => void; + projectCount?: number; +} + +const OtherProjectsGroupHeader: React.FC = ({ + isCollapsed, + onToggle, + projectCount = 0, +}) => { + const { t } = useTranslation(); + + return ( + + ); +}; + interface ProjectSidebarProps { selectedProject: Project | null; onSelectProject: (project: Project | null) => void; @@ -95,10 +186,17 @@ export function ProjectSidebar({ const { data: projects = [], isLoading, error } = useProjects(); const [favorites] = useLocalStorage('project-favorites', []); const [searchQuery, setSearchQuery] = useState(''); + const [otherProjectsCollapsed, setOtherProjectsCollapsed] = useLocalStorage('other-projects-collapsed', false); + const [labelsDialogOpen, setLabelsDialogOpen] = useState(false); + const { labels, toggleLabelCollapsed } = useLabels(); + const { getProjectLabels, hasAnyLabels } = useProjectLabels(); const isMobile = useIsMobile(); const navigate = useNavigate(); + // Always show grouped view when labels exist and projects have labels + const showGroupedView = labels.length > 0 && hasAnyLabels(); + // Fast in-memory search filtering const filteredProjects = useMemo(() => { if (!searchQuery.trim()) { @@ -112,6 +210,69 @@ export function ProjectSidebar({ ); }, [projects, searchQuery]); + // Group projects by label for grouped view + const groupedProjects = useMemo(() => { + if (!showGroupedView) return null; + + const groups: Map = new Map(); + const unlabeled: Project[] = []; + + // Initialize groups for each label in order + for (const label of labels) { + groups.set(label.id, []); + } + + // Sort projects into groups + for (const project of filteredProjects) { + const projectLabelIds = getProjectLabels(project.id); + if (projectLabelIds.length === 0) { + unlabeled.push(project); + } else { + // Add project to each label group it belongs to + let addedToAnyGroup = false; + for (const labelId of projectLabelIds) { + const group = groups.get(labelId); + if (group) { + group.push(project); + addedToAnyGroup = true; + } + } + // If all labels were deleted, add to unlabeled + if (!addedToAnyGroup) { + unlabeled.push(project); + } + } + } + + // Sort each group: favorites first, then by lastModified + const sortGroup = (projectList: Project[]) => { + return projectList.sort((a, b) => { + const aIsFavorite = favorites.includes(a.id); + const bIsFavorite = favorites.includes(b.id); + if (aIsFavorite && !bIsFavorite) return -1; + if (!aIsFavorite && bIsFavorite) return 1; + return b.lastModified.getTime() - a.lastModified.getTime(); + }); + }; + + for (const [labelId, projectList] of groups) { + groups.set(labelId, sortGroup(projectList)); + } + + return { + groups, + unlabeled: sortGroup(unlabeled), + }; + }, [showGroupedView, labels, filteredProjects, getProjectLabels, favorites]); + + // Get the first label color for a project (for colored icon display) + const getProjectLabelColor = (projectId: string): string | undefined => { + const projectLabelIds = getProjectLabels(projectId); + if (projectLabelIds.length === 0) return undefined; + const label = labels.find(l => l.id === projectLabelIds[0]); + return label?.color; + }; + // Custom navigate function that closes sidebar on mobile const navigateAndClose = (path: string) => { navigate(path); @@ -206,6 +367,13 @@ export function ProjectSidebar({ {t('importRepository')} + setLabelsDialogOpen(true)} + className="flex items-center gap-2 w-full" + > + + {t('manageLabels')} +
@@ -249,7 +417,84 @@ export function ProjectSidebar({

{t('noProjectsFound')}

{t('tryDifferentSearch')}

+ ) : showGroupedView && groupedProjects ? ( + // Grouped view by labels +
+ {/* Render each label group */} + {labels.map((label) => { + const groupProjects = groupedProjects.groups.get(label.id) || []; + if (groupProjects.length === 0) return null; + + return ( + toggleLabelCollapsed(label.id)} + > + +
+ toggleLabelCollapsed(label.id)} + projectCount={groupProjects.length} + /> +
+
+ +
+ {groupProjects.map((project) => ( + + ))} +
+
+
+ ); + })} + + {/* Other projects (unlabeled) */} + {groupedProjects.unlabeled.length > 0 && ( +
+ setOtherProjectsCollapsed(!otherProjectsCollapsed)} + > + +
+ setOtherProjectsCollapsed(!otherProjectsCollapsed)} + projectCount={groupedProjects.unlabeled.length} + /> +
+
+ +
+ {groupedProjects.unlabeled.map((project) => ( + + ))} +
+
+
+
+ )} +
) : ( + // Flat view (default)
{filteredProjects.map((project) => ( ))}
@@ -288,6 +534,12 @@ export function ProjectSidebar({ + + {/* Labels Management Dialog */} + ); } \ No newline at end of file diff --git a/src/components/labels/LabelSelector.tsx b/src/components/labels/LabelSelector.tsx new file mode 100644 index 00000000..94efbb3f --- /dev/null +++ b/src/components/labels/LabelSelector.tsx @@ -0,0 +1,239 @@ +import { useState } from 'react'; +import { useTranslation } from 'react-i18next'; +import { Check, Plus, Tag, X, Settings } from 'lucide-react'; +import { Button } from '@/components/ui/button'; +import { + Popover, + PopoverContent, + PopoverTrigger, +} from '@/components/ui/popover'; +import { ScrollArea } from '@/components/ui/scroll-area'; +import { Separator } from '@/components/ui/separator'; +import { Input } from '@/components/ui/input'; +import { useLabels } from '@/hooks/useLabels'; +import { getLabelColor, LABEL_COLORS, type Label, type LabelColorName } from '@/lib/labels'; +import { useProjectLabels } from '@/hooks/useProjectLabels'; +import { LabelsManageDialog } from './LabelsManageDialog'; +import { cn } from '@/lib/utils'; + +interface LabelSelectorProps { + projectId: string; + /** Render as a compact badge list (for inline display) */ + compact?: boolean; +} + +const getRandomColor = (): LabelColorName => { + const randomIndex = Math.floor(Math.random() * LABEL_COLORS.length); + return LABEL_COLORS[randomIndex].name; +}; + +export function LabelSelector({ projectId, compact }: LabelSelectorProps) { + const { t } = useTranslation(); + const { labels, createLabel } = useLabels(); + const { getProjectLabels, addLabelToProject, removeLabelFromProject } = useProjectLabels(); + const [open, setOpen] = useState(false); + const [manageDialogOpen, setManageDialogOpen] = useState(false); + const [showCreateForm, setShowCreateForm] = useState(false); + const [newLabelName, setNewLabelName] = useState(''); + const [selectedColor, setSelectedColor] = useState(getRandomColor()); + + const projectLabelIds = getProjectLabels(projectId); + const projectLabels = labels.filter(label => projectLabelIds.includes(label.id)); + + const handleToggleLabel = (label: Label) => { + if (projectLabelIds.includes(label.id)) { + removeLabelFromProject(projectId, label.id); + } else { + addLabelToProject(projectId, label.id); + } + }; + + const handleCreateLabel = () => { + if (!newLabelName.trim()) return; + + const newLabel = createLabel(newLabelName.trim(), selectedColor); + addLabelToProject(projectId, newLabel.id); + + // Reset form + setNewLabelName(''); + setSelectedColor(getRandomColor()); + setShowCreateForm(false); + }; + + const handleCancelCreate = () => { + setNewLabelName(''); + setSelectedColor(getRandomColor()); + setShowCreateForm(false); + }; + + if (compact) { + return ( +
+ {projectLabels.map((label) => { + const colorConfig = getLabelColor(label.color); + return ( + + {label.name} + + ); + })} +
+ ); + } + + return ( + <> + + + + + +
+

+ {t('selectLabels')} +

+
+ + {labels.length > 0 ? ( + +
+ {labels.map((label) => { + const colorConfig = getLabelColor(label.color); + const isSelected = projectLabelIds.includes(label.id); + return ( + + ); + })} +
+
+ ) : ( +
+ {t('noLabelsCreated')} +
+ )} + + + +
+ {showCreateForm ? ( +
+
+ setNewLabelName(e.target.value)} + onKeyDown={(e) => { + if (e.key === 'Enter') { + handleCreateLabel(); + } else if (e.key === 'Escape') { + handleCancelCreate(); + } + }} + className="flex-1 h-8" + autoFocus + /> + +
+ +
+ {LABEL_COLORS.map((color) => ( +
+ + +
+ ) : ( + + )} + +
+
+
+ + + + ); +} diff --git a/src/components/labels/LabelsManageDialog.tsx b/src/components/labels/LabelsManageDialog.tsx new file mode 100644 index 00000000..9b966dd3 --- /dev/null +++ b/src/components/labels/LabelsManageDialog.tsx @@ -0,0 +1,366 @@ +import { useState } from 'react'; +import { useTranslation } from 'react-i18next'; +import { Plus, Trash2, GripVertical, Check } from 'lucide-react'; +import { + DndContext, + closestCenter, + KeyboardSensor, + PointerSensor, + useSensor, + useSensors, + type DragEndEvent, +} from '@dnd-kit/core'; +import { + arrayMove, + SortableContext, + sortableKeyboardCoordinates, + useSortable, + verticalListSortingStrategy, +} from '@dnd-kit/sortable'; +import { CSS } from '@dnd-kit/utilities'; +import { + Dialog, + DialogContent, + DialogHeader, + DialogTitle, +} from '@/components/ui/dialog'; +import { Button } from '@/components/ui/button'; +import { Input } from '@/components/ui/input'; +import { Label } from '@/components/ui/label'; +import { ScrollArea } from '@/components/ui/scroll-area'; +import { + Accordion, + AccordionContent, + AccordionItem, + AccordionTrigger, +} from '@/components/ui/accordion'; +import { + AlertDialog, + AlertDialogAction, + AlertDialogCancel, + AlertDialogContent, + AlertDialogDescription, + AlertDialogFooter, + AlertDialogHeader, + AlertDialogTitle, +} from '@/components/ui/alert-dialog'; +import { useLabels } from '@/hooks/useLabels'; +import { LABEL_COLORS, getLabelColor, type LabelColorName, type Label as LabelType } from '@/lib/labels'; +import { useProjectLabels } from '@/hooks/useProjectLabels'; +import { cn } from '@/lib/utils'; + +interface LabelsManageDialogProps { + open: boolean; + onOpenChange: (open: boolean) => void; +} + +interface SortableLabelItemProps { + label: LabelType; + onUpdate: (name: string, color: LabelColorName) => void; + onDelete: () => void; + projectCount: number; +} + +function SortableLabelItem({ label, onUpdate, onDelete, projectCount }: SortableLabelItemProps) { + const { t } = useTranslation(); + const colorConfig = getLabelColor(label.color); + const [name, setName] = useState(label.name); + const [color, setColor] = useState(label.color); + + const { + attributes, + listeners, + setNodeRef, + transform, + transition, + isDragging, + } = useSortable({ id: label.id }); + + const style = { + transform: CSS.Transform.toString(transform), + transition, + }; + + const handleSave = () => { + if (name.trim() && (name !== label.name || color !== label.color)) { + onUpdate(name.trim(), color); + } + }; + + const hasChanges = name.trim() !== label.name || color !== label.color; + + return ( +
+ + +
+ +
+ {label.name} + + {projectCount} {projectCount === 1 ? 'project' : 'projects'} + +
+ + +
+
+ + setName(e.target.value)} + placeholder={t('enterLabelName')} + /> +
+ +
+ +
+ {LABEL_COLORS.map((colorOption) => ( +
+
+ +
+ + +
+
+
+ +
+ ); +} + +function AddLabelItem({ onCreate }: { onCreate: (name: string, color: LabelColorName) => void }) { + const { t } = useTranslation(); + + // Function to get a random color from LABEL_COLORS + const getRandomColor = (): LabelColorName => { + const randomIndex = Math.floor(Math.random() * LABEL_COLORS.length); + return LABEL_COLORS[randomIndex].name; + }; + + const [name, setName] = useState(''); + const [color, setColor] = useState(getRandomColor()); + + const handleCreate = () => { + if (name.trim()) { + onCreate(name.trim(), color); + setName(''); + setColor(getRandomColor()); + } + }; + + return ( + + +
+ + {t('createLabel')} +
+
+ +
+
+ + setName(e.target.value)} + placeholder={t('enterLabelName')} + /> +
+ +
+ +
+ {LABEL_COLORS.map((colorOption) => ( +
+
+ +
+ +
+
+
+
+ ); +} + +export function LabelsManageDialog({ open, onOpenChange }: LabelsManageDialogProps) { + const { t } = useTranslation(); + const { labels, createLabel, updateLabel, deleteLabel, reorderLabels } = useLabels(); + const { getProjectsByLabel, removeLabel: removeLabelFromProjects } = useProjectLabels(); + + const [deletingLabel, setDeletingLabel] = useState(null); + + const sensors = useSensors( + useSensor(PointerSensor, { + activationConstraint: { + distance: 8, + }, + }), + useSensor(KeyboardSensor, { + coordinateGetter: sortableKeyboardCoordinates, + }) + ); + + const handleDragEnd = (event: DragEndEvent) => { + const { active, over } = event; + + if (over && active.id !== over.id) { + const oldIndex = labels.findIndex((label) => label.id === active.id); + const newIndex = labels.findIndex((label) => label.id === over.id); + + const newOrder = arrayMove(labels, oldIndex, newIndex); + reorderLabels(newOrder.map((label) => label.id)); + } + }; + + const handleCreateLabel = (name: string, color: LabelColorName) => { + createLabel(name, color); + }; + + const handleUpdateLabel = (labelId: string) => (name: string, color: LabelColorName) => { + updateLabel(labelId, { name, color }); + }; + + const handleConfirmDelete = () => { + if (deletingLabel) { + // Remove label from all projects first + removeLabelFromProjects(deletingLabel.id); + // Then delete the label itself + deleteLabel(deletingLabel.id); + setDeletingLabel(null); + } + }; + + return ( + <> + + + + + {t('manageLabels')} + + + + + + + l.id)} + strategy={verticalListSortingStrategy} + > + {labels.map((label) => ( + setDeletingLabel(label)} + projectCount={getProjectsByLabel(label.id).length} + /> + ))} + + + + + + + + + + {/* Delete confirmation dialog */} + setDeletingLabel(null)}> + + + {t('deleteLabel')} + + {t('deleteLabelConfirmation', { name: deletingLabel?.name })} + + + + {t('cancel')} + + {t('delete')} + + + + + + ); +} diff --git a/src/components/labels/index.ts b/src/components/labels/index.ts new file mode 100644 index 00000000..ce8a2a70 --- /dev/null +++ b/src/components/labels/index.ts @@ -0,0 +1,2 @@ +export { LabelsManageDialog } from './LabelsManageDialog'; +export { LabelSelector } from './LabelSelector'; diff --git a/src/hooks/useLabels.ts b/src/hooks/useLabels.ts new file mode 100644 index 00000000..5812dac6 --- /dev/null +++ b/src/hooks/useLabels.ts @@ -0,0 +1,51 @@ +import { useLocalStorage } from '@/hooks/useLocalStorage'; +import { generateLabelId, type Label, type LabelColorName } from '@/lib/labels'; + +/** + * Hook for managing labels (creating, editing, deleting labels) + */ +export function useLabels() { + const [labels, setLabels] = useLocalStorage('project-labels', []); + + const createLabel = (name: string, color: LabelColorName): Label => { + const newLabel: Label = { + id: generateLabelId(), + name, + color, + }; + setLabels([...labels, newLabel]); + return newLabel; + }; + + const updateLabel = (labelId: string, updates: Partial>) => { + setLabels(labels.map(label => + label.id === labelId ? { ...label, ...updates } : label + )); + }; + + const deleteLabel = (labelId: string) => { + setLabels(labels.filter(label => label.id !== labelId)); + }; + + const reorderLabels = (orderedIds: string[]) => { + const reordered = orderedIds + .map(id => labels.find(label => label.id === id)) + .filter((label): label is Label => label !== undefined); + setLabels(reordered); + }; + + const toggleLabelCollapsed = (labelId: string) => { + setLabels(labels.map(label => + label.id === labelId ? { ...label, collapsed: !label.collapsed } : label + )); + }; + + return { + labels, + createLabel, + updateLabel, + deleteLabel, + reorderLabels, + toggleLabelCollapsed, + }; +} diff --git a/src/hooks/useProjectLabels.ts b/src/hooks/useProjectLabels.ts new file mode 100644 index 00000000..97cccbaa --- /dev/null +++ b/src/hooks/useProjectLabels.ts @@ -0,0 +1,83 @@ +import { useLocalStorage } from '@/hooks/useLocalStorage'; + +/** Map of project IDs to their assigned label IDs */ +type ProjectLabelsMap = Record; + +/** + * Hook for managing project-label associations + */ +export function useProjectLabels() { + const [projectLabels, setProjectLabels] = useLocalStorage('project-label-assignments', {}); + + const getProjectLabels = (projectId: string): string[] => { + return projectLabels[projectId] || []; + }; + + const addLabelToProject = (projectId: string, labelId: string) => { + const currentLabels = projectLabels[projectId] || []; + if (!currentLabels.includes(labelId)) { + setProjectLabels({ + ...projectLabels, + [projectId]: [...currentLabels, labelId], + }); + } + }; + + const removeLabelFromProject = (projectId: string, labelId: string) => { + const currentLabels = projectLabels[projectId] || []; + const newLabels = currentLabels.filter(id => id !== labelId); + if (newLabels.length === 0) { + const { [projectId]: _, ...rest } = projectLabels; + setProjectLabels(rest); + } else { + setProjectLabels({ + ...projectLabels, + [projectId]: newLabels, + }); + } + }; + + const setProjectLabelsList = (projectId: string, labelIds: string[]) => { + if (labelIds.length === 0) { + const { [projectId]: _, ...rest } = projectLabels; + setProjectLabels(rest); + } else { + setProjectLabels({ + ...projectLabels, + [projectId]: labelIds, + }); + } + }; + + const getProjectsByLabel = (labelId: string): string[] => { + return Object.entries(projectLabels) + .filter(([_, labels]) => labels.includes(labelId)) + .map(([projectId]) => projectId); + }; + + const hasAnyLabels = (): boolean => { + return Object.keys(projectLabels).length > 0; + }; + + const removeLabel = (labelId: string) => { + const newProjectLabels: ProjectLabelsMap = {}; + for (const [projectId, labels] of Object.entries(projectLabels)) { + const filtered = labels.filter(id => id !== labelId); + if (filtered.length > 0) { + newProjectLabels[projectId] = filtered; + } + } + setProjectLabels(newProjectLabels); + }; + + return { + projectLabels, + getProjectLabels, + addLabelToProject, + removeLabelFromProject, + setProjectLabelsList, + getProjectsByLabel, + hasAnyLabels, + removeLabel, + }; +} diff --git a/src/lib/labels.ts b/src/lib/labels.ts new file mode 100644 index 00000000..87b30bca --- /dev/null +++ b/src/lib/labels.ts @@ -0,0 +1,40 @@ +/** Predefined label colors */ +export const LABEL_COLORS = [ + { name: 'red', bg: 'bg-red-500', text: 'text-red-500', hover: 'hover:bg-red-500/20' }, + { name: 'orange', bg: 'bg-orange-500', text: 'text-orange-500', hover: 'hover:bg-orange-500/20' }, + { name: 'amber', bg: 'bg-amber-500', text: 'text-amber-500', hover: 'hover:bg-amber-500/20' }, + { name: 'yellow', bg: 'bg-yellow-500', text: 'text-yellow-500', hover: 'hover:bg-yellow-500/20' }, + { name: 'lime', bg: 'bg-lime-500', text: 'text-lime-500', hover: 'hover:bg-lime-500/20' }, + { name: 'green', bg: 'bg-green-500', text: 'text-green-500', hover: 'hover:bg-green-500/20' }, + { name: 'emerald', bg: 'bg-emerald-500', text: 'text-emerald-500', hover: 'hover:bg-emerald-500/20' }, + { name: 'teal', bg: 'bg-teal-500', text: 'text-teal-500', hover: 'hover:bg-teal-500/20' }, + { name: 'cyan', bg: 'bg-cyan-500', text: 'text-cyan-500', hover: 'hover:bg-cyan-500/20' }, + { name: 'sky', bg: 'bg-sky-500', text: 'text-sky-500', hover: 'hover:bg-sky-500/20' }, + { name: 'blue', bg: 'bg-blue-500', text: 'text-blue-500', hover: 'hover:bg-blue-500/20' }, + { name: 'indigo', bg: 'bg-indigo-500', text: 'text-indigo-500', hover: 'hover:bg-indigo-500/20' }, + { name: 'violet', bg: 'bg-violet-500', text: 'text-violet-500', hover: 'hover:bg-violet-500/20' }, + { name: 'purple', bg: 'bg-purple-500', text: 'text-purple-500', hover: 'hover:bg-purple-500/20' }, + { name: 'fuchsia', bg: 'bg-fuchsia-500', text: 'text-fuchsia-500', hover: 'hover:bg-fuchsia-500/20' }, + { name: 'pink', bg: 'bg-pink-500', text: 'text-pink-500', hover: 'hover:bg-pink-500/20' }, + { name: 'rose', bg: 'bg-rose-500', text: 'text-rose-500', hover: 'hover:bg-rose-500/20' }, + { name: 'gray', bg: 'bg-gray-500', text: 'text-gray-500', hover: 'hover:bg-gray-500/20' }, +] as const; + +export type LabelColorName = typeof LABEL_COLORS[number]['name']; + +export interface Label { + id: string; + name: string; + color: LabelColorName; + collapsed?: boolean; +} + +/** Get the color config for a label color name */ +export function getLabelColor(colorName: LabelColorName) { + return LABEL_COLORS.find(c => c.name === colorName) || LABEL_COLORS[0]; +} + +/** Generate a unique label ID */ +export function generateLabelId(): string { + return `label-${Date.now()}-${Math.random().toString(36).substring(2, 7)}`; +} diff --git a/src/locales/en.json b/src/locales/en.json index 6163aa23..92d1c60a 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -544,6 +544,21 @@ "templateDeletedDescription": "Project template '{{name}}' has been deleted.", "noTemplatesConfigured": "No project templates configured yet. Add a template to get started.", "atLeastOneTemplateRequired": "At least one template is required", + "projectLabels": "Project Labels", + "manageLabels": "Manage Labels", + "createLabel": "Create Label", + "labelName": "Label Name", + "enterLabelName": "Enter label name", + "labelColor": "Color", + "deleteLabel": "Delete Label", + "deleteLabelConfirmation": "Are you sure you want to delete the label \"{{name}}\"? This will remove the label from all projects.", + "noLabelsYet": "No labels yet", + "createLabelToOrganize": "Create a label to organize your projects", + "addLabel": "Add label", + "selectLabels": "Select labels", + "noLabelsCreated": "No labels created yet", + "createNewLabel": "Create new label", + "otherProjects": "Other projects", "duplicateProject": "Duplicate Project", "duplicatingProject": "Duplicating project...", "projectDuplicated": "Project duplicated", diff --git a/src/locales/ha.json b/src/locales/ha.json index 789fa9be..5ab28476 100644 --- a/src/locales/ha.json +++ b/src/locales/ha.json @@ -431,6 +431,21 @@ "restoreToDefault": "Mayar da asali", "restoredToDefault": "An Mayar da Asali", "terminal": "Terminal", + "projectLabels": "Lakabi na Aiki", + "manageLabels": "Sarrafa Lakabi", + "createLabel": "Ƙirƙiri Lakabi", + "labelName": "Sunan Lakabi", + "enterLabelName": "Shigar da sunan lakabi", + "labelColor": "Launi", + "deleteLabel": "Goge Lakabi", + "deleteLabelConfirmation": "Ka tabbata kana son goge lakabi \"{{name}}\"? Wannan zai cire lakabi daga duk ayyuka.", + "noLabelsYet": "Babu lakabi tukuna", + "createLabelToOrganize": "Ƙirƙiri lakabi don tsara ayyukanka", + "addLabel": "Ƙara lakabi", + "selectLabels": "Zaɓi lakabi", + "noLabelsCreated": "Ba a ƙirƙiri lakabi tukuna ba", + "createNewLabel": "Ƙirƙiri sabon lakabi", + "otherProjects": "Sauran ayyuka", "discoverPlugins": "Gano Plugins", "discoverPluginsDescription": "Bincika kuma shigar da plugins na Shakespeare da aka raba akan hanyar sadarwa ta Nostr.", "searchPlugins": "Bincika plugins...", diff --git a/src/locales/ig.json b/src/locales/ig.json index 513e2a5c..de1b3bd3 100644 --- a/src/locales/ig.json +++ b/src/locales/ig.json @@ -428,6 +428,21 @@ "restoreToDefault": "Weghachi na nke mbụ", "restoredToDefault": "Weghachiri na Nke Mbụ", "terminal": "Terminal", + "projectLabels": "Akara Ọrụ", + "manageLabels": "Jikwaa Akara", + "createLabel": "Mepụta Akara", + "labelName": "Aha Akara", + "enterLabelName": "Tinye aha akara", + "labelColor": "Agba", + "deleteLabel": "Hichapụ Akara", + "deleteLabelConfirmation": "Ị jiri n'ezie chọrọ ihichapụ akara \"{{name}}\"? Nke a ga-ewepụ akara ahụ n'ọrụ niile.", + "noLabelsYet": "Enweghị akara ugbu a", + "createLabelToOrganize": "Mepụta akara iji hazie ọrụ gị", + "addLabel": "Tinye akara", + "selectLabels": "Họrọ akara", + "noLabelsCreated": "Emepụtaghị akara ọ bụla", + "createNewLabel": "Mepụta akara ọhụrụ", + "otherProjects": "Ọrụ ndị ọzọ", "discoverPlugins": "Chọpụta Plugins", "discoverPluginsDescription": "Chọgharịa ma wụnye plugins Shakespeare nke ekekọrịtara na netwọk Nostr.", "searchPlugins": "Chọọ plugins...", diff --git a/src/locales/pt.json b/src/locales/pt.json index 6fdcb577..01aa8395 100644 --- a/src/locales/pt.json +++ b/src/locales/pt.json @@ -440,6 +440,21 @@ "restoreToDefault": "Restaurar para padrão", "restoredToDefault": "Restaurado para Padrão", "terminal": "Terminal", + "projectLabels": "Etiquetas de Projeto", + "manageLabels": "Gerenciar Etiquetas", + "createLabel": "Criar Etiqueta", + "labelName": "Nome da Etiqueta", + "enterLabelName": "Digite o nome da etiqueta", + "labelColor": "Cor", + "deleteLabel": "Excluir Etiqueta", + "deleteLabelConfirmation": "Tem certeza de que deseja excluir a etiqueta \"{{name}}\"? Isso removerá a etiqueta de todos os projetos.", + "noLabelsYet": "Nenhuma etiqueta ainda", + "createLabelToOrganize": "Crie uma etiqueta para organizar seus projetos", + "addLabel": "Adicionar etiqueta", + "selectLabels": "Selecionar etiquetas", + "noLabelsCreated": "Nenhuma etiqueta criada ainda", + "createNewLabel": "Criar nova etiqueta", + "otherProjects": "Outros projetos", "discoverPlugins": "Descobrir Plugins", "discoverPluginsDescription": "Navegue e instale plugins do Shakespeare compartilhados na rede Nostr.", "searchPlugins": "Buscar plugins...", diff --git a/src/locales/yo.json b/src/locales/yo.json index 4cbf9735..2bdd9e7e 100644 --- a/src/locales/yo.json +++ b/src/locales/yo.json @@ -428,6 +428,21 @@ "restoreToDefault": "Pada si atilẹwa", "restoredToDefault": "Ti Pada si Atilẹwa", "terminal": "Terminal", + "projectLabels": "Àmì Ìṣẹ́", + "manageLabels": "Ṣàkóso Àmì", + "createLabel": "Ṣẹ̀dá Àmì", + "labelName": "Orúkọ Àmì", + "enterLabelName": "Tẹ orúkọ àmì", + "labelColor": "Àwọ̀", + "deleteLabel": "Pa Àmì rẹ́", + "deleteLabelConfirmation": "Ṣé o dá a lójú pé o fẹ́ pa àmì \"{{name}}\" rẹ́? Èyí yóò yọ àmì náà kúrò nínú gbogbo iṣẹ́.", + "noLabelsYet": "Kò sí àmì síbẹ̀", + "createLabelToOrganize": "Ṣẹ̀dá àmì láti ṣètò àwọn iṣẹ́ rẹ", + "addLabel": "Fi àmì kún", + "selectLabels": "Yan àmì", + "noLabelsCreated": "A kò tí ì ṣẹ̀dá àmì kankan", + "createNewLabel": "Ṣẹ̀dá àmì tuntun", + "otherProjects": "Àwọn iṣẹ́ mìíràn", "discoverPlugins": "Ṣawari Awọn Plugins", "discoverPluginsDescription": "Ṣayẹwo ati fi sori ẹrọ awọn plugins Shakespeare ti a pin lori nẹtiwọọki Nostr.", "searchPlugins": "Wa awọn plugins...", diff --git a/src/locales/zh.json b/src/locales/zh.json index 95f44ea2..a6d4d390 100644 --- a/src/locales/zh.json +++ b/src/locales/zh.json @@ -440,6 +440,21 @@ "restoreToDefault": "恢复默认值", "restoredToDefault": "已恢复默认值", "terminal": "终端", + "projectLabels": "项目标签", + "manageLabels": "管理标签", + "createLabel": "创建标签", + "labelName": "标签名称", + "enterLabelName": "输入标签名称", + "labelColor": "颜色", + "deleteLabel": "删除标签", + "deleteLabelConfirmation": "确定要删除标签 \"{{name}}\" 吗?这将从所有项目中移除该标签。", + "noLabelsYet": "暂无标签", + "createLabelToOrganize": "创建标签来组织您的项目", + "addLabel": "添加标签", + "selectLabels": "选择标签", + "noLabelsCreated": "尚未创建标签", + "createNewLabel": "创建新标签", + "otherProjects": "其他项目", "discoverPlugins": "发现插件", "discoverPluginsDescription": "浏览并安装在 Nostr 网络上共享的 Shakespeare 插件。", "searchPlugins": "搜索插件...",