The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 04:45 UTC
| 1 | /* oxlint-disable eslint/no-restricted-imports -- Resolves saved project icons by name, so it needs the whole set. */ |
| 2 | // Import lazily: one chunk avoids lucide-react/dynamic emitting about 1,900 icon chunks. |
| 3 | import * as Lucide from "lucide-react"; |
| 4 | import type { LucideIcon } from "lucide-react"; |
| 5 | |
| 6 | const iconComponents = new Set<unknown>(Object.values(Lucide.icons)); |
| 7 | const lucideExports: Record<string, unknown> = Lucide; |
| 8 | |
| 9 | // Match Lucide export naming to resolve deprecated aliases saved by older overrides. |
| 10 | function toPascalName(name: string): string { |
| 11 | return name |
| 12 | .split("-") |
| 13 | .map((part) => part.charAt(0).toUpperCase() + part.slice(1)) |
| 14 | .join(""); |
| 15 | } |
| 16 | |
| 17 | // Lucide digit names can differ from this inverse; both forms resolve through toPascalName. |
| 18 | function toKebabName(pascalName: string): string { |
| 19 | return (pascalName.match(/[A-Z][a-z]*|[0-9]+[a-z]*/g) ?? []).join("-").toLowerCase(); |
| 20 | } |
| 21 | |
| 22 | export const lucideIconNames: ReadonlyArray<string> = Object.keys(Lucide.icons).map(toKebabName); |
| 23 | |
| 24 | export function lucideIconByName(name: string): LucideIcon | undefined { |
| 25 | const icon = lucideExports[toPascalName(name)]; |
| 26 | return iconComponents.has(icon) ? (icon as LucideIcon) : undefined; |
| 27 | } |