Skip to content

Commit

Permalink
add initial react app
Browse files Browse the repository at this point in the history
  • Loading branch information
Berkeley Martinez authored and Berkeley Martinez committed Jun 18, 2015
1 parent bfddc03 commit a8540be
Show file tree
Hide file tree
Showing 42 changed files with 299 additions and 244 deletions.
3 changes: 3 additions & 0 deletions client/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
This is the entry point for the client
Code that should only run on the client should be put here.
NOTE(berks): For react specific stuff this should be the entry point
20 changes: 20 additions & 0 deletions client/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import BrowserHistory from 'react-router/lib/BrowserHistory';
import debugFactory from 'debug';
import { Cat } from 'thundercats';

import AppFactory from '../common/app/appFactory';

const debug = debugFactory('fcc:client');
const DOMContianer = document.getElemenetById('#fCC');
const fcc = new Cat();

// returns an observable
fcc.render(AppFactory(BrowserHistory), DOMContianer)
.subscribe(
function() {
debug('react rendered');
},
function(err) {
debug('an error has occured', err.stack);
}
);
25 changes: 25 additions & 0 deletions common/app/App.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import React, { PropTypes } from 'react';

import Nav from './components/Nav';
import Footer from './components/Footer';

export default class extends React.Component {
constructor(props) {
super(props);
}

static displayName = 'FreeCodeCamp'
static propTypes = {
children: PropTypes.node
}

render() {
return (
<div>
<Nav />
{ this.props.children }
<Footer />
</div>
);
}
}
18 changes: 18 additions & 0 deletions common/app/appFactory.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import React from 'react';
import { Router, Route } from 'react-router';

// components
import App from './App.jsx';
import Jobs from './screens/App/screens/Jobs';

module.exports = function appFactory(history) {
return (
<Router history={ history }>
<Route handler={ App }>
<Route
component={ Jobs }
path='/jobs' />
</Route>
</Router>
);
};
50 changes: 50 additions & 0 deletions common/app/components/Footer/Footer.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import React from 'react';
import { Col, Row, Grid } from 'react-bootstrap';

import links from './links.json';

export default class extends React.Component {
static displayName = 'Footer'
renderLinks(mobile) {
return links.map(link => {
return (
<a
className={ link.className}
href={ link.href }
target={ link.target }>
{ this.renderContent(mobile, link.content) }
</a>
);
});
}

renderContent(mobile, content) {
if (mobile) {
return (
<span className='sr-only'>
content;
</span>
);
}
return content;
}

render() {
return (
<Grid className='fcc-footer'>
<Row>
<Col
className='hidden-xs hidden-sm'
xs={ 12 }>
{ this.renderLinks() }
</Col>
<Col
className='visible-xs visible-sm'
xs={ 12 }>
{ this.renderLinks(true) }
</Col>
</Row>
</Grid>
);
}
}
1 change: 1 addition & 0 deletions common/app/components/Footer/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default as Footer } from './Footer.jsx';
44 changes: 44 additions & 0 deletions common/app/components/Footer/links.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
[
{
"className": "ion-speakerphone",
"content": "&nbsp;Blog&nbsp;&nbsp;",
"href": "http://blog.freecodecamp.com",
"target": "_blank"
},
{
"className": "ion-social-twitch-outline",
"content": "&nbsp;Twitch&nbsp;&nbsp;",
"href": "http://www.twitch.tv/freecodecamp",
"target": "_blank"
},
{
"className": "ion-social-github",
"content": "&nbsp;Github&nbsp;&nbsp;",
"href": "http://github.com/freecodecamp",
"target": "_blank"
},
{
"className": "ion-social-twitter",
"content": "&nbsp;Twitter&nbsp;&nbsp;",
"href": "http://twitter.com/freecodecamp",
"target": "_blank"
},
{
"className": "ion-social-facebook",
"content": "&nbsp;Facebook&nbsp;&nbsp;",
"href": "http://facebook.com/freecodecamp",
"target": "_blank"
},
{
"className": "ion-information-circled",
"content": "&nbsp;About&nbsp;&nbsp;",
"href": "/learn-to-code",
"target": "_self"
},
{
"className": "ion-locked",
"content": "&nbsp;Privacy&nbsp;&nbsp;",
"href": "/privacy'",
"target": "_self"
}
]
55 changes: 26 additions & 29 deletions common/screens/nav/Nav.jsx → common/app/components/Nav/Nav.jsx
Original file line number Diff line number Diff line change
@@ -1,31 +1,30 @@
var React = require('react'),
bootStrap = require('react-bootstrap'),
Navbar = bootStrap.Navbar,
Nav = bootStrap.Nav,
NavItem = bootStrap.NavItem,
NavItemFCC = require('./NavItem.jsx');
import React from 'react';
import { Nav, Navbar, NavItem } from 'react-bootstrap';
import NavItemFCC from './NavItem.jsx';

