-
Notifications
You must be signed in to change notification settings - Fork 25
Nav Component
Richard Davis edited this page Aug 23, 2020
·
2 revisions
The <Nav />
component displays the left-hand side APD Navigation. Its items
are managed by the reducer at web/src/reducers/nav.js
. We use the pathname
and hash
(aka- fragment) as provided by connected-react-router
to determine
how to expand the <Nav />
to the current view, and to highlight the current
nav item.
import React, { useEffect, useState } from 'react';
import { VerticalNav } from '@cmsgov/design-system-core';
import { connect } from 'react-redux';
import NavLink from '../components/NavLink';
import { generateKey as actualGenerateKey } from '../util'
const Nav = ({ generateKey, items, pathname }) => {
// force component update when pathname changes
const [key, setKey] = useState('');
useEffect(() => setKey(generateKey()), [pathname]);
return (
<VerticalNav
component={NavLink}
items={items}
key={key}
/>
)
};
Nav.defaultProps = {
generateKey: actualGenerateKey
}
const mapStateToProps = ({ nav, router }) => ({
items: nav.items,
pathname: router.location.pathname
});
export default connect(mapStateToProps)(Nav);
const initialState = {
activities: [],
continueLink: null,
items: staticItems,
previousLink: null
};
const reducer = (state = initialState, action = {}) => {
switch (action.type) {
case APD_ACTIVITIES_CHANGE: {
return {
...state,
activities: action.activities
};
}
case LOCATION_CHANGE: {
const { pathname, hash } = action.payload.location;
const url = [pathname, hash].join('');
const items = getItems({
activities: state.activities,
items: state.items,
url
});
return {
...state,
items
};
}
default:
return state;
}
};
export default reducer;
- Team Working Agreement
- Team composition
- Workflows and processes
- Testing and bug filing
- Accessing eAPD
- Active Documentation:
- Sandbox Environment
- Glossary of acronyms
- APDs 101
- Design iterations archive
- MMIS Budget calculations
- HITECH Budget calculations
- Beyond the APD: From Paper to Pixels
- UX principles
- User research process
- Visual styling
- Content guide
- User research findings
- eAPD pilot findings
- User needs
- Developer info
- Development environment
- Coding Standards
- Development deployment
- Infrastructure Architecture
- Code Architecture
- Tech 101
- Authentication
- APD Auto Saving Process
- Resetting an Environment
- Hardware Software List
- Deploying Staging Production Instances Using Scripts
- Terraform 101 for eAPD
- Provisioning Infrastructure with Terraform
- WebSocket basics
- Operations-and-Support-Index
- Single Branch Deployment Strategy
- Ops and Support Overview
- Service Level AOI
- Incident Response Plan
- On-Call Policy
- Infrastructure Contingency Plan
- Updating CloudFront Security Headers
- Requesting and Installing TLS Certificates