Line data Source code
1 : /**
2 : * Maps category IDs to their corresponding Lucide icon classes
3 : */
4 2356 : export const getCategoryIcon = (categoryId: string): string => {
5 : const iconMap: Record<string, string> = {
6 : // Main categories
7 : all: 'icon-[lucide--list]',
8 : 'getting-started': 'icon-[lucide--graduation-cap]',
9 :
10 : // Generation types
11 : 'generation-image': 'icon-[lucide--image]',
12 : image: 'icon-[lucide--image]',
13 : 'generation-video': 'icon-[lucide--film]',
14 : video: 'icon-[lucide--film]',
15 : 'generation-3d': 'icon-[lucide--box]',
16 : '3d': 'icon-[lucide--box]',
17 : 'generation-audio': 'icon-[lucide--volume-2]',
18 : audio: 'icon-[lucide--volume-2]',
19 : 'generation-llm': 'icon-[lucide--message-square-text]',
20 :
21 : // API and models
22 : 'api-nodes': 'icon-[lucide--hand-coins]',
23 : 'closed-models': 'icon-[lucide--hand-coins]',
24 :
25 : // LLMs and AI
26 : llm: 'icon-[lucide--message-square-text]',
27 : llms: 'icon-[lucide--message-square-text]',
28 : 'llm-api': 'icon-[lucide--message-square-text]',
29 :
30 : // Performance and hardware
31 : 'small-models': 'icon-[lucide--zap]',
32 : performance: 'icon-[lucide--zap]',
33 : 'mac-compatible': 'icon-[lucide--command]',
34 : 'runs-on-mac': 'icon-[lucide--command]',
35 :
36 : // Training
37 : 'lora-training': 'icon-[lucide--dumbbell]',
38 : training: 'icon-[lucide--dumbbell]',
39 :
40 : // Extensions and tools
41 : extensions: 'icon-[lucide--puzzle]',
42 : tools: 'icon-[lucide--wrench]',
43 :
44 : // Fallbacks for common patterns
45 : upscaling: 'icon-[lucide--maximize-2]',
46 : controlnet: 'icon-[lucide--sliders-horizontal]',
47 : 'area-composition': 'icon-[lucide--layout-grid]'
48 : }
49 :
50 : // Return mapped icon or fallback to folder
51 22 : return iconMap[categoryId.toLowerCase()] || 'icon-[lucide--folder]'
52 : }
53 :
54 : /**
55 : * Provider brand colors extracted from SVG icons.
56 : * Each entry can be a single color or [color1, color2] for gradient.
57 : */
58 2356 : const PROVIDER_COLORS: Record<string, string | [string, string]> = {
59 : anthropic: '#D97757',
60 : bfl: '#ffffff',
61 : bria: '#B6B6B6',
62 : elevenlabs: '#B6B6B6',
63 : bytedance: ['#00C8D2', '#325AB4'],
64 : gemini: ['#3186FF', '#FABC12'],
65 : grok: '#B6B6B6',
66 : hitpaw: '#B6B6B6',
67 : ideogram: '#B6B6B6',
68 : kling: ['#0BF2F9', '#FFF959'],
69 : ltxv: '#B6B6B6',
70 : luma: ['#004EFF', '#00FFFF'],
71 : magnific: ['#EA5A3D', '#F1A64A'],
72 : meshy: ['#67B700', '#FA418C'],
73 : minimax: ['#E2167E', '#FE603C'],
74 : 'moonvalley-marey': '#DAD9C5',
75 : openai: '#B6B6B6',
76 : pixverse: ['#B465E6', '#E8632A'],
77 : quiver: '#B6B6B6',
78 : recraft: '#B6B6B6',
79 : reve: '#B6B6B6',
80 : rodin: '#F7F7F7',
81 : runway: '#B6B6B6',
82 : sora: ['#6BB6FE', '#ffffff'],
83 : 'stability-ai': ['#9D39FF', '#E80000'],
84 : tencent: ['#004BE5', '#00B3FE'],
85 : topaz: '#B6B6B6',
86 : tripo: ['#F6D85A', '#B6B6B6'],
87 : veo: ['#4285F4', '#EB4335'],
88 : vidu: ['#047FFE', '#40EDD8'],
89 : wan: ['#6156EC', '#F4F3FD'],
90 : wavespeed: '#B6B6B6'
91 : }
92 :
93 : /**
94 : * Extracts the provider name from a node category path.
95 : * e.g. "api/image/BFL" -> "BFL"
96 : */
97 693 : export function getProviderName(category: string): string {
98 693 : return category.split('/').at(-1) ?? ''
99 : }
100 :
101 : /**
102 : * Returns the icon class for an API node provider (e.g., BFL, OpenAI, Stability AI)
103 : * @param providerName - The provider name from the node category
104 : * @returns The icon class string (e.g., 'icon-[comfy--bfl]')
105 : */
106 16565 : export function getProviderIcon(providerName: string): string {
107 : const iconKey = providerName.toLowerCase().replaceAll(/\s+/g, '-')
108 16565 : return `icon-[comfy--${iconKey}]`
109 : }
110 :
111 : /**
112 : * Returns the border color(s) for an API node provider badge.
113 : * @param providerName - The provider name from the node category
114 : * @returns CSS color string or gradient definition
115 : */
116 0 : export function getProviderBorderStyle(providerName: string): string {
117 : const iconKey = providerName.toLowerCase().replaceAll(/\s+/g, '-')
118 0 : const colors = PROVIDER_COLORS[iconKey]
119 :
120 0 : if (!colors) {
121 0 : return '#525252' // neutral-600 fallback
122 : }
123 :
124 0 : if (Array.isArray(colors)) {
125 0 : return `linear-gradient(90deg, ${colors[0]}, ${colors[1]})`
126 : }
127 :
128 0 : return colors
129 : }
130 :
131 : /**
132 : * Generates a unique category ID from a category group and title
133 : */
134 132 : export function generateCategoryId(
135 : categoryGroup: string,
136 : categoryTitle: string
137 : ) {
138 132 : return `${categoryGroup.toLowerCase().replace(/\s+/g, '-')}-${categoryTitle.toLowerCase().replace(/\s+/g, '-')}`
139 : }
|