diff --git a/.babelrc b/.babelrc index 5d1b702..1a6c752 100644 --- a/.babelrc +++ b/.babelrc @@ -1 +1,4 @@ -{ "presets": ["react", "es2015"] } +{ + "presets": ["react", "es2015"], + "plugins": ["transform-class-properties"] +} diff --git a/app.js b/app.js index d763964..3992b4c 100644 --- a/app.js +++ b/app.js @@ -18,11 +18,11 @@ const browserHistory = useRouterHistory(createHistory)({ }); ReactDOM.render( - ( - + ( + - {route} + {route} - ), document.getElementById('root') + ), document.getElementById('root') ); diff --git a/js/components/Form.jsx b/js/components/Form.jsx index 82847d9..f551aef 100644 --- a/js/components/Form.jsx +++ b/js/components/Form.jsx @@ -1,12 +1,12 @@ import React from 'react'; -import FormApp from 'us-forms-system/lib/js/containers/FormApp'; +import FormApp from './FormApp'; import formConfig from '../config/form'; export default function Form({ location, children }) { return ( - {children} + {children} ); } diff --git a/js/components/FormApp.jsx b/js/components/FormApp.jsx new file mode 100644 index 0000000..d0a71a6 --- /dev/null +++ b/js/components/FormApp.jsx @@ -0,0 +1,87 @@ +import React from 'react'; +import { connect } from 'react-redux'; +import Scroll from 'react-scroll'; + +import FormNav from 'us-forms-system/lib/js/components/FormNav'; +import FormTitle from 'us-forms-system/lib/js/components/FormTitle'; +import { isInProgress } from 'us-forms-system/lib/js/helpers'; +// import { setGlobalScroll } from 'us-forms-system/lib/js/utilities/ui'; + +const Element = Scroll.Element; + +/* + * Primary component for a schema generated form app. + */ +class FormApp extends React.Component { + componentWillMount() { + // setGlobalScroll(); + + // if (window.History) { + // window.History.scrollRestoration = 'manual'; + // } + } + + render() { + const { currentLocation, formConfig, children, formData } = this.props; + console.log('FormApp'); + console.log(formData); + const trimmedPathname = currentLocation.pathname.replace(/\/$/, ''); + const isIntroductionPage = trimmedPathname.endsWith('introduction'); + const Footer = formConfig.footerContent; + + let formTitle; + let formNav; + let renderedChildren = children; + if (!isIntroductionPage) { + // Show title only if we're not on the intro page and if there is a title + // specified in the form config + if (formConfig.title) { + formTitle = ; + } + } + + // Show nav only if we're not on the intro, form-saved, error, or confirmation page + // Also add form classes only if on an actual form page + if (isInProgress(trimmedPathname)) { + formNav = ; + + renderedChildren = ( +
+ {children} +
+ ); + } + + let footer; + if (Footer) { + footer = ( +