Skip to content

Commit

Permalink
Merge pull request kriasoft#44 from kriasoft/new-project-structure
Browse files Browse the repository at this point in the history
Refactor the directory strucure
  • Loading branch information
vishwanatharondekar authored and Vishwanath Arondekar committed Dec 16, 2014
2 parents d65fb55 + 998ebff commit 46115c2
Show file tree
Hide file tree
Showing 14 changed files with 73 additions and 19 deletions.
8 changes: 5 additions & 3 deletions README.md
Expand Up @@ -40,12 +40,14 @@ utilizing a unidirectional data flow.
├── /src/ # The source code of the application
│ ├── /actions/ # Action creators that allow to trigger a dispatch to stores
│ ├── /assets/ # Static files which are copied to ./build on compile
│ ├── /components/ # React components. E.g. Navbar.jsx, Calendar.jsx
│ ├── /components/ # React components
│ │ ├── /common/ # - Shared components. E.g. Link.js
│ │ ├── /forms/ # - Form components. E.g. TextBox.js
│ │ ├── /layout/ # - Layout components. E.g. Navbar.js
│ │ └── /pages/ # - Web-page components. E.g. About.js
│ ├── /constants/ # Enumerations used in action creators and stores
│ ├── /core/ # Core components (Flux dispatcher, base classes)
│ ├── /images/ # Graphics (.png, .jpg, .svg etc.)
│ ├── /layouts/ # Shared layouts for top-level components
│ ├── /pages/ # Top-level, URL-bound React components
│ ├── /stores/ # Stores contain the application state and logic
│ ├── /styles/ # CSS style sheets (or LESS, SASS, Stylus)
│ ├── /app.js # The application's main file (entry point)
Expand Down
5 changes: 3 additions & 2 deletions gulpfile.js
Expand Up @@ -107,7 +107,7 @@ gulp.task('images', function() {

// HTML pages
gulp.task('pages', function() {
src.pages = ['src/pages/**/*.js', 'src/pages/404.html'];
src.pages = ['src/components/pages/**/*.js', 'src/components/pages/404.html'];

var currentPage = {};
var Dispatcher = require('./src/core/Dispatcher');
Expand All @@ -123,7 +123,7 @@ gulp.task('pages', function() {
});

var render = $.render({
template: './src/pages/_template.html',
template: './src/components/pages/index.html',
data: function() { return currentPage; }
})
.on('error', function(err) { console.log(err); render.end(); });
Expand All @@ -137,6 +137,7 @@ gulp.task('pages', function() {
collapseWhitespace: true,
minifyJS: true
}), $.jsbeautifier()))
.pipe($.if('**/home.html', $.rename('index.html')))
.pipe(gulp.dest(DEST))
.pipe($.size({title: 'pages'}));
});
Expand Down
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -31,6 +31,7 @@
"gulp-load-plugins": "^0.8.0",
"gulp-minify-css": "^0.3.11",
"gulp-plumber": "^0.6.6",
"gulp-rename": "^1.2.0",
"gulp-render": "^0.2.1",
"gulp-replace": "^0.5.0",
"gulp-size": "^1.1.0",
Expand Down
4 changes: 2 additions & 2 deletions src/app.js
Expand Up @@ -54,8 +54,8 @@ function render(page) {
// Define URL routes
// See https://github.com/flatiron/director
var routes = {
'/': () => render(require('./pages/Index')),
'/privacy': () => render(require('./pages/Privacy'))
'/': () => render(require('./components/pages/Home')),
'/privacy': () => render(require('./components/pages/Privacy'))
};

// Initialize a router
Expand Down
2 changes: 1 addition & 1 deletion src/components/Link.js → src/components/common/Link.js
Expand Up @@ -9,7 +9,7 @@
'use strict';

var React = require('react');
var RouteActions = require('../actions/RouteActions');
var RouteActions = require('../../actions/RouteActions');

var Link = React.createClass({
propTypes: {
Expand Down
40 changes: 40 additions & 0 deletions src/components/forms/TextBox.js
@@ -0,0 +1,40 @@
/*
* React.js Starter Kit
* Copyright (c) 2014 Konstantin Tarkus (@koistya), KriaSoft LLC.
*
* This source code is licensed under the MIT license found in the
* LICENSE.txt file in the root directory of this source tree.
*/

'use strict';

require('./TextBox.less');

var React = require('react');

var TextBox = React.createClass({

propTypes: {
maxLines: React.PropTypes.number
},

getDefaultProps() {
return {
maxLines: 1
};
},

render() {
return (
<div className="TextBox">
{this.props.maxLines > 1 ?
<textarea {...this.props} className="TextBox-input" ref="input" key="input" rows={this.props.maxLines} /> :
<input {...this.props} className="TextBox-input" ref="input" key="input" />}
</div>
);
}

});

module.exports = TextBox;

10 changes: 10 additions & 0 deletions src/components/forms/TextBox.less
@@ -0,0 +1,10 @@
/*
* React.js Starter Kit
* Copyright (c) 2014 Konstantin Tarkus (@koistya), KriaSoft LLC.
*
* This source code is licensed under the MIT license found in the
* LICENSE.txt file in the root directory of this source tree.
*/

.TextBox {}
.TextBox-input {}
6 changes: 3 additions & 3 deletions src/layouts/DefaultLayout.js → src/components/layout/App.js
Expand Up @@ -9,9 +9,9 @@
'use strict';

var React = require('react');
var PageStore = require('../stores/PageStore');
var Link = require('../components/Link');
var Navbar = require('../components/Navbar');
var PageStore = require('../../stores/PageStore');
var Link = require('../common/Link');
var Navbar = require('../layout/Navbar');

/**
* Retrieves the current page metadata from the PageStore.
Expand Down
Expand Up @@ -9,7 +9,7 @@
'use strict';

var React = require('react');
var Link = require('./Link');
var Link = require('../common/Link');

var Navbar = React.createClass({
render() {
Expand Down
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions src/pages/Index.js → src/components/pages/Home.js
Expand Up @@ -9,13 +9,13 @@
'use strict';

var React = require('react');
var PageActions = require('../actions/PageActions');
var DefaultLayout = require('../layouts/DefaultLayout');
var PageActions = require('../../actions/PageActions');
var App = require('../layout/App');

var HomePage = React.createClass({

statics: {
layout: DefaultLayout
layout: App
},

componentWillMount() {
Expand Down
8 changes: 4 additions & 4 deletions src/pages/Privacy.js → src/components/pages/Privacy.js
Expand Up @@ -9,14 +9,14 @@
'use strict';

var React = require('react');
var PageActions = require('../actions/PageActions');
var DefaultLayout = require('../layouts/DefaultLayout');
var Link = require('../components/Link');
var PageActions = require('../../actions/PageActions');
var App = require('../layout/App');
var Link = require('../common/Link');

var PrivacyPage = React.createClass({

statics: {
layout: DefaultLayout,
layout: App,
breadcrumb: (
<ol className="breadcrumb">
<li><Link to="/">Home</Link></li>
Expand Down
File renamed without changes.

0 comments on commit 46115c2

Please sign in to comment.