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

Changed markup to plain html, added linting to npm scripts; added editorconfig file #37

Merged
merged 8 commits into from
Sep 26, 2016
6 changes: 6 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[*]
trim_trailing_whitespace = true
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 4
5 changes: 1 addition & 4 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,10 @@
"react/no-unknown-property": 1,
"react/prop-types": 1,
"react/react-in-jsx-scope": 1,
"react/require-extension": 1,
"react/self-closing-comp": 1,
"react/sort-comp": 1,
"react/sort-prop-types": 1,
"react/wrap-multilines": 1,
"react/no-did-mount-set-state": [1, "allow-in-func"],
"react/no-did-update-set-state": [1, "allow-in-func"],
"react/jsx-wrap-multilines": 1,
"react/jsx-boolean-value": 1,
"react/jsx-closing-bracket-location": [1, "tag-aligned"],
"react/jsx-curly-spacing": [2, "never"],
Expand Down
70 changes: 70 additions & 0 deletions bootstrap.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
'use strict';
// ## bootstrap-webpack Configuration

module.exports = {
// ### Scripts
// Any scripts here set to false will never
// make it to the client, it's not packaged
// by webpack.
scripts: {
'transition': true,
'alert': true,
'button': true,
'carousel': true,
'collapse': true,
'dropdown': true,
'modal': true,
'tooltip': true,
'popover': true,
'scrollspy': true,
'tab': true,
'affix': true
},
// ### Styles
// Enable or disable certain less components and thus remove
// the css for them from the build.
styles: {
'mixins': true,

'normalize': true,
'print': true,

'scaffolding': true,
'type': true,
'code': true,
'grid': true,
'tables': true,
'forms': true,
'buttons': true,

'component-animations': true,
'glyphicons': true,
'dropdowns': true,
'button-groups': true,
'input-groups': true,
'navs': true,
'navbar': true,
'breadcrumbs': true,
'pagination': true,
'pager': true,
'labels': true,
'badges': true,
'jumbotron': true,
'thumbnails': true,
'alerts': true,
'progress-bars': true,
'media': true,
'list-group': true,
'panels': true,
'wells': true,
'close': true,

'modals': true,
'tooltip': true,
'popovers': true,
'carousel': true,

'utilities': true,
'responsive-utilities': true
}
};
Empty file added bootstrap.config.less
Empty file.
24 changes: 19 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"description": "",
"main": "src/server.js",
"scripts": {
"start": "node --harmony_destructuring ./src/server.js",
"start": "node ./src/server.js",
"lint": "eslint . --ignore-path .gitignore --ignore-pattern webpack.config.js",
"build:dev": "webpack --colors --watch"
},
"repository": {
Expand All @@ -18,23 +19,33 @@
},
"homepage": "https://github.com/kjendrzyca/corpo-food#readme",
"devDependencies": {
"eslint": "^3.6.0",
"eslint-plugin-react": "^6.3.0"
},
"dependencies": {
"babel-core": "^6.7.2",
"babel-loader": "^6.2.4",
"babel-preset-es2015": "^6.6.0",
"babel-preset-react": "^6.5.0",
"babel-preset-stage-0": "^6.5.0",
"webpack": "^1.12.14"
},
"dependencies": {
"bcrypt-nodejs": "0.0.3",
"body-parser": "^1.15.0",
"bootstrap": "^3.3.7",
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like dependencies and devDependencies are mixed up.
Everything that would be needed to build the app on production should listed as "dependencies" node. Things that are not for production like mocha should be listed as "devDependencies".
webpack/webpack#520

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

true

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't mocha also be in the dependencies to allow for
export NODE_ENV=production && npm i && npm test to be able to run tests using mocha under production environment? Otherwise you would have to remember (and the CI system) to set NODE_ENV to development before npm i

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fair point! I'm not sure if that is a common practice, to be honest
on production environment I'd go for running integration/smoke tests that treat the application as a black box
but if they treat it as a black box and use public api, it doesn't matter where they're run, they just need access to a running app
also, we don't have any tests here which is a whole other story

"bootstrap-webpack": "0.0.5",
"css-loader": "^0.25.0",
"exports-loader": "^0.6.3",
"express": "^4.13.4",
"extract-text-webpack-plugin": "^1.0.1",
"file-loader": "^0.9.0",
"imports-loader": "^0.6.5",
"jquery": "^3.1.0",
"less": "^2.7.1",
"less-loader": "^2.2.3",
"http-status": "^0.2.0",
"locale": "0.0.21",
"mongoose": "^4.4.8",
"node-polyglot": "^1.0.0",
"react": "^0.14.7",
"react-bootstrap": "^0.29.0",
"react-dom": "^0.14.7",
"react-redux": "^4.4.1",
"react-router": "^2.0.1",
Expand All @@ -43,6 +54,9 @@
"redux-thunk": "^2.0.1",
"socket.io": "^1.4.5",
"socket.io-client": "^1.4.5",
"style-loader": "^0.13.1",
"url-loader": "^0.5.7",
"webpack": "^1.12.14",
"whatwg-fetch": "^0.11.0",
"winston": "^2.2.0"
}
Expand Down
25 changes: 12 additions & 13 deletions src/components/app.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React from 'react';
import DOM from 'react-dom';
import {Grid, Row, Col, PageHeader} from 'react-bootstrap';
import {createStore, combineReducers, applyMiddleware} from 'redux';
import {Provider, connect} from 'react-redux';
import {browserHistory, Router, Route, IndexRoute} from 'react-router';
Expand Down Expand Up @@ -44,22 +43,22 @@ const App = connect(state => ({

render () {
return (
<Grid>
<Row>
<Col xs={12}>
<PageHeader>
<div className="container">
<div className="row">
<div className="col-xs-12">
<h1>
{this.props.resources.appName}
<small>{this.props.resources.uniqueValueProposition}</small>
</PageHeader>
</Col>
</Row>
</h1>
</div>
</div>
<Errors />
<Row>
<Col xs={12}>
<div className="row">
<div className="col-xs-12">
{this.props.children}
</Col>
</Row>
</Grid>
</div>
</div>
</div>
);
}
})
Expand Down
43 changes: 23 additions & 20 deletions src/components/chat.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React from 'react';
import {connect} from 'react-redux';
import {FormGroup, FormControl, InputGroup, Panel} from 'react-bootstrap';
import {hydrateMessages, newMessage} from '../store/chatActions';

import io from 'socket.io-client';
Expand Down Expand Up @@ -50,33 +49,37 @@ const Chat = React.createClass({
return (
<div>
<h3>Chat</h3>
<Panel
<div
className="panel panel-default"
style={{
height: '400px',
overflowY: 'scroll'
}}
>
{chatMessages.map(
message => (
<div
key={message._id}
style={{margin: '0.5em 0'}}
>
<span style={{fontWeight: 'bold'}}>{`${message.user}`}</span><br />
<span>{`${message.message}`}</span>
</div>
)
)}
</Panel>
<FormGroup>
<InputGroup>
<InputGroup.Addon>Message:</InputGroup.Addon>
<FormControl
<div className="panel-body">
{chatMessages.map(
message => (
<div
key={message._id}
style={{margin: '0.5em 0'}}
>
<span style={{fontWeight: 'bold'}}>{`${message.user}`}</span><br />
<span>{`${message.message}`}</span>
</div>
)
)}
</div>
</div>
<div className="form-group">
<span className="input-group">
<span className="input-group-addon">Message:</span>
<input
className="form-control"
onKeyPress={this.sendMessage}
type="text"
/>
</InputGroup>
</FormGroup>
</span>
</div>
</div>
);
}
Expand Down
17 changes: 8 additions & 9 deletions src/components/dashboard.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React from 'react';
import {Row, Col, Alert, Button} from 'react-bootstrap';
import {Link} from 'react-router';
import OrderTile from './orderTile';
import {connect} from 'react-redux';
Expand Down Expand Up @@ -29,21 +28,21 @@ const Dashboard = React.createClass({
render () {
const noOrdersYet = this.props.orders.length
? null
: <Alert bsStyle="warning">{this.props.resources.noOrdersYet}</Alert>;
: <div className="alert alert-warning">{this.props.resources.noOrdersYet}</div>;

return (
<div className="Dashboard">
<Row>
<Col xs={12}>
<div className="row">
<div className="col-xs-12">
<Link className="add-order-cta" to={'/newOrder'}>
<Button block bsSize="large" bsStyle="success">{this.props.resources.addOrder}</Button>
<button className="btn btn-success btn-block btn-lg">{this.props.resources.addOrder}</button>
</Link>
</Col>
</Row>
</div>
</div>
{noOrdersYet}
<Row style={this._getTileContainerStyles()}>
<div className="row" style={this._getTileContainerStyles()}>
{this._renderOrderTiles()}
</Row>
</div>
</div>
);
}
Expand Down
24 changes: 15 additions & 9 deletions src/components/errors.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React from 'react';
import {Row, Col, Alert} from 'react-bootstrap';
import {connect} from 'react-redux';
import {dismissError} from '../store/errorsActions';

Expand All @@ -14,13 +13,20 @@ const Errors = connect(state => ({

_renderErrors () {
return this.props.errors.map(error => (
<Alert
bsStyle="danger"
<div
key={error.id}
onDismiss={this._dismiss.bind(null, error.id)}
className="alert alert-danger alert-dismissable"
>
<button
className="close"
onClick={this._dismiss.bind(null, error.id)}
tabIndex="-1"
type="button"
>
<span>×</span>
</button>
<strong>ERROR:</strong> {error.message}
</Alert>)
</div>)
);
},

Expand All @@ -30,11 +36,11 @@ const Errors = connect(state => ({

render () {
return (
<Row>
<Col xs={12}>
<div className="row">
<div className="col-xs-12">
{this._renderErrors()}
</Col>
</Row>
</div>
</div>
);
}
})
Expand Down
30 changes: 16 additions & 14 deletions src/components/newOrderForm.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React from 'react';
import {Button, Input, Row, Col} from 'react-bootstrap';
import ValidatedInput from './validatedInput';
import {connect} from 'react-redux';
import {addNewOrder} from '../store/ordersActions';
Expand Down Expand Up @@ -88,8 +87,8 @@ const NewOrderForm = React.createClass({

render () {
return (
<Row >
<Col xs={8}>
<div className="row">
<div className="col-xs-8">
<form>
<ValidatedInput
id="restaurant"
Expand Down Expand Up @@ -136,13 +135,16 @@ const NewOrderForm = React.createClass({
]}
value={this.state.menu}
/>
<Input
id="description"
label={this.props.resources.description}
onChange={this.handleTextChange}
placeholder={this.props.resources.description}
type="textarea"
/>
<div className="form-group">
<label htmlFor="description">{this.props.resources.description}</label>
<input
id="description"
className="form-control"
onChange={this.handleTextChange}
placeholder={this.props.resources.description}
type="textarea"
/>
</div>
<ValidatedInput
id="password"
label={this.props.resources.password}
Expand Down Expand Up @@ -196,12 +198,12 @@ const NewOrderForm = React.createClass({
]}
value={this.state.extraCostPerMeal}
/>
<Button onClick={this.handleSubmit} type="button">
<button onClick={this.handleSubmit} type="button" className="btn btn-primary">
{this.props.resources.save}
</Button>
</button>
</form>
</Col>
</Row>
</div>
</div>
);
}
});
Expand Down
Loading