Skip to content

Commit 91fce81

Browse files
authored
Merge pull request #4495 from fedspendingtransparency/fix/DEV12045
Fix/dev12045 - Make InfoBanner component more dynamic
2 parents 8ce90ce + 9cbf257 commit 91fce81

File tree

5 files changed

+61
-28
lines changed

5 files changed

+61
-28
lines changed

src/_scss/core/_variables.scss

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ $font-bold: 700;
4444
$image-path: './img';
4545

4646
// USWDS Color Tokens
47+
$orange-5v: #FEF2E4;
48+
$orange-20v: #FFBC78;
4749
$orange-30v: #FA9441;
4850
$orange-warm-40v: #FF580A;
4951
$orange-warm-10v: #ffe2d1;
@@ -71,6 +73,8 @@ $blue-60v: #005ea2;
7173
$blue-70v: #0B4778;
7274
$blue-80v: #112f4e;
7375
$blue-cool-5v: #e1f3f8;
76+
$blue-cool-20v: #97d4ea;
77+
$blue-cool-30v: #59b9de;
7478
$blue-cool-60v: #07648d;
7579
$blue-cool-80v: #002d3f;
7680
$blue-vivid-5v: #e8f5ff;
@@ -107,6 +111,9 @@ $gray-cool-5: #edeff0;
107111
$gray-cool-10: #dfe1e2;
108112
$gray-cool-20: #c6cace;
109113
$gray-cool-90: #1c1d1f;
114+
$green-cool-5v: #E3F5E1;
115+
$green-cool-20v: #70E17B;
116+
$green-cool-30v: #21C834;
110117

111118
// Theme Colors
112119
$theme-color-1: $blue-50;

src/_scss/layouts/default/header/_warning.scss

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,23 @@
7979
padding: rem(5) 0;
8080
color: $gray-cool-90;
8181
}
82+
83+
}
84+
85+
&.general {
86+
border-top: 4px solid $blue-cool-30v;
87+
background-color: $blue-cool-5v;
88+
border-bottom: 1px solid $blue-cool-20v;
89+
}
90+
&.warning {
91+
border-top: 4px solid $orange-30v;
92+
background-color: $orange-5v;
93+
border-bottom: 1px solid $orange-20v;
94+
}
95+
&.warning-resolved {
96+
border-top: 4px solid $green-cool-30v;
97+
background-color: $green-cool-5v;
98+
border-bottom: 1px solid $green-cool-20v;
8299
}
83100

84101
&.info-banner_warning {

src/js/GlobalConstants.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ const globalConstants = {
2828
isActive: false,
2929
title: 'Recipient Filter',
3030
content: 'There is currently a bug affecting the Recipient Filter feature of our service. We appreciate your understanding and patience as we work to fix this issue. Please contact our service desk for additional assistance.',
31-
page: 'search'
31+
page: 'search',
32+
type: "warning" // three options "general", "warning", "warning-resolved"
3233
}
3334
};
3435

src/js/components/sharedComponents/header/Header.jsx

Lines changed: 31 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import InfoBanner from './InfoBanner';
1212

1313
const Header = () => {
1414
const location = useLocation();
15+
const bannerType = GlobalConstants?.BANNER?.type || "";
1516

1617
const skippedNav = (e) => {
1718
// don't update the URL due to potential React Router conflicts
@@ -38,6 +39,31 @@ const Header = () => {
3839
return false;
3940
};
4041

42+
const getIcon = (type) => {
43+
let icon = "";
44+
45+
switch (type) {
46+
case "general":
47+
icon = <FontAwesomeIcon size="lg" icon="info-circle" color="#59b9de" />;
48+
break;
49+
50+
case "warning":
51+
icon = <FontAwesomeIcon size="lg" icon="exclamation-triangle" color="#FA9441" />;
52+
break;
53+
54+
case "warning-resolved":
55+
icon = <FontAwesomeIcon size="lg" icon="check-circle" color="#21C834" />;
56+
break;
57+
58+
default:
59+
break;
60+
}
61+
62+
63+
return icon;
64+
};
65+
66+
4167
return (
4268
<div className="site-header">
4369
<a
@@ -53,25 +79,11 @@ const Header = () => {
5379
<NavbarWrapper />
5480
</header>
5581
{isBannerActive() &&
56-
<InfoBanner
57-
icon={<FontAwesomeIcon size="lg" icon="exclamation-triangle" color="#FA9441" />}
58-
// GENERAL NOTIFICATION
59-
// borderTopColor="#59b9de"
60-
// backgroundColor="#e1f3f8"
61-
// borderBottomColor="#97d4ea"
62-
// color="#59B9DE" (info-circle use for fontawesomeicon above)
63-
// WARNING
64-
borderTopColor="#FA9441"
65-
backgroundColor="#FEF2E4"
66-
borderBottomColor="#FFBC78"
67-
// color="#FA9441" (exclamation-triangle use for fontawesomeicon above)
68-
// WARNING RESOLVED
69-
// borderTopColor="#21C834"
70-
// backgroundColor="#E3F5E1"
71-
// borderBottomColor="#70E17B"
72-
// color="#21C834" (check-circle use for fontawesomeicon above)
73-
title={GlobalConstants?.BANNER?.isActive ? GlobalConstants.BANNER.title : ""}
74-
content={GlobalConstants.BANNER.isActive ? GlobalConstants.BANNER.content : ""} />}
82+
<InfoBanner
83+
icon={getIcon(bannerType)}
84+
type={bannerType}
85+
title={GlobalConstants?.BANNER?.isActive ? GlobalConstants.BANNER.title : ""}
86+
content={GlobalConstants.BANNER.isActive ? GlobalConstants.BANNER.content : ""} />}
7587
<AboutTheDataContainer />
7688
<GlossaryContainer />
7789
<GlobalModalContainer />

src/js/components/sharedComponents/header/InfoBanner.jsx

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ const propTypes = {
1010
closeBanner: PropTypes.func,
1111
title: oneOfType([PropTypes.string, PropTypes.object]),
1212
content: oneOfType([PropTypes.string, PropTypes.object]),
13-
icon: oneOfType([PropTypes.string, PropTypes.object])
13+
icon: oneOfType([PropTypes.string, PropTypes.object]),
14+
type: oneOfType([PropTypes.string, PropTypes.object])
1415
};
1516

1617
const InfoBanner = (props) => {
@@ -33,13 +34,8 @@ const InfoBanner = (props) => {
3334

3435
return (
3536
<div
36-
className="info-banner"
37-
style={{
38-
display: `${closeBanner ? 'none' : ''}`,
39-
backgroundColor: props.backgroundColor,
40-
borderTop: `${props.borderTopColor !== '' ? `4px solid ${props.borderTopColor}` : ''}`,
41-
borderBottom: `${props.borderBottomColor !== '' ? `1px solid ${props.borderBottomColor}` : ''}`
42-
}}>
37+
className={`info-banner ${props.type || ""}`}
38+
style={{ display: `${closeBanner ? 'none' : ''}` }}>
4339
<div className="info-banner__content">
4440
<div className="info-banner__icon">
4541
{props.icon}

0 commit comments

Comments
 (0)