39 lines
980 B
TypeScript
39 lines
980 B
TypeScript
import navigationIcon from '@/configs/navigation-icon.config'
|
|
import type { ElementType, ComponentPropsWithRef } from 'react'
|
|
import React from 'react'
|
|
|
|
type VerticalMenuIconProps = {
|
|
icon: string
|
|
}
|
|
|
|
export const Icon = <T extends ElementType>({
|
|
component,
|
|
...props
|
|
}: {
|
|
header: T
|
|
} & ComponentPropsWithRef<T>) => {
|
|
const Component = component
|
|
return <Component {...props} />
|
|
}
|
|
|
|
const VerticalMenuIcon = ({ icon }: VerticalMenuIconProps) => {
|
|
// Eğer icon boş veya string değilse, boş bir öğe döndür
|
|
if (typeof icon !== 'string' || !icon) {
|
|
return <></>
|
|
}
|
|
|
|
// navigationIcon'dan ikonu al ve React.createElement ile render et
|
|
const IconComponent = navigationIcon[icon]
|
|
|
|
if (!IconComponent) {
|
|
return <></> // İkon bulunamazsa, boş döndür
|
|
}
|
|
|
|
return (
|
|
<span className="text-2xl ltr:mr-2 rtl:ml-2">
|
|
{React.createElement(IconComponent)} {/* İkonu dinamik olarak render et */}
|
|
</span>
|
|
)
|
|
}
|
|
|
|
export default VerticalMenuIcon
|