11import type { ProjectIconColor , ProjectIconOverride } from "@t3tools/contracts" ;
2+ import type { AppSymbolName } from "../components/AppSymbol" ;
23
34export type ProjectIconGlyph =
45 | { readonly kind : "emoji" ; readonly emoji : string }
5- | { readonly kind : "monogram" ; readonly text : string ; readonly color : ProjectIconColor } ;
6+ | { readonly kind : "monogram" ; readonly text : string ; readonly color : ProjectIconColor }
7+ | { readonly kind : "symbol" ; readonly name : AppSymbolName ; readonly color : ProjectIconColor } ;
8+
9+ /** Native stand-ins for the Lucide icons the server assigns on its own. */
10+ const SYMBOL_BY_LUCIDE_NAME : Partial < Record < string , AppSymbolName > > = {
11+ // No project. Neither SF Symbols nor Tabler has a dashed chat bubble.
12+ "message-square-dashed" : "square.dashed" ,
13+ } ;
614
715/**
816 * Visible glyph count for sizing monogram text. Hermes has no Intl.Segmenter, so combining
@@ -33,8 +41,8 @@ export function projectMonogram(projectName: string): string {
3341
3442/**
3543 * Picks what mobile draws for an assigned project icon. Mobile does not bundle
36- * the Lucide set, so a Lucide override keeps its color and falls back to the
37- * project's monogram instead of the folder glyph.
44+ * the Lucide set, so a Lucide override keeps its color and draws a native
45+ * stand-in when one exists, else the project's monogram instead of the folder glyph.
3846 */
3947export function resolveProjectIconGlyph (
4048 projectIcon : ProjectIconOverride | null | undefined ,
@@ -45,35 +53,47 @@ export function resolveProjectIconGlyph(
4553 return { kind : "emoji" , emoji : projectIcon . emoji } ;
4654 case "monogram" :
4755 return { kind : "monogram" , text : projectIcon . text , color : projectIcon . color } ;
48- case "lucide" :
49- return { kind : "monogram" , text : projectMonogram ( projectTitle ) , color : projectIcon . color } ;
56+ case "lucide" : {
57+ const symbol = SYMBOL_BY_LUCIDE_NAME [ projectIcon . name ] ;
58+ return symbol
59+ ? { kind : "symbol" , name : symbol , color : projectIcon . color }
60+ : { kind : "monogram" , text : projectMonogram ( projectTitle ) , color : projectIcon . color } ;
61+ }
5062 case undefined :
5163 return null ;
5264 }
5365}
5466
5567const PROJECT_ICON_COLOR_CLASSES : Record <
5668 ProjectIconColor ,
57- { readonly text : string ; readonly background : string }
69+ { readonly text : string ; readonly tint : string ; readonly background : string }
5870> = {
59- gray : { text : "text-gray-500" , background : "bg-gray-500/15" } ,
60- red : { text : "text-red-500" , background : "bg-red-500/15" } ,
61- orange : { text : "text-orange-500" , background : "bg-orange-500/15" } ,
62- amber : { text : "text-amber-500" , background : "bg-amber-500/15" } ,
63- yellow : { text : "text-yellow-500" , background : "bg-yellow-500/15" } ,
64- lime : { text : "text-lime-500" , background : "bg-lime-500/15" } ,
65- green : { text : "text-green-500" , background : "bg-green-500/15" } ,
66- emerald : { text : "text-emerald-500" , background : "bg-emerald-500/15" } ,
67- teal : { text : "text-teal-500" , background : "bg-teal-500/15" } ,
68- cyan : { text : "text-cyan-500" , background : "bg-cyan-500/15" } ,
69- sky : { text : "text-sky-500" , background : "bg-sky-500/15" } ,
70- blue : { text : "text-blue-500" , background : "bg-blue-500/15" } ,
71- indigo : { text : "text-indigo-500" , background : "bg-indigo-500/15" } ,
72- violet : { text : "text-violet-500" , background : "bg-violet-500/15" } ,
73- purple : { text : "text-purple-500" , background : "bg-purple-500/15" } ,
74- fuchsia : { text : "text-fuchsia-500" , background : "bg-fuchsia-500/15" } ,
75- pink : { text : "text-pink-500" , background : "bg-pink-500/15" } ,
76- rose : { text : "text-rose-500" , background : "bg-rose-500/15" } ,
71+ gray : { text : "text-gray-500" , tint : "accent-gray-500" , background : "bg-gray-500/15" } ,
72+ red : { text : "text-red-500" , tint : "accent-red-500" , background : "bg-red-500/15" } ,
73+ orange : { text : "text-orange-500" , tint : "accent-orange-500" , background : "bg-orange-500/15" } ,
74+ amber : { text : "text-amber-500" , tint : "accent-amber-500" , background : "bg-amber-500/15" } ,
75+ yellow : { text : "text-yellow-500" , tint : "accent-yellow-500" , background : "bg-yellow-500/15" } ,
76+ lime : { text : "text-lime-500" , tint : "accent-lime-500" , background : "bg-lime-500/15" } ,
77+ green : { text : "text-green-500" , tint : "accent-green-500" , background : "bg-green-500/15" } ,
78+ emerald : {
79+ text : "text-emerald-500" ,
80+ tint : "accent-emerald-500" ,
81+ background : "bg-emerald-500/15" ,
82+ } ,
83+ teal : { text : "text-teal-500" , tint : "accent-teal-500" , background : "bg-teal-500/15" } ,
84+ cyan : { text : "text-cyan-500" , tint : "accent-cyan-500" , background : "bg-cyan-500/15" } ,
85+ sky : { text : "text-sky-500" , tint : "accent-sky-500" , background : "bg-sky-500/15" } ,
86+ blue : { text : "text-blue-500" , tint : "accent-blue-500" , background : "bg-blue-500/15" } ,
87+ indigo : { text : "text-indigo-500" , tint : "accent-indigo-500" , background : "bg-indigo-500/15" } ,
88+ violet : { text : "text-violet-500" , tint : "accent-violet-500" , background : "bg-violet-500/15" } ,
89+ purple : { text : "text-purple-500" , tint : "accent-purple-500" , background : "bg-purple-500/15" } ,
90+ fuchsia : {
91+ text : "text-fuchsia-500" ,
92+ tint : "accent-fuchsia-500" ,
93+ background : "bg-fuchsia-500/15" ,
94+ } ,
95+ pink : { text : "text-pink-500" , tint : "accent-pink-500" , background : "bg-pink-500/15" } ,
96+ rose : { text : "text-rose-500" , tint : "accent-rose-500" , background : "bg-rose-500/15" } ,
7797} ;
7898
7999export function projectIconColorClassNames ( color : ProjectIconColor ) {
0 commit comments