Skip to content

Commit

Permalink
Add basic React app
Browse files Browse the repository at this point in the history
  • Loading branch information
avaragado committed Mar 16, 2017
1 parent ea970bf commit 0d5024a
Show file tree
Hide file tree
Showing 11 changed files with 2,785 additions and 0 deletions.
14 changes: 14 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
; http://EditorConfig.org

root = true

[*]
indent_style = space
indent_size = 4
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[package.json]
indent_size = 2
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# riw example

Example project for [riw](https://github.com/avaragado/riw)

::TODO:: explain how to make it work with riw

## To run

```js
git clone git@github.com:avaragado/riw-example.git
cd riw-example
yarn install
yarn start
```

Then open up [localhost:9000](http://localhost:9000) in your browser.


## Acknowledgements

`riw-example` is derived from https://github.com/thejameskyle/react-loadable-example.
21 changes: 21 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"name": "riw-example",
"version": "1.0.0",
"main": "index.js",
"author": "David Smith <[email protected]>",
"license": "MIT",
"scripts": {
"start": "webpack-dev-server"
},
"dependencies": {
"react": "^15.4.2",
"react-dom": "^15.4.2"
},
"devDependencies": {
"babel-core": "^6.23.1",
"babel-loader": "^6.4.0",
"babel-preset-react": "^6.23.0",
"webpack": "^2.2.1",
"webpack-dev-server": "^2.4.1"
}
}
11 changes: 11 additions & 0 deletions public/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>riw-example</title>
</head>
<body>
<div id="root"></div>
<script type="text/javascript" src="scripts/bundle-main.js"></script>
</body>
</html>
24 changes: 24 additions & 0 deletions src/components/App.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import React from 'react';

import Buttons from './Buttons';
import Text from './Text';
import FileCounter from './FileCounter';

const App = () => (
<div>
<h1>Hello world!</h1>

<Text name="Fred" number="123456" />

<FileCounter numFiles={0} />
<FileCounter numFiles={1} />
<FileCounter numFiles={2} />
<FileCounter numFiles={10} />

<Buttons />

<p>The end</p>
</div>
);

export default App;
10 changes: 10 additions & 0 deletions src/components/Buttons.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import React from 'react';

const Buttons = () => (
<div>
<button>Press me</button>
<button>Cancel</button>
</div>
);

export default Buttons;
7 changes: 7 additions & 0 deletions src/components/FileCounter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import React from 'react';

const FileCounter = ({ numFiles }) => (
<p>You have { numFiles } file(s)</p>
);

export default FileCounter;
15 changes: 15 additions & 0 deletions src/components/Text.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import React from 'react';

import FileCounter from './FileCounter';

const Text = ({ name, number }) => (
<div>
<p>This is some boring text related to {name}.</p>

<FileCounter numFiles={number} />

<p>Thank you.</p>
</div>
);

export default Text;
9 changes: 9 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import React from 'react';
import ReactDOM from 'react-dom';

import App from './components/App';

ReactDOM.render(
<App/>,
document.getElementById('root')
);
26 changes: 26 additions & 0 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
const path = require('path');

module.exports = {
entry: './src/index.js',
module: {
rules: [{
test: /\.js$/,
exclude: /node_modules/,
loader: 'babel-loader',
options: {
babelrc: false,
presets: ['react'],
}
}]
},
output: {
filename: 'bundle-[name].js',
path: path.resolve(__dirname, 'public', 'scripts'),
publicPath: 'scripts/',
},
devServer: {
contentBase: path.join(__dirname, 'public'),
compress: true,
port: 9000
}
};
Loading

0 comments on commit 0d5024a

Please sign in to comment.