11import { Container } from "@dataesr/dsfr-plus" ;
2- import { useEffect } from "react" ;
2+ import { useEffect , useState } from "react" ;
33import { Link , Outlet , useLocation , useSearchParams } from "react-router-dom" ;
44
55import CountrySelector from "../../../../components/country-selector/selector" ;
@@ -12,6 +12,7 @@ import "../../colors.scss";
1212export default function GlobalLayout ( ) {
1313 const { pathname } = useLocation ( ) ;
1414 const [ searchParams , setSearchParams ] = useSearchParams ( ) ;
15+ const [ isMenuOpen , setIsMenuOpen ] = useState ( false ) ;
1516 const currentLang = searchParams . get ( "language" ) || "fr" ;
1617 const filtersParams = searchParams . toString ( ) ;
1718
@@ -30,6 +31,10 @@ export default function GlobalLayout() {
3031 }
3132 } , [ searchParams , setSearchParams ] ) ;
3233
34+ useEffect ( ( ) => {
35+ setIsMenuOpen ( false ) ;
36+ } , [ pathname ] ) ;
37+
3338 if ( ! pathname ) return null ;
3439 const is = ( str : string ) : boolean => pathname ?. startsWith ( str ) ;
3540
@@ -61,12 +66,14 @@ export default function GlobalLayout() {
6166 </ div >
6267 < div className = "fr-header__navbar" >
6368 < button
64- data-fr-opened = "false"
65- aria-controls = "modal-header"
69+ data-fr-opened = { isMenuOpen ? "true" : "false" }
70+ aria-controls = "main-navigation"
71+ aria-expanded = { isMenuOpen }
6672 title = "Menu"
6773 type = "button"
6874 id = "button-header"
6975 className = "fr-btn--menu fr-btn"
76+ onClick = { ( ) => setIsMenuOpen ( ( open ) => ! open ) }
7077 >
7178 Menu
7279 </ button >
@@ -77,67 +84,37 @@ export default function GlobalLayout() {
7784 </ div >
7885 </ div >
7986 </ header >
80- < nav className = " ep-sticky-nav fr-nav" role = "navigation" aria-label = "Menu principal" >
87+ < nav id = "main-navigation" className = { ` ep-sticky-nav fr-nav${ isMenuOpen ? " ep-nav-open" : "" } ` } role = "navigation" aria-label = "Menu principal" >
8188 < Container >
8289 < ul className = "fr-nav__list" >
8390 < li className = "fr-nav__item" >
84- < Link
85- to = "/european-projects/accueil"
86- target = "_self"
87- { ...( pathname === "/european-projects/accueil" && { "aria-current" : "page" } ) }
88- className = "fr-nav__link"
89- >
91+ < Link to = "/european-projects/accueil" target = "_self" { ...( pathname === "/european-projects/accueil" && { "aria-current" : "page" } ) } className = "fr-nav__link" >
9092 < span className = "fr-icon-home-4-line fr-mr-1w" aria-hidden = "true" />
9193 { getI18nLabel ( "home" ) }
9294 </ Link >
9395 </ li >
9496 < li className = "fr-nav__item" >
95- < Link
96- to = { `/european-projects/horizon-europe?section=synthesis&${ filtersParams } ` }
97- target = "_self"
98- { ...( is ( "/european-projects/horizon-europe" ) && { "aria-current" : "page" } ) }
99- className = "fr-nav__link"
100- >
97+ < Link to = { `/european-projects/horizon-europe?section=synthesis&${ filtersParams } ` } target = "_self" { ...( is ( "/european-projects/horizon-europe" ) && { "aria-current" : "page" } ) } className = "fr-nav__link" >
10198 { getI18nLabel ( "he" ) }
10299 </ Link >
103100 </ li >
104101 < li className = "fr-nav__item" >
105- < Link
106- to = { `/european-projects/msca?${ filtersParams } ` }
107- target = "_self"
108- { ...( is ( "/european-projects/msca" ) && { "aria-current" : "page" } ) }
109- className = "fr-nav__link"
110- >
102+ < Link to = { `/european-projects/msca?${ filtersParams } ` } target = "_self" { ...( is ( "/european-projects/msca" ) && { "aria-current" : "page" } ) } className = "fr-nav__link" >
111103 Focus MSCA
112104 </ Link >
113105 </ li >
114106 < li className = "fr-nav__item" >
115- < Link
116- to = { `/european-projects/erc?${ filtersParams } ` }
117- target = "_self"
118- { ...( is ( "/european-projects/erc" ) && { "aria-current" : "page" } ) }
119- className = "fr-nav__link"
120- >
107+ < Link to = { `/european-projects/erc?${ filtersParams } ` } target = "_self" { ...( is ( "/european-projects/erc" ) && { "aria-current" : "page" } ) } className = "fr-nav__link" >
121108 Focus ERC
122109 </ Link >
123110 </ li >
124111 < li className = "fr-nav__item" >
125- < Link
126- to = "/european-projects/evolution-pcri"
127- target = "_self"
128- { ...( is ( "/european-projects/evolution-pcri" ) && { "aria-current" : "page" } ) }
129- className = "fr-nav__link"
130- >
112+ < Link to = "/european-projects/evolution-pcri" target = "_self" { ...( is ( "/european-projects/evolution-pcri" ) && { "aria-current" : "page" } ) } className = "fr-nav__link" >
131113 { getI18nLabel ( "evolutionPcri" ) }
132114 </ Link >
133115 </ li >
134116 < li >
135- < Link
136- to = { `/european-projects/entities?${ filtersParams } ` }
137- target = "_self"
138- { ...( is ( "/european-projects/entities" ) && { "aria-current" : "page" } ) }
139- className = "fr-nav__link"
140- >
117+ < Link to = { `/european-projects/entities?${ filtersParams } ` } target = "_self" { ...( is ( "/european-projects/entities" ) && { "aria-current" : "page" } ) } className = "fr-nav__link" >
141118 { getI18nLabel ( "entities" ) }
142119 </ Link >
143120 </ li >
0 commit comments