11import React , { Fragment , MouseEventHandler , useContext , useMemo } from 'react' ;
22import block from 'bem-cn-lite' ;
33
4- import { RouterLink , ToggleArrow } from '../../../index' ;
4+ import { RouterLink , ToggleArrow , Button , Image } from '../../../index' ;
55import { getLinkProps } from '../../../../utils' ;
66import { LocationContext } from '../../../../context/locationContext' ;
77import {
@@ -10,13 +10,14 @@ import {
1010 NavigationItemType ,
1111 NavigationSocialItem ,
1212 NavigationLinkItem ,
13- } from '../../../../models/navigation' ;
13+ ImageProps ,
14+ ButtonProps ,
15+ } from '../../../../models' ;
1416import { NavigationArrow } from '../../../../icons' ;
1517import SocialIcon from '../SocialIcon/SocialIcon' ;
1618import { getMediaImage } from '../../../Media/Image/utils' ;
1719
1820import './NavigationItem.scss' ;
19- import { ImageProps } from '../../../../models' ;
2021
2122const b = block ( 'navigation-item' ) ;
2223
@@ -37,7 +38,7 @@ export interface NavigationItemProps {
3738
3839const Content : React . FC < { text : string ; icon ?: ImageProps } > = ( { text, icon} ) => (
3940 < Fragment >
40- { icon && < img className = { b ( 'icon' ) } { ...icon } /> }
41+ { icon && < Image className = { b ( 'icon' ) } { ...icon } /> }
4142 < span className = { b ( 'text' ) } > { text } </ span >
4243 </ Fragment >
4344) ;
@@ -92,10 +93,21 @@ const NavigationLink: React.FC<NavigationLinkProps> = (props) => {
9293 ) ;
9394} ;
9495
96+ const NavigationButton : React . FC < ButtonProps > = ( props ) => {
97+ const { url, target} = props ;
98+ return target ? (
99+ < Button { ...props } url = { url } />
100+ ) : (
101+ < RouterLink href = { url } >
102+ < Button { ...props } url = { url } />
103+ </ RouterLink >
104+ ) ;
105+ } ;
106+
95107//todo: add types support form component in map
96108// eslint-disable-next-line @typescript-eslint/no-explicit-any
97109const NavigationItemsMap : Record < NavigationItemType , React . ComponentType < any > > = {
98- [ NavigationItemType . Button ] : RouterLink ,
110+ [ NavigationItemType . Button ] : NavigationButton ,
99111 [ NavigationItemType . Social ] : SocialIcon ,
100112 [ NavigationItemType . Dropdown ] : NavigationDropdown ,
101113 [ NavigationItemType . Link ] : NavigationLink ,
0 commit comments