1- import React from 'react' ;
2- import PropTypes from 'prop-types' ;
1+ import React , { type ReactNode , type ComponentProps } from 'react' ;
32import { useIntl } from '@edx/frontend-platform/i18n' ;
43import classNames from 'classnames' ;
54import {
@@ -19,6 +18,32 @@ import BrandNav from './BrandNav';
1918import NavDropdownMenu from './NavDropdownMenu' ;
2019import messages from './messages' ;
2120
21+ export interface HeaderBodyProps {
22+ studioBaseUrl : string ;
23+ logoutUrl : string ;
24+ setModalPopupTarget ?: ( ( instance : HTMLButtonElement | null ) => void ) | null ;
25+ toggleModalPopup ?: React . MouseEventHandler < HTMLButtonElement > ;
26+ isModalPopupOpen ?: boolean ;
27+ number ?: string ;
28+ org ?: string ;
29+ title : string ;
30+ logo : string ;
31+ logoAltText : string ;
32+ authenticatedUserAvatar ?: string ;
33+ username ?: string ;
34+ isAdmin ?: boolean ;
35+ isMobile ?: boolean ;
36+ isHiddenMainMenu ?: boolean ;
37+ mainMenuDropdowns ?: {
38+ id : string ;
39+ buttonTitle : ReactNode ;
40+ items : { title : ReactNode ; href : string ; } [ ] ;
41+ } [ ] ;
42+ outlineLink ?: string ;
43+ searchButtonAction ?: React . MouseEventHandler < HTMLButtonElement > ;
44+ containerProps ?: Omit < ComponentProps < typeof Container > , 'children' > ;
45+ }
46+
2247const HeaderBody = ( {
2348 logo,
2449 logoAltText,
@@ -31,15 +56,15 @@ const HeaderBody = ({
3156 logoutUrl,
3257 authenticatedUserAvatar,
3358 isMobile,
34- setModalPopupTarget,
59+ setModalPopupTarget = null ,
3560 toggleModalPopup,
36- isModalPopupOpen,
37- isHiddenMainMenu,
38- mainMenuDropdowns,
61+ isModalPopupOpen = false ,
62+ isHiddenMainMenu = false ,
63+ mainMenuDropdowns = [ ] ,
3964 outlineLink,
4065 searchButtonAction,
41- containerProps,
42- } ) => {
66+ containerProps = { } ,
67+ } : HeaderBodyProps ) => {
4368 const intl = useIntl ( ) ;
4469
4570 const renderBrandNav = (
@@ -52,7 +77,7 @@ const HeaderBody = ({
5277 />
5378 ) ;
5479
55- const { className : containerClassName , ...restContainerProps } = containerProps || { } ;
80+ const { className : containerClassName , ...restContainerProps } = containerProps ;
5681
5782 return (
5883 < Container
@@ -144,53 +169,4 @@ const HeaderBody = ({
144169 ) ;
145170} ;
146171
147- HeaderBody . propTypes = {
148- studioBaseUrl : PropTypes . string . isRequired ,
149- logoutUrl : PropTypes . string . isRequired ,
150- setModalPopupTarget : PropTypes . func ,
151- toggleModalPopup : PropTypes . func ,
152- isModalPopupOpen : PropTypes . bool ,
153- number : PropTypes . string ,
154- org : PropTypes . string ,
155- title : PropTypes . string ,
156- logo : PropTypes . string ,
157- logoAltText : PropTypes . string ,
158- authenticatedUserAvatar : PropTypes . string ,
159- username : PropTypes . string ,
160- isAdmin : PropTypes . bool ,
161- isMobile : PropTypes . bool ,
162- isHiddenMainMenu : PropTypes . bool ,
163- mainMenuDropdowns : PropTypes . arrayOf ( PropTypes . shape ( {
164- id : PropTypes . string ,
165- buttonTitle : PropTypes . node ,
166- items : PropTypes . arrayOf ( PropTypes . shape ( {
167- href : PropTypes . string ,
168- title : PropTypes . node ,
169- } ) ) ,
170- } ) ) ,
171- outlineLink : PropTypes . string ,
172- searchButtonAction : PropTypes . func ,
173- containerProps : PropTypes . shape ( Container . propTypes ) ,
174- } ;
175-
176- HeaderBody . defaultProps = {
177- setModalPopupTarget : null ,
178- toggleModalPopup : null ,
179- isModalPopupOpen : false ,
180- logo : null ,
181- logoAltText : null ,
182- number : '' ,
183- org : '' ,
184- title : '' ,
185- authenticatedUserAvatar : null ,
186- username : null ,
187- isAdmin : false ,
188- isMobile : false ,
189- isHiddenMainMenu : false ,
190- mainMenuDropdowns : [ ] ,
191- outlineLink : null ,
192- searchButtonAction : null ,
193- containerProps : { } ,
194- } ;
195-
196172export default HeaderBody ;
0 commit comments