I'll just go with this solution for now I guess, seems to be alright, not exactly what I wanted, but then, icon names never change so.... I'm just trying to overengeener something that doesn't have to be xd
import { CloseSolid, PaletteSolid } from "../svg/solid";
const icons = [
{
"icon": "close",
"types": {
"solid": <CloseSolid />,
"regular": ""
}
},
{
"icon": "eye",
"types": {
"solid": <PaletteSolid />,
"regular": ""
}
},
{
"icon": "file",
"types": {
"solid": <PaletteSolid />,
"regular": ""
}
},
{
"icon": "floppy-disk",
"types": {
"solid": <PaletteSolid />,
"regular": ""
}
},
]
function Svg({icon, type}:{icon:string, type?:any}) {
return (
<>
{ icons.map(filteredIcon => {
if(filteredIcon.icon === icon) {
// return filteredIcon.types[type];
return filteredIcon.types['solid'];
} else {
// return filteredIcon.types['solid'];
}
})}
</>
);
}