Skip to content

Commit 9f059df

Browse files
authored
Hide new USWDS footer behind feature flag (#1287)
Contributes to the feature branch #1285 Hej @snmln ! Thanks for setting up the feature branch and foundations for the new footer component! I renamed the old footer to PageFooterLegacy, that way we can use the regular import path for our new footer component. Also added a .env var that allows us to switch between old and new footer implementations easily. Campground Rule[^1]: While working on the feature flag, I addressed an unrelated lint warning within the files I made changes to. [^1]: Always leave the campground cleaner than you found it.
2 parents 7f300ea + f838337 commit 9f059df

File tree

5 files changed

+50
-38
lines changed

5 files changed

+50
-38
lines changed

.env

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,5 @@ GOOGLE_FORM = 'https://docs.google.com/forms/d/e/1FAIpQLSfGcd3FDsM3kQIOVKjzdPn4f
1414

1515
SHOW_CONFIGURABLE_COLOR_MAP = 'TRUE'
1616

17+
# Enables the refactor page footer component that uses the USWDS design system
18+
ENABLE_USWDS_PAGE_FOOTER = 'TRUE'

app/scripts/components/common/layout-root/index.tsx

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,11 @@ import styled from 'styled-components';
1111
import { Outlet } from 'react-router';
1212
import { reveal } from '@devseed-ui/animation';
1313
import { getBannerFromVedaConfig, getCookieConsentFromVedaConfig } from 'veda';
14+
1415
import MetaTags from '../meta-tags';
15-
import PageFooter from '../page-footer/index';
16+
import PageFooter from '../page-footer';
17+
import PageFooterLegacy from '../page-footer-legacy';
18+
1619
const Banner = React.lazy(() => import('../banner'));
1720
const CookieConsent = React.lazy(() => import('../cookie-consent'));
1821

@@ -26,9 +29,11 @@ import {
2629
mainNavItems,
2730
subNavItems
2831
} from '$components/common/page-header/default-config';
32+
import { checkEnvFlag } from '$utils/utils';
2933

3034
const appTitle = process.env.APP_TITLE;
3135
const appDescription = process.env.APP_DESCRIPTION;
36+
const isUSWDSEnabled = checkEnvFlag(process.env.ENABLE_USWDS_PAGE_FOOTER);
3237

3338
export const PAGE_BODY_ID = 'pagebody';
3439

@@ -58,7 +63,8 @@ function LayoutRoot(props: { children?: ReactNode }) {
5863
useEffect(() => {
5964
// When there is no cookie consent form set up
6065
!cookieConsentContent && setGoogleTagManager();
61-
}, []);
66+
// eslint-disable-next-line react-hooks/exhaustive-deps
67+
}, []); // Empty dependency array ensures this effect runs only once, and not during SSR
6268

6369
const { title, thumbnail, description, hideFooter } =
6470
useContext(LayoutRootContext);
@@ -98,7 +104,11 @@ function LayoutRoot(props: { children?: ReactNode }) {
98104
/>
99105
)}
100106
</PageBody>
101-
<PageFooter hideFooter />
107+
{isUSWDSEnabled ? (
108+
<PageFooter />
109+
) : (
110+
<PageFooterLegacy hideFooter={hideFooter} />
111+
)}
102112
</Page>
103113
);
104114
}

app/scripts/components/common/page-footer.js renamed to app/scripts/components/common/page-footer-legacy.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ const InfoList = styled.dl`
109109
}
110110
`;
111111

112-
function PageFooter(props) {
112+
function PageFooterLegacy(props) {
113113
const nowDate = new Date();
114114

115115
return (
@@ -174,8 +174,8 @@ function PageFooter(props) {
174174
);
175175
}
176176

177-
export default PageFooter;
177+
export default PageFooterLegacy;
178178

179-
PageFooter.propTypes = {
179+
PageFooterLegacy.propTypes = {
180180
isHidden: T.bool
181181
};

app/scripts/components/common/page-footer/index.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,9 @@ import {
77
USWDSFooterNav,
88
USWDSLogo
99
} from '$components/common/uswds';
10-
export default function PageFooter(hideFooter) {
10+
export default function PageFooter() {
1111
return (
1212
<>
13-
{/* //commenting out hidefooter functionality for inflight work{!hideFooter && ( */}
1413
<USWDSFooter
1514
size='slim'
1615
// returnToTop={returnToTop}
@@ -41,7 +40,6 @@ export default function PageFooter(hideFooter) {
4140
/>
4241
}
4342
/>
44-
{/* )} */}
4543
</>
4644
);
4745
}

app/scripts/components/home/index.tsx

Lines changed: 31 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,9 @@ import {
2424
ComponentOverride,
2525
ContentOverride
2626
} from '$components/common/page-overrides';
27+
import { checkEnvFlag } from '$utils/utils';
2728

28-
29+
const isUSWDSEnabled = checkEnvFlag(process.env.ENABLE_USWDS_PAGE_FOOTER);
2930
const homeContent = getOverride('homeContent');
3031

3132
const Connections = styled(Hug)`
@@ -113,10 +114,10 @@ const getCoverProps = () => {
113114

114115
return author
115116
? {
116-
...coverProps,
117-
attributionAuthor: author.name,
118-
attributionUrl: author.url
119-
}
117+
...coverProps,
118+
attributionAuthor: author.name,
119+
attributionUrl: author.url
120+
}
120121
: coverProps;
121122
} else {
122123
return {
@@ -171,36 +172,37 @@ function RootHome() {
171172
</ComponentOverride>
172173

173174
<ContentOverride with='homeContent'>
174-
175175
<Audience />
176176

177177
<FeaturedStories />
178178

179179
<ValueProposition />
180180

181-
<Connections>
182-
<ConnectionsBlock>
183-
<ConnectionsBlockTitle>About</ConnectionsBlockTitle>
184-
<ConnectionsList>
185-
<li>
186-
<Link to='/about'>
187-
<CollecticonChevronRightSmall /> Learn more
188-
</Link>
189-
</li>
190-
<li>
191-
<a
192-
href='#'
193-
onClick={(e) => {
194-
e.preventDefault();
195-
showFeedbackModal();
196-
}}
197-
>
198-
<CollecticonChevronRightSmall /> Give feedback
199-
</a>
200-
</li>
201-
</ConnectionsList>
202-
</ConnectionsBlock>
203-
</Connections>
181+
{!isUSWDSEnabled && (
182+
<Connections>
183+
<ConnectionsBlock>
184+
<ConnectionsBlockTitle>About</ConnectionsBlockTitle>
185+
<ConnectionsList>
186+
<li>
187+
<Link to='/about'>
188+
<CollecticonChevronRightSmall /> Learn more
189+
</Link>
190+
</li>
191+
<li>
192+
<a
193+
href='#'
194+
onClick={(e) => {
195+
e.preventDefault();
196+
showFeedbackModal();
197+
}}
198+
>
199+
<CollecticonChevronRightSmall /> Give feedback
200+
</a>
201+
</li>
202+
</ConnectionsList>
203+
</ConnectionsBlock>
204+
</Connections>
205+
)}
204206
</ContentOverride>
205207
</PageMainContent>
206208
);

0 commit comments

Comments
 (0)