qpp-style 9.35.0 → 9.37.0

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,8 @@ import PropTypes from "prop-types";
4
4
  import HeaderLogo from "./HeaderLogo";
5
5
  import NotificationBanner from "../NotificationBanner";
6
6
  import GovBanner from "../GovBanner";
7
- import { useHeaderState } from "./hooks";
7
+ import { useHeaderState, useWindowWidth } from "./hooks";
8
+ import HeaderSearchBar from "../HeaderSearchBar";
8
9
  /**
9
10
  * Accessibility enhancement that moves focus to an element for "Skip" links
10
11
  * @param {Object} e - The native JS event
@@ -22,13 +23,18 @@ const HeaderContainer = ({
22
23
  skipToContentId,
23
24
  isIESupportPage,
24
25
  isDevPre,
26
+ showSearchBar,
25
27
  }) => {
28
+ const windowWidth = useWindowWidth();
26
29
  const { currentOpenMenu } = useHeaderState();
27
- const cssCancelBtn = showCancelButton ? "show-cancel-button" : "";
30
+ const showSearch = showSearchBar === "true";
31
+ const cssCancelBtn = showCancelButton ? "show-cancel-button " : "";
28
32
  const cssMenuDropdownStatus =
29
33
  currentOpenMenu === ""
30
34
  ? "header-dropdown--closed"
31
35
  : "header-dropdown--open";
36
+ const cssSearchBar = showSearch ? " header-height" : "";
37
+ const headerClasses = `${cssCancelBtn}${cssMenuDropdownStatus}${cssSearchBar}`;
32
38
 
33
39
  return (
34
40
  <>
@@ -50,9 +56,12 @@ const HeaderContainer = ({
50
56
  )}
51
57
  <GovBanner />
52
58
  {!isIESupportPage && <NotificationBanner />}
53
- <header id="top" className={`${cssCancelBtn} ${cssMenuDropdownStatus}`}>
54
- <HeaderLogo isDevPre={isDevPre} />
55
- {children}
59
+ <header id="top" className={headerClasses}>
60
+ {showSearch && windowWidth > 767 ? <HeaderSearchBar /> : null}
61
+ <>
62
+ <HeaderLogo isDevPre={isDevPre} hasSearchBar={showSearch} />
63
+ {children}
64
+ </>
56
65
  </header>
57
66
  </>
58
67
  );
@@ -65,12 +74,14 @@ HeaderContainer.propTypes = {
65
74
  skipToContentId: PropTypes.string,
66
75
  isIESupportPage: PropTypes.bool,
67
76
  isDevPre: PropTypes.object,
77
+ showSearchBar: PropTypes.bool,
68
78
  };
69
79
  HeaderContainer.defaultProps = {
70
80
  includeSkipToSidebar: false,
71
81
  showCancelButton: false,
72
82
  skipToContentId: null,
73
83
  isIESupportPage: false,
84
+ showSearchBar: false,
74
85
  };
75
86
 
76
87
  export default HeaderContainer;
@@ -3,12 +3,13 @@ import PropTypes from "prop-types";
3
3
 
4
4
  import { useHeaderState } from "./hooks";
5
5
 
6
- const HeaderLogo = (isDevPre) => {
6
+ const HeaderLogo = ({ isDevPre, hasSearchBar }) => {
7
7
  const { closeMenus, RouterLink } = useHeaderState();
8
- const showDevPre = isDevPre.isDevPre;
9
- if (showDevPre) {
8
+ const searchHeaderClass = hasSearchBar ? " header-logo-search" : "";
9
+ const headerLogoClass = `header-logo${searchHeaderClass}`;
10
+ if (isDevPre) {
10
11
  return (
11
- <div className="header-logo">
12
+ <div className={headerLogoClass}>
12
13
  <img
13
14
  className="qpp-logo"
14
15
  src="/images/qpp_logo_rgb_color.png"
@@ -20,7 +21,7 @@ const HeaderLogo = (isDevPre) => {
20
21
  if (RouterLink) {
21
22
  return (
22
23
  <RouterLink
23
- className="header-logo"
24
+ className={headerLogoClass}
24
25
  to="/"
25
26
  onClick={closeMenus}
26
27
  data-track-category="HeaderNav"
@@ -38,7 +39,7 @@ const HeaderLogo = (isDevPre) => {
38
39
 
39
40
  return (
40
41
  <a
41
- className="header-logo"
42
+ className={headerLogoClass}
42
43
  href="/"
43
44
  data-track-category="HeaderNav"
44
45
  data-track-action="OpenQPPHome"
@@ -54,7 +55,8 @@ const HeaderLogo = (isDevPre) => {
54
55
  };
55
56
 
56
57
  HeaderLogo.propTypes = {
57
- isDevPre: PropTypes.object,
58
+ isDevPre: PropTypes.bool,
59
+ hasSearchBar: PropTypes.bool,
58
60
  };
59
61
 
60
62
  export default HeaderLogo;
@@ -6,8 +6,9 @@ import HeaderContainer from "./HeaderContainer";
6
6
  import HeaderMenuItem from "./HeaderMenuItem";
7
7
  import HeaderMobileButton from "./HeaderMobileButton";
8
8
  import ImpersonatorBanner from "./ImpersonatorBanner";
9
+ import HeaderSearchBar from "../HeaderSearchBar";
9
10
  import HelpIcon from "./HelpIcon";
10
- import { HeaderStateProvider } from "./hooks";
11
+ import { HeaderStateProvider, useWindowWidth } from "./hooks";
11
12
  import defaultContent from "./default-content.json";
12
13
 
13
14
  const HeaderUI = ({
@@ -22,6 +23,7 @@ const HeaderUI = ({
22
23
  }) => {
23
24
  const [isMobileMenuExpanded, setIsMobileMenuExpanded] = useState(false);
24
25
  const [headerContent, setHeaderContent] = useState({});
26
+ const windowWidth = useWindowWidth();
25
27
 
26
28
  const mapContentToRows = (config) => {
27
29
  // Append transposed array to content
@@ -63,22 +65,22 @@ const HeaderUI = ({
63
65
  }, []);
64
66
 
65
67
  const content = mapContentToRows(headerContent?.content);
68
+ const sharedHeaderProps = {
69
+ skipToContentId,
70
+ includeSkipToSidebar,
71
+ showSearchBar: headerContent.showSearchBar,
72
+ };
66
73
 
67
74
  const displayCancelContent = () => (
68
- <HeaderContainer
69
- showCancelButton
70
- skipToContentId={skipToContentId}
71
- includeSkipToSidebar={includeSkipToSidebar}
72
- >
75
+ <HeaderContainer {...sharedHeaderProps} showCancelButton>
73
76
  <HeaderCancel handleCancel={handleCancel} />
74
77
  </HeaderContainer>
75
78
  );
76
79
 
77
80
  const displayDevPreContent = () => (
78
81
  <HeaderContainer
82
+ {...sharedHeaderProps}
79
83
  isIESupportPage={isIESupportPage}
80
- skipToContentId={skipToContentId}
81
- includeSkipToSidebar={includeSkipToSidebar}
82
84
  isDevPre={isDevPre}
83
85
  >
84
86
  <nav aria-label="Primary navigation" hidden={!isMobileMenuExpanded}>
@@ -91,12 +93,13 @@ const HeaderUI = ({
91
93
 
92
94
  const displayHeaderContent = () => (
93
95
  <>
94
- <HeaderContainer
95
- isIESupportPage={isIESupportPage}
96
- skipToContentId={skipToContentId}
97
- includeSkipToSidebar={includeSkipToSidebar}
98
- >
96
+ <HeaderContainer {...sharedHeaderProps} isIESupportPage={isIESupportPage}>
99
97
  <HelpIcon />
98
+ {headerContent.showSearchBar === "true" && windowWidth < 768 ? (
99
+ <div style={{ width: "100%" }}>
100
+ <HeaderSearchBar />
101
+ </div>
102
+ ) : null}
100
103
  <HeaderMobileButton
101
104
  handleClick={() => setIsMobileMenuExpanded(!isMobileMenuExpanded)}
102
105
  isMobileMenuExpanded={isMobileMenuExpanded}
@@ -0,0 +1,80 @@
1
+ import React from "react";
2
+
3
+ const HeaderSearchBar = () => {
4
+ return (
5
+ <div className="qpp-c-search--header-container">
6
+ <div className="qpp-c-search--header-container__block">
7
+ <div className="qpp-c-search--header-container__title">
8
+ Search (beta)
9
+ </div>
10
+ <form
11
+ id="search_form"
12
+ acceptCharset="UTF-8"
13
+ action="https://search.usa.gov/search"
14
+ aria-labelledby="site-search-label"
15
+ role="search"
16
+ method="get"
17
+ className="qpp-c-search qpp-c-search--global qpp-u-width--100"
18
+ >
19
+ <div
20
+ style={{
21
+ margin: "0px",
22
+ padding: "0px",
23
+ display: "inline",
24
+ }}
25
+ >
26
+ <input name="utf8" type="hidden" value="&#x2713;" />
27
+ </div>
28
+ <input id="affiliate" name="affiliate" type="hidden" value="qpp" />
29
+ <label
30
+ id="site-search-label"
31
+ className="qpp-u-visually-hidden"
32
+ htmlFor="query"
33
+ >
34
+ Site Search
35
+ </label>
36
+ <div className="qpp-u-width--100 qpp-u-display--flex">
37
+ <div className="qpp-c-search__wrap">
38
+ <input
39
+ autoComplete="off"
40
+ className="qpp-c-text-input"
41
+ id="query"
42
+ name="query"
43
+ type="text"
44
+ />
45
+ </div>
46
+ <button
47
+ name="commit"
48
+ id="global-search"
49
+ type="submit"
50
+ className="qpp-c-search__submit qpp-c-button qpp-c-button--secondary"
51
+ >
52
+ <span className="qpp-u-visually-hidden">Search</span>
53
+ <svg
54
+ xmlns="http://www.w3.org/2000/svg"
55
+ viewBox="0 0 24 24"
56
+ className="qpp-icon-mat qpp-icon-inline--lg"
57
+ aria-hidden="true"
58
+ focusable="false"
59
+ >
60
+ <path d="M15.5 14h-.79l-.28-.27A6.471 6.471 0 0 0 16 9.5 6.5 6.5 0 1 0 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z" />
61
+ </svg>
62
+ </button>
63
+ </div>
64
+ </form>
65
+ </div>
66
+ <div>
67
+ <a
68
+ className="survey-link"
69
+ href="https://agilesix.qualtrics.com/jfe/form/SV_e3Esl9l6dXWLnwy"
70
+ rel="noreferrer"
71
+ target="_blank"
72
+ >
73
+ Give feedback about the Search experience
74
+ </a>
75
+ </div>
76
+ </div>
77
+ );
78
+ };
79
+
80
+ export default HeaderSearchBar;
@@ -67,6 +67,7 @@ const NavLinkInline = ({
67
67
  data-track-action={`GoTo${label ? label.split(" ").join("") : ""}`}
68
68
  data-track-label={label}
69
69
  aria-label={label}
70
+ data-cy={label}
70
71
  target={`${target ? target : "_self"}`}
71
72
  >
72
73
  <svg