Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable Federalist previews #383

Merged
merged 2 commits into from
Apr 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion config/webpack/webpack.shared.js
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ module.exports = {
appleStartup: false
},
inject: true,
prefix: '/assets/img/favicons',
prefix: join(PUBLIC_PATH, '/assets/img/favicons'),
output: './assets/img/favicons/',
config: {
favicons: true,
Expand Down
4 changes: 2 additions & 2 deletions src/browser-history.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { createBrowserHistory } from 'history'

const history = createBrowserHistory()
const history = createBrowserHistory({ basename: PUBLIC_PATH })

export default history
export default history
2 changes: 1 addition & 1 deletion src/components/about-page/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import Resources from './resources.component'
import MeasuringCode from './measuring-code.component'
import Licensing from './licensing.component'

const abouturl = `${PUBLIC_PATH}about`
const abouturl = `/about`

const links = [
{
Expand Down
22 changes: 2 additions & 20 deletions src/components/app/__snapshots__/app.component.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -30,25 +30,7 @@ exports[`components - App render should render correctly 1`] = `
isDark={true}
/>
<withRouter(Connect(Menu)) />
<Switch
location={
Location {
"assign": [Function],
"hash": "",
"host": "test.com",
"hostname": "test.com",
"href": "http://test.com/",
"origin": "http://test.com",
"pathname": "/",
"port": "",
"protocol": "http:",
"reload": [Function],
"replace": [Function],
"search": "",
"toString": [Function],
}
}
>
<Switch>
<Route
component={[Function]}
exact={true}
Expand Down Expand Up @@ -93,4 +75,4 @@ exports[`components - App render should render correctly 1`] = `
<Connect(Footer) />
</div>
</Connect(ConnectedRouter)>
`
`;
7 changes: 2 additions & 5 deletions src/components/app/app.component.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import Menu from 'components/menu'
import Footer from 'components/footer'
import OfficialBanner from 'components/official-banner'
import PrivacyPolicy from 'components/privacy-policy'
import { refreshView } from 'utils/other'
import { refreshView, isHomepage } from 'utils/other'

export default class AppComponent extends Component {
componentDidMount() {
Expand All @@ -25,15 +25,12 @@ export default class AppComponent extends Component {
}

render() {
const location = window.location
const isHomepage = location.pathname === '/'

return (
<ConnectedRouter history={history}>
<div className="App">
{isHomepage ? <OfficialBanner isDark /> : <OfficialBanner />}
<Menu />
<Switch location={location}>
<Switch>
<Route exact path="/" component={Home} />
<Route path="/search" component={SearchPage} />
<Route path="/about" component={AboutPage} />
Expand Down
9 changes: 3 additions & 6 deletions src/components/footer/footer.container.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
/* global PUBLIC_PATH */
import { connect } from 'react-redux'
import { getConfigValue } from 'utils/other'
import { getConfigValue, isHomepage } from 'utils/other'
import Footer from './footer.component'

export const mapStateToProps = ({ router }) => {
const onHomePage = router.location.pathname === PUBLIC_PATH
return {
export const mapStateToProps = ({ router }) => ({
color: 'white',
links: getConfigValue('content.footer.links'),
logos: getConfigValue('content.footer.logos'),
socials: getConfigValue('content.footer.socials')
}
}
})

export default connect(mapStateToProps)(Footer)
4 changes: 2 additions & 2 deletions src/components/menu/__snapshots__/menu.container.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ Object {
"name": "SOCIAL",
},
],
"onHomePage": false,
"onHomePage": true,
"searchDropdown": "test-search-dropdown",
"siteTitle": "code.gov",
}
`
`;
11 changes: 4 additions & 7 deletions src/components/menu/menu.container.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,19 @@

import { withRouter } from 'react-router-dom'
import { connect } from 'react-redux'
import { getConfigValue } from 'utils/other'
import { getConfigValue, isHomepage } from 'utils/other'
import toggleSearchDropdown from 'actions/toggle-search-dropdown'
import MenuComponent from './menu.component'

export const mapStateToProps = ({ router, searchDropdown }) => {
const onHomePage = router.location.pathname === PUBLIC_PATH
return {
export const mapStateToProps = ({ router, searchDropdown }) => ({
color: 'white',
logoDark: getConfigValue('content.header.logos.dark'),
logoLight: getConfigValue('content.header.logos.light'),
menu: getConfigValue('content.header.menu'),
onHomePage,
onHomePage: isHomepage,
searchDropdown,
siteTitle: getConfigValue('title')
}
}
})

export const mapDispatchToProps = dispatch => ({
toggleSearchDropdown: () => dispatch(toggleSearchDropdown())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

exports[`containers - MobileMenuControl mapStateToProps should return the correct properties 1`] = `
Object {
"color": "dark",
"color": "white",
"displayMobileMenu": true,
}
`
`;
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import { connect } from 'react-redux'
import hideMobileMenu from 'actions/hide-mobile-menu'
import showMobileMenu from 'actions/show-mobile-menu'
import toggleMobileMenu from 'actions/toggle-mobile-menu'
import { refreshView, isHomepage } from 'utils/other'
import MobileMenuControlComponent from './mobile-menu-control.component'

export const mapStateToProps = ({ displayMobileMenu, router }) => {
const onHomePage = router.location.pathname === PUBLIC_PATH
const color = onHomePage ? 'white' : 'dark'
const color = isHomepage ? 'white' : 'dark'
return {
color,
displayMobileMenu
Expand Down
2 changes: 2 additions & 0 deletions src/utils/other.js
Original file line number Diff line number Diff line change
Expand Up @@ -263,3 +263,5 @@ export function prettify(text) {
match => `<br/>${match.replace(/[A-Za-z]{1,25}/, name => `<b>${name}</b>`)}`
)
}

export const isHomepage = window.location.pathname === PUBLIC_PATH
2 changes: 1 addition & 1 deletion styles/theme/_uswds-theme-general.scss
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Relative image file path
----------------------------------------
*/

$theme-image-path: "/uswds/img";
$theme-image-path: "./uswds/img";

/*
----------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion styles/theme/_uswds-theme-typography.scss
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ Relative font file path
----------------------------------------
*/

$theme-font-path: "/uswds/fonts";
$theme-font-path: "./uswds/fonts";

/*
----------------------------------------
Expand Down