qpp-style 1.0.1-ds.2 → 1.0.1-ds.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,7 +4,7 @@ import PropTypes from 'prop-types';
4
4
  import HeaderLogo from './HeaderLogo';
5
5
  import NotificationBanner from '../NotificationBanner';
6
6
  import GovBanner from '../GovBanner';
7
-
7
+ import { useHeaderState } from './hooks';
8
8
  /**
9
9
  * Accessibility enhancement that moves focus to an element for "Skip" links
10
10
  * @param {Object} e - The native JS event
@@ -21,32 +21,48 @@ const HeaderContainer = ({
21
21
  showCancelButton,
22
22
  skipToContentId,
23
23
  isIESupportPage,
24
- }) => (
25
- <>
26
- <a
27
- className="skip"
28
- onClick={(e) => jumpToLink(e, `${skipToContentId || 'mainContent'}`)}
29
- href={`#${skipToContentId || 'mainContent'}`}
30
- >
31
- Skip to content
32
- </a>
33
- {includeSkipToSidebar && (
24
+ }) => {
25
+ const { currentOpenMenu } = useHeaderState();
26
+ let cssClasses = '';
27
+
28
+ {
29
+ cssClasses +=
30
+ currentOpenMenu !== ''
31
+ ? 'header-dropdown--open'
32
+ : 'header-dropdown--closed';
33
+ }
34
+
35
+ if (showCancelButton) {
36
+ cssClasses += ' show-cancel-button';
37
+ }
38
+
39
+ return (
40
+ <>
34
41
  <a
35
42
  className="skip"
36
- onClick={(e) => jumpToLink(e, 'qppSidebar')}
37
- href="#qppSidebar"
43
+ onClick={(e) => jumpToLink(e, `${skipToContentId || 'mainContent'}`)}
44
+ href={`#${skipToContentId || 'mainContent'}`}
38
45
  >
39
- Skip to sidebar
46
+ Skip to content
40
47
  </a>
41
- )}
42
- <GovBanner />
43
- {!isIESupportPage && <NotificationBanner />}
44
- <header id="top" className={showCancelButton ? 'show-cancel-button' : ''}>
45
- <HeaderLogo />
46
- {children}
47
- </header>
48
- </>
49
- );
48
+ {includeSkipToSidebar && (
49
+ <a
50
+ className="skip"
51
+ onClick={(e) => jumpToLink(e, 'qppSidebar')}
52
+ href="#qppSidebar"
53
+ >
54
+ Skip to sidebar
55
+ </a>
56
+ )}
57
+ <GovBanner />
58
+ {!isIESupportPage && <NotificationBanner />}
59
+ <header id="top" className={cssClasses}>
60
+ <HeaderLogo />
61
+ {children}
62
+ </header>
63
+ </>
64
+ );
65
+ };
50
66
 
51
67
  HeaderContainer.propTypes = {
52
68
  children: PropTypes.node.isRequired,