Skip to content

Commit

Permalink
Merge branch 'release/0.1.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
Elias Meire committed Jul 11, 2017
2 parents 72a7c25 + 3520008 commit f3c781f
Show file tree
Hide file tree
Showing 27 changed files with 6,984 additions and 1 deletion.
9 changes: 9 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
root=true

[*]
charset = utf-8
indent_style = space
indent_size = 2
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
5 changes: 5 additions & 0 deletions .firebaserc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"projects": {
"default": "ishare-c35bb"
}
}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,5 @@ typings/
# dotenv environment variables file
.env


build/
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# ishare

[![Build Status](https://travis-ci.org/oSoc17/istwaar.svg?branch=master)](https://travis-ci.org/oSoc17/istwaar)
[![Build Status](https://travis-ci.org/oSoc17/ishare.svg?branch=develop)](https://travis-ci.org/oSoc17/istwaar)
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
11 changes: 11 additions & 0 deletions firebase.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"hosting": {
"public": "build",
"rewrites": [
{
"source": "**",
"destination": "/index.html"
}
]
}
}
23 changes: 23 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"name": "test",
"version": "0.1.0",
"private": true,
"dependencies": {
"connected-react-router": "^4.2.3",
"firebase": "^4.1.3",
"react": "^15.6.1",
"react-dom": "^15.6.1",
"react-redux": "^5.0.5",
"react-router-dom": "^4.1.1",
"react-scripts": "1.0.10",
"redux": "^3.7.1",
"redux-devtools-extension": "^2.13.2",
"redux-thunk": "^2.2.0"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
}
}
Binary file added public/favicon.ico
Binary file not shown.
40 changes: 40 additions & 0 deletions public/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="theme-color" content="#000000">
<!--
manifest.json provides metadata used when your web app is added to the
homescreen on Android. See https://developers.google.com/web/fundamentals/engage-and-retain/web-app-manifest/
-->
<link rel="manifest" href="%PUBLIC_URL%/manifest.json">
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico">
<!--
Notice the use of %PUBLIC_URL% in the tags above.
It will be replaced with the URL of the `public` folder during the build.
Only files inside the `public` folder can be referenced from the HTML.
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>React App</title>
</head>
<body>
<noscript>
You need to enable JavaScript to run this app.
</noscript>
<div id="root"></div>
<!--
This HTML file is a template.
If you open it directly in the browser, you will see an empty page.
You can add webfonts, meta tags, or analytics to this file.
The build step will place the bundled scripts into the <body> tag.
To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`.
-->
</body>
</html>
15 changes: 15 additions & 0 deletions public/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"short_name": "React App",
"name": "Create React App Sample",
"icons": [
{
"src": "favicon.ico",
"sizes": "192x192",
"type": "image/png"
}
],
"start_url": "./index.html",
"display": "standalone",
"theme_color": "#000000",
"background_color": "#ffffff"
}
17 changes: 17 additions & 0 deletions src/components/auth/ProtectedRoute.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import React from 'react';
import { Route, Redirect } from 'react-router-dom';

const ProtectedRoute = ({ render, isAuthorized, redirectUrl, ...otherProps }) =>
<Route
{...otherProps}
render={
isAuthorized
? render
: props =>
<Redirect
to={{ pathname: redirectUrl, state: { from: props.location } }}
/>
}
/>;

export default ProtectedRoute;
1 change: 1 addition & 0 deletions src/containers/App.css
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

44 changes: 44 additions & 0 deletions src/containers/App.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import React, { Component } from 'react';
import { connect } from 'react-redux';
import { test } from '../redux/actions';
import { Route, Switch, Redirect } from 'react-router-dom';
import { ConnectedRouter } from 'connected-react-router';
import Home from './Home';
import Story from './Story';
import './App.css';

class App extends Component {
componentDidMount() {
this.props.test();
}

render() {
const { history, user } = this.props;

return (
<div className="app">
<ConnectedRouter history={history}>
<Switch>
<Route
path="/"
exact
render={props => <Home user={user} {...props} />}
/>
<Route
path="/story/:storyId"
render={props => <Story user={user} {...props} />}
/>
<Route render={() => <Redirect to="/" />} />
</Switch>
</ConnectedRouter>
</div>
);
}
}

const mapStateToProps = state => ({
user: state.user,
room: state.room
});

export default connect(mapStateToProps, { test })(App);
5 changes: 5 additions & 0 deletions src/containers/Home.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import React from 'react';

const Home = () => <div>This is home!</div>;

export default Home;
11 changes: 11 additions & 0 deletions src/containers/Root.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import React from 'react';
import { Provider } from 'react-redux';
import App from './App';
import store, { history } from '../redux/store';

const Root = () =>
<Provider store={store}>
<App history={history} />
</Provider>;

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

it('renders without crashing', () => {
const div = document.createElement('div');
ReactDOM.render(<Root />, div);
});
5 changes: 5 additions & 0 deletions src/containers/Story.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import React from 'react';

const Story = () => <div>This is a Story!</div>;

export default Story;
7 changes: 7 additions & 0 deletions src/containers/logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 17 additions & 0 deletions src/helpers/firebase.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import firebase from 'firebase';

// Initialize Firebase
const config = {
apiKey: "AIzaSyAmVHUHVmO5OS1-pKcLP_YkPwffWFhdIu0",
authDomain: "ishare-c35bb.firebaseapp.com",
databaseURL: "https://ishare-c35bb.firebaseio.com",
projectId: "ishare-c35bb",
storageBucket: "ishare-c35bb.appspot.com",
messagingSenderId: "530521724254"
};

firebase.initializeApp(config);

export const firebaseDatabase = firebase.database();
export const firebaseStorage = firebase.storage;
export const firebaseAuth = firebase.auth;
5 changes: 5 additions & 0 deletions src/index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
body {
margin: 0;
padding: 0;
font-family: sans-serif;
}
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 './index.css';
import Root from './containers/Root';
import registerServiceWorker from './registerServiceWorker';

ReactDOM.render(<Root />, document.getElementById('root'));

registerServiceWorker();
5 changes: 5 additions & 0 deletions src/redux/actions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export const actionTypes = {
test: 'TEST'
};

export const test = () => ({ type: actionTypes.test });
8 changes: 8 additions & 0 deletions src/redux/modules/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { combineReducers } from 'redux';
import { reducer as user } from './user';
import { reducer as room } from './room';

export const rootReducer = combineReducers({
user,
room
});
12 changes: 12 additions & 0 deletions src/redux/modules/room.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { actionTypes } from '../actions';

const initialState = {};

export const reducer = (state = initialState, action) => {
switch (action.type) {
case actionTypes.test:
return state;
default:
return state;
}
};
30 changes: 30 additions & 0 deletions src/redux/modules/user.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { actionTypes } from '../actions';

const initialState = {
authPending: true,
isAuthorized: false,
id: '',
name: '',
error: null
};

export const reducer = (state = initialState, action) => {
switch (action.type) {
case actionTypes.logout:
return Object.assign({}, initialState, { authPending: false });
case actionTypes.fetchUserAuthFulfilled:
return Object.assign({}, state, {
...action.user,
isAuthorized: true,
authPending: false
});
case actionTypes.fetchUserAuthRejected:
return Object.assign({}, state, {
error: action.error,
isAuthorized: false,
authPending: false
});
default:
return state;
}
};
16 changes: 16 additions & 0 deletions src/redux/store.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { createStore, applyMiddleware } from 'redux';
import { composeWithDevTools } from 'redux-devtools-extension/developmentOnly';
import { createBrowserHistory } from 'history';
import { connectRouter, routerMiddleware } from 'connected-react-router';
import { rootReducer } from './modules';
import thunk from 'redux-thunk';

export const history = createBrowserHistory();
const middlewares = [thunk, routerMiddleware(history)];

const store = createStore(
connectRouter(history)(rootReducer),
composeWithDevTools(applyMiddleware(...middlewares))
);

export default store;
Loading

0 comments on commit f3c781f

Please sign in to comment.