var NavBarComp = React.createClass({

propTypes: { signedIn: React.PropTypes.bool },
export default class extends React.Component {
constructor(props) {
super(props);
}

getDefaultProps: function() {
return { signedIn: false };
},
static displayName = 'Nav'
static propTypes = {
signedIn: React.PropTypes.bool
}

_renderBrand: function() {
renderBrand() {
var fCClogo = 'https://s3.amazonaws.com/freecodecamp/freecodecamp_logo.svg';
return (
<a href='/'>
<img
src={ fCClogo }
alt='learn to code javascript at Free Code Camp logo'
className='img-responsive nav-logo' />
className='img-responsive nav-logo'
src={ fCClogo } />
</a>
);
},
}

_renderSignin: function() {
renderSignin() {
if (this.props.signedIn) {
return (
<NavItem
Expand All @@ -36,27 +35,26 @@ var NavBarComp = React.createClass({
} else {
return (
<NavItemFCC
aClassName='btn signup-btn signup-btn-nav'
eventKey={ 2 }
href='/login'
aClassName='btn signup-btn signup-btn-nav'>
Sign In
href='/login'>
Sign In
</NavItemFCC>
);
}
},

render: function() {
}

render() {
return (
<Navbar
brand={ this._renderBrand() }
className='nav-height'
fixedTop={ true }
toggleNavKey={ 0 }
className='nav-height'>
toggleNavKey={ 0 }>
<Nav
right={ true }
className='hamburger-dropdown'
eventKey={ 0 }
className='hamburger-dropdown'>
right={ true }>
<NavItem
eventKey={ 1 }
href='/Challenges'>
Expand All @@ -77,5 +75,4 @@ var NavBarComp = React.createClass({
</Navbar>
);
}
});
module.exports = NavBarComp;
}
File renamed without changes.
1 change: 1 addition & 0 deletions common/app/components/Nav/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default as Nav } from './Nav.jsx';
1 change: 1 addition & 0 deletions common/app/components/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
things like NavBar and Footer go here
1 change: 1 addition & 0 deletions common/app/routes/Admin/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
in case we ever want an admin panel
File renamed without changes.
1 change: 1 addition & 0 deletions common/app/routes/Bonfires/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This folder contains things relative to the bonfires screens
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 6 additions & 0 deletions common/app/routes/Bonfires/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export default {
path: 'bonfires/(:bonfireName)',
getComponents(cb) {
// TODO(berks): add bonfire component
}
};
1 change: 1 addition & 0 deletions common/app/routes/FAVS/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
future home of FAVS app
1 change: 1 addition & 0 deletions common/app/routes/Jobs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This folder contains everything relative to Jobs board
15 changes: 15 additions & 0 deletions common/app/routes/Jobs/components/Actions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { Actions } from 'thundercats';

export default class JobsActions extends Actions {
constructor() {
super();
}
static displayName = 'JobsActions'

getJob(id) {
return { id };
}
getJobs(params) {
return { params };
}
}
28 changes: 28 additions & 0 deletions common/app/routes/Jobs/components/Jobs.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import React, { PropTypes } from 'react';
import { createContainer } from 'thundercats';
import { Grid, Row } from 'react-bootstrap';

@createContainer({
store: 'JobsStore'
})
export default class extends React.Component {
constructor(props) {
super(props);
}


static displayName = 'Jobs'
static propTypes = {
jobs: PropTypes.array
}

render() {
return (
<Grid>
<Row>
foo
</Row>
</Grid>
);
}
}
13 changes: 13 additions & 0 deletions common/app/routes/Jobs/components/List.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import React, { PropTypes } from 'react';

export default class extends React.Component {
constructor(props) {
super(props);
}

static displayName = 'JobsList'
static propTypes = {}
render() {
return null;
}
}
9 changes: 9 additions & 0 deletions common/app/routes/Jobs/components/Store.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { Store } from 'thundercats';

export default class JobsStore extends Store {
constructor(cat) {
super();
let JobsActions = cat.getActions('JobsActions');
}
static displayName = 'JobsStore'
}
19 changes: 19 additions & 0 deletions common/app/routes/Jobs/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
* show: /jobs
* showOne: /jobs/:id
* edit /jobs/:id
* delete /jobs/:id
* createOne /jobs/new
*/

export default {
path: '/jobs/(:jobId)',

getComponents(cb) {
require.ensure([], require => {
cb(null, [
require('./components/Jobs')
]);
});
}
};
11 changes: 11 additions & 0 deletions common/app/routes/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
export default {
path: '/',
getRoutes(cb) {
require.ensure([], require => {
cb(null, [
// require('./Bonfires'),
require('./Jobs')
]);
});
}
};
1 change: 1 addition & 0 deletions common/app/shared/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Here is where all components that are shared between multiple views
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit a8540be

Please sign in to comment.