diff --git a/common/app/Nav/links.json b/common/app/Nav/links.json index 03a3acc911..2e47b55a42 100644 --- a/common/app/Nav/links.json +++ b/common/app/Nav/links.json @@ -7,5 +7,9 @@ "content": "Forum", "link": "https://forum.freecodecamp.org/", "target": "_blank" + }, + { + "content": "News", + "link": "https://www.freecodecamp.org/news" } ] \ No newline at end of file diff --git a/news/NewsApp.js b/news/NewsApp.js index cd8a037755..6a528d2340 100644 --- a/news/NewsApp.js +++ b/news/NewsApp.js @@ -1,10 +1,20 @@ import React from 'react'; +import { Grid } from 'react-bootstrap'; + +import { FullWidthRow } from '../common/app/helperComponents'; +import Nav from './components/Nav'; +import { routes } from './routes'; const propTypes = {}; function NewsApp() { return ( -

This is the news!

+
+
); } diff --git a/news/index.js b/news/client.js similarity index 65% rename from news/index.js rename to news/client.js index 6dbca1a30e..b7c53e4f21 100644 --- a/news/index.js +++ b/news/client.js @@ -1,12 +1,19 @@ import React from 'react'; +import {BrowserRouter} from 'react-router-dom'; import { render } from 'react-dom'; import NewsApp from './NewsApp'; const newsMountPoint = document.getElementById('news-app-mount'); +const App = ( + + + +); + render( - , + App, newsMountPoint, () => console.log('react has rendered and is ready to go go go go go go!!') ); diff --git a/news/components/Nav/LargeNav.js b/news/components/Nav/LargeNav.js new file mode 100644 index 0000000000..f6d431a528 --- /dev/null +++ b/news/components/Nav/LargeNav.js @@ -0,0 +1,38 @@ +import React from 'react'; +import Media from 'react-media'; +import { Col, Navbar, Row } from 'react-bootstrap'; +import FCCSearchBar from 'react-freecodecamp-search'; +import NavLogo from './components/NavLogo'; +import NavLinks from './components/NavLinks'; + +import propTypes from './navPropTypes'; + +function LargeNav({ clickOnLogo }) { + return ( + ( + + + + + + + + + + + + + + ) + } + /> + ); +} + +LargeNav.displayName = 'LargeNav'; +LargeNav.propTypes = propTypes; + +export default LargeNav; diff --git a/news/components/Nav/MediumNav.js b/news/components/Nav/MediumNav.js new file mode 100644 index 0000000000..fd03c86802 --- /dev/null +++ b/news/components/Nav/MediumNav.js @@ -0,0 +1,42 @@ +import React from 'react'; +import Media from 'react-media'; +import { Navbar, Row } from 'react-bootstrap'; +import FCCSearchBar from 'react-freecodecamp-search'; +import NavLogo from './components/NavLogo'; +import NavLinks from './components/NavLinks'; +import propTypes from './navPropTypes'; + +function MediumNav({ clickOnLogo }) { + return ( + + { + matches => matches && typeof window !== 'undefined' && ( +
+ + +
+ + + +
+
+ + + + + + + +
+ ) + } + + ); +} + +MediumNav.displayName = 'MediumNav'; +MediumNav.propTypes = propTypes; + +export default MediumNav; diff --git a/news/components/Nav/Nav.js b/news/components/Nav/Nav.js new file mode 100644 index 0000000000..5ad44e7036 --- /dev/null +++ b/news/components/Nav/Nav.js @@ -0,0 +1,31 @@ +import React from 'react'; +import { Navbar } from 'react-bootstrap'; + +import LargeNav from './LargeNav'; +import MediumNav from './MediumNav'; +import SmallNav from './SmallNav'; + +const allNavs = [ + LargeNav, + MediumNav, + SmallNav +]; + +export default function FCCNav() { + const withNavProps = Component => ( + + ); + return ( + + { + allNavs.map(withNavProps) + } + + ); +} diff --git a/news/components/Nav/SmallNav.js b/news/components/Nav/SmallNav.js new file mode 100644 index 0000000000..8c988aa919 --- /dev/null +++ b/news/components/Nav/SmallNav.js @@ -0,0 +1,44 @@ +import React from 'react'; +import Media from 'react-media'; +import { Navbar, Row } from 'react-bootstrap'; +import FCCSearchBar from 'react-freecodecamp-search'; +import NavLogo from './components/NavLogo'; +import NavLinks from './components/NavLinks'; + +import propTypes from './navPropTypes'; + +function SmallNav({ clickOnLogo }) { + return ( + + { + matches => matches && typeof window !== 'undefined' && ( +
+ + +
+ + +
+
+ + + + + + + + + +
+ ) + } + + ); +} + +SmallNav.displayName = 'SmallNav'; +SmallNav.propTypes = propTypes; + +export default SmallNav; diff --git a/news/components/Nav/components/NavLinks.js b/news/components/Nav/components/NavLinks.js new file mode 100644 index 0000000000..c4c878fcd8 --- /dev/null +++ b/news/components/Nav/components/NavLinks.js @@ -0,0 +1,38 @@ +import React from 'react'; +import { NavItem, Nav } from 'react-bootstrap'; +import { startCase } from 'lodash'; + +const urls = { + curriculum: 'https://learn.freecodecamp.org', + forum: 'https://forum.freecodecamp.org', + news: 'https://freecodecamp.org/news' +}; + +const Links = Object.keys(urls).map(key => ( + + {startCase(key)} + +)); +const propTypes = {}; + +function NavLinks() { + return ( + + ); +} + +NavLinks.displayName = 'NavLinks'; +NavLinks.propTypes = propTypes; + +export default NavLinks; + +/* + + */ diff --git a/news/components/Nav/components/NavLogo.js b/news/components/Nav/components/NavLogo.js new file mode 100644 index 0000000000..b65e484ce7 --- /dev/null +++ b/news/components/Nav/components/NavLogo.js @@ -0,0 +1,41 @@ +import React from 'react'; +import { NavbarBrand } from 'react-bootstrap'; +import Media from 'react-media'; + +const fCClogo = 'https://s3.amazonaws.com/freecodecamp/freecodecamp_logo.svg'; +const fCCglyph = 'https://s3.amazonaws.com/freecodecamp/FFCFire.png'; + +const propTypes = {}; + +function NavLogo() { + return ( + + + + { + matches => matches ? ( + learn to code javascript at freeCodeCamp logo + ) : ( + learn to code javascript at freeCodeCamp logo + ) + } + + + + ); +} + +NavLogo.displayName = 'NavLogo'; +NavLogo.propTypes = propTypes; + +export default NavLogo; diff --git a/news/components/Nav/index.js b/news/components/Nav/index.js new file mode 100644 index 0000000000..13fa327162 --- /dev/null +++ b/news/components/Nav/index.js @@ -0,0 +1 @@ +export { default } from './Nav'; diff --git a/news/components/Nav/navPropTypes.js b/news/components/Nav/navPropTypes.js new file mode 100644 index 0000000000..1f3348ba74 --- /dev/null +++ b/news/components/Nav/navPropTypes.js @@ -0,0 +1,3 @@ +// import PropTypes from 'prop-types'; + +export default {}; diff --git a/server/boot/news.js b/server/boot/news.js index 14628b7ea2..a663c3036b 100644 --- a/server/boot/news.js +++ b/server/boot/news.js @@ -1,15 +1,24 @@ import React from 'react'; import { renderToString } from 'react-dom/server'; +import { StaticRouter } from 'react-router-dom'; import NewsApp from '../../news/NewsApp'; +function serveNewsApp(req, res) { + const context = {}; + const markup = renderToString( + + + + ); + return res.render('layout-news', { title: 'News | freeCodeCamp', markup }); +} + export default function newsBoot(app) { const router = app.loopback.Router(); - router.get('/', (req, res) => { - const markup = renderToString(); - return res.render('layout-news', {title: 'Hello News?', markup}); - }); + router.get('/news', serveNewsApp); + router.get('/news/*', serveNewsApp); - app.use('/news', router); + app.use(router); }