@@ -26,16 +26,24 @@ export namespace MegaMenuProps {
26
26
} ;
27
27
28
28
export type Category = {
29
- categoryMainLink : {
30
- text : ReactNode ;
31
- linkProps : RegisteredLinkProps ;
32
- } ;
33
29
links : {
34
30
text : ReactNode ;
35
31
linkProps : RegisteredLinkProps ;
36
32
isActive ?: boolean ;
37
33
} [ ] ;
38
- } ;
34
+ } & (
35
+ | {
36
+ categoryMainLink : {
37
+ text : ReactNode ;
38
+ linkProps : RegisteredLinkProps ;
39
+ } ;
40
+ categoryMainText ?: never ;
41
+ }
42
+ | {
43
+ categoryMainText : ReactNode ;
44
+ categoryMainLink ?: never ;
45
+ }
46
+ ) ;
39
47
}
40
48
41
49
export const MegaMenu = memo (
@@ -101,30 +109,42 @@ export const MegaMenu = memo(
101
109
</ div >
102
110
</ div >
103
111
) }
104
- { categories . map ( ( { categoryMainLink, links } , i ) => (
112
+ { categories . map ( ( { categoryMainLink, categoryMainText , links } , i ) => (
105
113
< div className = { fr . cx ( "fr-col-12" , "fr-col-lg-3" ) } key = { i } >
106
- < h5
107
- className = { cx (
108
- fr . cx ( "fr-mega-menu__category" ) ,
109
- classes . category
110
- ) }
111
- >
112
- < Link
113
- { ...categoryMainLink . linkProps }
114
- id = {
115
- categoryMainLink . linkProps . id ??
116
- `${ id } -category-link${ generateValidHtmlId ( {
117
- "text" : categoryMainLink . text
118
- } ) } -${ i } `
119
- }
114
+ { categoryMainLink !== undefined && (
115
+ < h5
120
116
className = { cx (
121
- fr . cx ( "fr-nav__link " ) ,
122
- categoryMainLink . linkProps . className
117
+ fr . cx ( "fr-mega-menu__category " ) ,
118
+ classes . category
123
119
) }
124
120
>
125
- { categoryMainLink . text }
126
- </ Link >
127
- </ h5 >
121
+ < Link
122
+ { ...categoryMainLink . linkProps }
123
+ id = {
124
+ categoryMainLink . linkProps . id ??
125
+ `${ id } -category-link${ generateValidHtmlId ( {
126
+ "text" : categoryMainLink . text
127
+ } ) } -${ i } `
128
+ }
129
+ className = { cx (
130
+ fr . cx ( "fr-nav__link" ) ,
131
+ categoryMainLink . linkProps . className
132
+ ) }
133
+ >
134
+ { categoryMainLink . text }
135
+ </ Link >
136
+ </ h5 >
137
+ ) }
138
+ { categoryMainText !== undefined && (
139
+ < h5
140
+ className = { cx (
141
+ fr . cx ( "fr-mega-menu__category" , "fr-nav__link" ) ,
142
+ classes . category
143
+ ) }
144
+ >
145
+ { categoryMainText }
146
+ </ h5 >
147
+ ) }
128
148
< ul className = { cx ( fr . cx ( "fr-mega-menu__list" ) , classes . list ) } >
129
149
{ links . map ( ( { linkProps, text, isActive } , j ) => (
130
150
< li key = { j } >
0 commit comments