66 type ProjectIconColor ,
77 type ProjectIconOverride ,
88} from "@t3tools/contracts" ;
9- import { DynamicIcon , type IconName } from "lucide-react/dynamic" ;
10- import { useEffect , useMemo , useRef , useState } from "react" ;
9+ import { createElement , useEffect , useMemo , useRef , useState } from "react" ;
1110import {
1211 filterProjectIconNames ,
1312 firstEmoji ,
@@ -16,6 +15,7 @@ import {
1615 projectIconColorClassName ,
1716} from "../../projectIconOptions" ;
1817import { cn } from "~/lib/utils" ;
18+ import { lucideIconByName } from "../../lib/lucideIconByName" ;
1919import { Button } from "../ui/button" ;
2020import {
2121 Dialog ,
@@ -30,9 +30,14 @@ import { Input } from "../ui/input";
3030import { ScrollArea } from "../ui/scroll-area" ;
3131import { Toggle , ToggleGroup } from "../ui/toggle-group" ;
3232
33- const DEFAULT_ICON : IconName = "folder-code" ;
33+ const DEFAULT_ICON = "folder-code" ;
3434const isMonogramText = Schema . is ( ProjectMonogramText ) ;
3535
36+ function PickerIcon ( { name } : { name : string } ) {
37+ const icon = lucideIconByName ( name ) ;
38+ return icon ? createElement ( icon , { className : "size-5" } ) : null ;
39+ }
40+
3641function iconLabel ( name : string ) : string {
3742 return name
3843 . split ( "-" )
@@ -55,8 +60,8 @@ export function ProjectIconPickerDialog({
5560} ) {
5661 const automatic = deriveProjectIdentity ( projectName ) ;
5762 const [ mode , setMode ] = useState < ProjectIconOverride [ "kind" ] > ( current ?. kind ?? "lucide" ) ;
58- const [ iconName , setIconName ] = useState < IconName > (
59- current ?. kind === "lucide" ? ( current . name as IconName ) : DEFAULT_ICON ,
63+ const [ iconName , setIconName ] = useState < string > (
64+ current ?. kind === "lucide" ? current . name : DEFAULT_ICON ,
6065 ) ;
6166 const [ color , setColor ] = useState < ProjectIconColor > (
6267 current && current . kind !== "emoji" ? current . color : automatic . color ,
@@ -72,7 +77,7 @@ export function ProjectIconPickerDialog({
7277 useEffect ( ( ) => {
7378 if ( open && ! previousOpenRef . current ) {
7479 setMode ( current ?. kind ?? "lucide" ) ;
75- setIconName ( current ?. kind === "lucide" ? ( current . name as IconName ) : DEFAULT_ICON ) ;
80+ setIconName ( current ?. kind === "lucide" ? current . name : DEFAULT_ICON ) ;
7681 setColor ( current && current . kind !== "emoji" ? current . color : automatic . color ) ;
7782 setLetters ( current ?. kind === "monogram" ? current . text : automatic . monogram ) ;
7883 setEmoji ( current ?. kind === "emoji" ? current . emoji : "💻" ) ;
@@ -167,7 +172,7 @@ export function ProjectIconPickerDialog({
167172 ) }
168173 onClick = { ( ) => setIconName ( name ) }
169174 >
170- < DynamicIcon name = { name } className = "size-5" />
175+ < PickerIcon name = { name } />
171176 </ button >
172177 ) ) }
173178 </ div >
0 commit comments