├── .env.example ├── .gitignore ├── LICENSE ├── README.md ├── package.json ├── public ├── favicon.ico ├── index.html └── manifest.json ├── src ├── App.js ├── Root.js ├── actions │ ├── auth.js │ └── index.js ├── components │ ├── controls │ │ └── Input.js │ ├── hoc │ │ ├── LazyLoad.js │ │ └── PrivateRoute.js │ └── layout │ │ └── Loader.js ├── containers │ ├── Login │ │ ├── components │ │ │ └── index.js │ │ └── index.js │ └── Register │ │ └── index.js ├── helpers │ ├── api.js │ └── utils.js ├── index.js ├── logo.svg ├── reducers │ ├── auth.js │ └── index.js ├── sagas │ ├── auth.js │ └── index.js ├── serviceWorker.js ├── store │ └── index.js └── styles │ ├── css │ └── main.css │ └── scss │ ├── abstracts │ ├── _functions.scss │ ├── _mixins.scss │ └── _variables.scss │ ├── base │ ├── _reset.scss │ └── _typography.scss │ ├── components │ └── _button.scss │ ├── containers │ ├── _login.scss │ └── _register.scss │ ├── helpers │ ├── _icon.scss │ ├── _spacing.scss │ ├── _theming.scss │ └── _utilities.scss │ ├── main.scss │ └── vendors │ └── bootstrap-4.3.1 │ ├── _alert.scss │ ├── _badge.scss │ ├── _breadcrumb.scss │ ├── _button-group.scss │ ├── _buttons.scss │ ├── _card.scss │ ├── _carousel.scss │ ├── _close.scss │ ├── _code.scss │ ├── _custom-forms.scss │ ├── _dropdown.scss │ ├── _forms.scss │ ├── _functions.scss │ ├── _grid.scss │ ├── _images.scss │ ├── _input-group.scss │ ├── _jumbotron.scss │ ├── _list-group.scss │ ├── _media.scss │ ├── _mixins.scss │ ├── _modal.scss │ ├── _nav.scss │ ├── _navbar.scss │ ├── _pagination.scss │ ├── _popover.scss │ ├── _print.scss │ ├── _progress.scss │ ├── _reboot.scss │ ├── _root.scss │ ├── _spinners.scss │ ├── _tables.scss │ ├── _toasts.scss │ ├── _tooltip.scss │ ├── _transitions.scss │ ├── _type.scss │ ├── _utilities.scss │ ├── _variables.scss │ ├── bootstrap-grid.scss │ ├── bootstrap-reboot.scss │ ├── bootstrap.scss │ ├── mixins │ ├── _alert.scss │ ├── _background-variant.scss │ ├── _badge.scss │ ├── _border-radius.scss │ ├── _box-shadow.scss │ ├── _breakpoints.scss │ ├── _buttons.scss │ ├── _caret.scss │ ├── _clearfix.scss │ ├── _deprecate.scss │ ├── _float.scss │ ├── _forms.scss │ ├── _gradients.scss │ ├── _grid-framework.scss │ ├── _grid.scss │ ├── _hover.scss │ ├── _image.scss │ ├── _list-group.scss │ ├── _lists.scss │ ├── _nav-divider.scss │ ├── _pagination.scss │ ├── _reset-text.scss │ ├── _resize.scss │ ├── _screen-reader.scss │ ├── _size.scss │ ├── _table-row.scss │ ├── _text-emphasis.scss │ ├── _text-hide.scss │ ├── _text-truncate.scss │ ├── _transition.scss │ └── _visibility.scss │ ├── utilities │ ├── _align.scss │ ├── _background.scss │ ├── _borders.scss │ ├── _clearfix.scss │ ├── _display.scss │ ├── _embed.scss │ ├── _flex.scss │ ├── _float.scss │ ├── _overflow.scss │ ├── _position.scss │ ├── _screenreaders.scss │ ├── _shadows.scss │ ├── _sizing.scss │ ├── _spacing.scss │ ├── _stretched-link.scss │ ├── _text.scss │ └── _visibility.scss │ └── vendor │ └── _rfs.scss └── yarn.lock /.env.example: -------------------------------------------------------------------------------- 1 | # Note: change in this file will require reload / rebuild. 2 | # Note: prefix `REACT_APP_` is required. 3 | 4 | REACT_APP_OAUTH_DEFAULT_ENDPOINT="/login" 5 | REACT_APP_ROUTE_BASENAME="/" 6 | REACT_APP_BACKEND_URL="https://devapiurl.com" 7 | REACT_APP_API_ENDPOINT="https://devapiurl.com/api" -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # editor settings. 4 | .vscode 5 | 6 | # dependencies 7 | /node_modules 8 | /.pnp 9 | .pnp.js 10 | 11 | # testing 12 | /coverage 13 | 14 | # production 15 | /build 16 | 17 | # misc 18 | .env 19 | .DS_Store 20 | .env.local 21 | .env.development.local 22 | .env.test.local 23 | .env.production.local 24 | 25 | npm-debug.log* 26 | yarn-debug.log* 27 | yarn-error.log* 28 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Mukesh Tivari 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | The React boilerplate code bootstrapped with [Create React App](https://github.com/facebook/create-react-app). 2 | 3 | ## Available Scripts 4 | 5 | In the project directory, you can run: 6 | 7 | ### `yarn start` 8 | 9 | Runs the app in the development mode.
10 | Open [http://localhost:3000](http://localhost:3000) to view it in the browser. 11 | 12 | The page will reload if you make edits.
13 | You will also see any lint errors in the console. 14 | 15 | ### `yarn test` 16 | 17 | Launches the test runner in the interactive watch mode.
18 | See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information. 19 | 20 | ### `yarn run build` 21 | 22 | Builds the app for production to the `build` folder.
23 | It correctly bundles React in production mode and optimizes the build for the best performance. 24 | 25 | The build is minified and the filenames include the hashes.
26 | Your app is ready to be deployed! 27 | 28 | See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information. 29 | 30 | ### `yarn run eject` 31 | 32 | **Note: this is a one-way operation. Once you `eject`, you can’t go back!** 33 | 34 | If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project. 35 | 36 | Instead, it will copy all the configuration files and the transitive dependencies (Webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own. 37 | 38 | You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it. 39 | 40 | ## Learn More 41 | 42 | You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started). 43 | 44 | To learn React, check out the [React documentation](https://reactjs.org/). 45 | 46 | ## Available Packages 47 | 48 | 1. axios: [Promise based HTTP client for the browser and node.js.](https://github.com/axios/axios) 49 | 2. classnames: [A simple javascript utility for conditionally joining classNames together.](https://github.com/JedWatson/classnames) 50 | 3. dotenv: [Loads environment variables from .env for nodejs projects.](https://github.com/motdotla/dotenv) 51 | 4. lodash: [A JavaScript utility library delivering consistency, modularity, performance, & extras.](https://lodash.com) 52 | 5. node-sass: [It allows you to natively compile .scss files to css at incredible speed and automatically via a connect middleware.](https://github.com/sass/node-sass) 53 | 6. redux: [Redux helps you write applications that behave consistently, run in different environments (client, server, and native), and are easy to test.](https://redux.js.org) 54 | 7. react-bootstrap: [The most popular front-end framework](https://react-bootstrap.github.io/) 55 | 8. react-router-dom: [Declarative routing for React.](https://reacttraining.com/react-router/) 56 | 9. redux-persist: [Persist and rehydrate a redux store.](https://github.com/rt2zz/redux-persist) 57 | 10. redux-saga: [An alternative side effect model for Redux apps.](https://redux-saga.js.org) 58 | 11. redux-thunk: [Thunk middleware for Redux.](https://github.com/reduxjs/redux-thunk) -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "boilerplate", 3 | "version": "0.1.0", 4 | "private": true, 5 | "dependencies": { 6 | "axios": "^0.18.0", 7 | "classnames": "^2.2.6", 8 | "dotenv": "^8.0.0", 9 | "lodash": "^4.17.11", 10 | "node-sass": "^4.12.0", 11 | "prop-types": "^15.7.2", 12 | "react": "^16.8.6", 13 | "react-bootstrap": "^1.0.0-beta.8", 14 | "react-dom": "^16.8.6", 15 | "react-redux": "^7.0.3", 16 | "react-router-dom": "^5.0.0", 17 | "react-scripts": "^3.0.1", 18 | "redux": "^4.0.1", 19 | "redux-persist": "^5.10.0", 20 | "redux-saga": "^1.0.2", 21 | "redux-thunk": "^2.3.0" 22 | }, 23 | "scripts": { 24 | "start": "npm-run-all -p sass start:js", 25 | "build": "npm-run-all build:sass build:js", 26 | "test": "react-scripts test --env=jsdom", 27 | "eject": "react-scripts eject", 28 | "sass": "node-sass -w src/styles/scss/main.scss src/styles/css/main.css", 29 | "start:js": "react-scripts start", 30 | "build:js": "react-scripts build", 31 | "build:sass": "node-sass src/styles/scss/main.scss src/styles/css/main.css" 32 | }, 33 | "eslintConfig": { 34 | "extends": "react-app" 35 | }, 36 | "browserslist": [ 37 | ">0.2%", 38 | "not dead", 39 | "not ie <= 11", 40 | "not op_mini all" 41 | ], 42 | "devDependencies": { 43 | "npm-run-all": "^4.1.5", 44 | "redux-devtools-extension": "^2.13.8" 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imukeshtivari/react-boilerplate/736368aa16ebdea78db6fd3487680e4358f0ec0d/public/favicon.ico -------------------------------------------------------------------------------- /public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 13 | 14 | 23 | React App 24 | 25 | 26 | 27 | 30 |
31 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "React App", 3 | "name": "Create React App Sample", 4 | "icons": [ 5 | { 6 | "src": "favicon.ico", 7 | "sizes": "64x64 32x32 24x24 16x16", 8 | "type": "image/x-icon" 9 | } 10 | ], 11 | "start_url": ".", 12 | "display": "standalone", 13 | "theme_color": "#000000", 14 | "background_color": "#ffffff" 15 | } 16 | -------------------------------------------------------------------------------- /src/App.js: -------------------------------------------------------------------------------- 1 | import React, { Component } from "react"; 2 | import { Route, Switch, Link } from "react-router-dom"; 3 | 4 | class App extends Component { 5 | render() { 6 | return ( 7 |
8 | 9 | ( 12 |
inside application
13 | )} 14 | /> 15 | ( 17 |
18 |

19 | Sorry, page not found (404) 20 |

21 |
22 | Go to Home 23 |
24 | )} 25 | /> 26 | 27 |
28 |
29 | ); 30 | } 31 | } 32 | 33 | export default App; 34 | -------------------------------------------------------------------------------- /src/Root.js: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import { Provider } from "react-redux"; 3 | import { PersistGate } from "redux-persist/lib/integration/react"; 4 | import { BrowserRouter as Router, Route, Switch } from "react-router-dom"; 5 | 6 | // redux store. 7 | import { persistor, store } from "./store"; 8 | 9 | // components. 10 | import PrivateRoute from "./components/hoc/PrivateRoute"; 11 | import LazyLoad from "./components/hoc/LazyLoad"; 12 | import Loader from "./components/layout/Loader"; 13 | 14 | // import css. 15 | import "./styles/css/main.css"; 16 | 17 | // components that will be loaded only when required. 18 | const Register = (props) => ( 19 | import("./containers/Register")}> 20 | {(Component) => (Component === null) ? : } 21 | 22 | ); 23 | 24 | const Login = (props) => ( 25 | import("./containers/Login")}> 26 | {(Component) => (Component === null) ? : } 27 | 28 | ); 29 | 30 | const App = (props) => ( 31 | import("./App")}> 32 | {(Component) => (Component === null) ? : } 33 | 34 | ); 35 | 36 | export default function () { 37 | return ( 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | ); 50 | } 51 | -------------------------------------------------------------------------------- /src/actions/auth.js: -------------------------------------------------------------------------------- 1 | // actions for registration. 2 | export const REQUEST_REGISTER = "REQUEST_REGISTER"; 3 | export const SUCCESS_REGISTER = "SUCCESS_REGISTER"; 4 | export const ERROR_REGISTER = "ERROR_REGISTER"; 5 | 6 | // actions for login. 7 | export const REQUEST_LOGIN = "REQUEST_LOGIN"; 8 | export const SUCCESS_LOGIN = "SUCCESS_LOGIN"; 9 | export const ERROR_LOGIN = "ERROR_LOGIN"; 10 | 11 | // action for saving the token. 12 | export const SAVE_OAUTH_TOKEN = "SAVE_OAUTH_TOKEN"; 13 | 14 | // action creator for saving the token with token 15 | export function saveAuthToken(token) { 16 | return (dispatch) => { 17 | return dispatch({ 18 | type: SAVE_OAUTH_TOKEN, 19 | token 20 | }); 21 | }; 22 | } 23 | 24 | // action for deleting the token. 25 | export const DELETE_OAUTH_TOKEN = "DELETE_OAUTH_TOKEN"; 26 | 27 | // action creator for deleting the token. 28 | export function deleteAuthToken() { 29 | return (dispatch) => { 30 | return dispatch({ type: DELETE_OAUTH_TOKEN }); 31 | }; 32 | } 33 | -------------------------------------------------------------------------------- /src/actions/index.js: -------------------------------------------------------------------------------- 1 | import { requireAll } from "../helpers/utils"; 2 | 3 | const objModules = {}; 4 | 5 | // require all files in the current directory, except index.js 6 | requireAll(require.context(".", true, /^((?!index).)*\.js$/)).forEach(module => 7 | Object.assign(objModules, module) 8 | ); 9 | 10 | export default objModules; 11 | -------------------------------------------------------------------------------- /src/components/controls/Input.js: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | 3 | export default function (props) { 4 | return ( 5 | 6 | ) 7 | } -------------------------------------------------------------------------------- /src/components/hoc/LazyLoad.js: -------------------------------------------------------------------------------- 1 | import React, { Component } from "react"; 2 | import PropTypes from "prop-types"; 3 | 4 | const ERROR_MESSAGE = "Oops, Something wen't wrong."; 5 | 6 | class Lazyload extends Component { 7 | state = { 8 | component: null, 9 | error: null 10 | }; 11 | 12 | componentDidMount() { 13 | try { 14 | this.props.load() 15 | .then((component) => { 16 | this.setState({ 17 | component: component.default || component 18 | }); 19 | }) 20 | .catch((error) => { 21 | this.setState({ error }); 22 | }) 23 | } catch (error) { 24 | this.setState({ error }); 25 | } 26 | } 27 | 28 | componentDidCatch(error) { 29 | this.setState({ error }); 30 | } 31 | 32 | render() { 33 | const { error } = this.state; 34 | 35 | if (error) { 36 | if (process.env.NODE_ENV === "production") { 37 | return (

{ERROR_MESSAGE}

); 38 | } 39 | 40 | return (

{(error || ERROR_MESSAGE).toString()}

); 41 | } 42 | 43 | return this.props.children(this.state.component); 44 | } 45 | } 46 | 47 | Lazyload.propTypes = { 48 | children: PropTypes.func.isRequired 49 | } 50 | 51 | export default Lazyload; -------------------------------------------------------------------------------- /src/components/hoc/PrivateRoute.js: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import { Route, Redirect } from "react-router-dom"; 3 | import { connect } from "react-redux"; 4 | import _ from "lodash"; 5 | 6 | class PrivateRoute extends React.Component { 7 | 8 | render() { 9 | const { component: Component, token, ...rest } = this.props; 10 | 11 | return ( 12 | { 15 | if (_.isEmpty(token)) { 16 | return ( 17 | 23 | ) 24 | } 25 | 26 | return 27 | }} 28 | /> 29 | ) 30 | } 31 | } 32 | 33 | const mapStateToProps = (state) => ({ 34 | token: _.get(state, "auth.data.token", "") 35 | }) 36 | 37 | export default connect(mapStateToProps)(PrivateRoute); -------------------------------------------------------------------------------- /src/components/layout/Loader.js: -------------------------------------------------------------------------------- 1 | import React, { Component } from "react"; 2 | import { Spinner } from "react-bootstrap"; 3 | 4 | export default class Loader extends Component { 5 | render() { 6 | return ( 7 | 8 | Loading... 9 | 10 | ) 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/containers/Login/components/index.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imukeshtivari/react-boilerplate/736368aa16ebdea78db6fd3487680e4358f0ec0d/src/containers/Login/components/index.js -------------------------------------------------------------------------------- /src/containers/Login/index.js: -------------------------------------------------------------------------------- 1 | import React, { Component } from "react" 2 | import { connect } from "react-redux"; 3 | import { Link } from "react-router-dom"; 4 | import { Container, Form, Button } from "react-bootstrap"; 5 | 6 | import { saveAuthToken } from "../../actions/auth"; 7 | // import api from "../../helpers/api"; 8 | 9 | class Login extends Component { 10 | 11 | constructor(props) { 12 | super(props); 13 | 14 | this.state = { 15 | username: "", 16 | password: "", 17 | keep_me: false, 18 | }; 19 | 20 | [ 21 | "_handleChange", 22 | "_handleSubmit" 23 | ].forEach((fn) => this[fn] = this[fn].bind(this)); 24 | } 25 | 26 | _handleSubmit(e) { 27 | e.preventDefault(); 28 | } 29 | 30 | _handleChange(e) { 31 | this.setState({ [e.target.name]: (e.target.type === "checkbox") ? e.target.checked : e.target.value }); 32 | } 33 | 34 | render() { 35 | const { username, password, keep_me } = this.state; 36 | 37 | return ( 38 | 39 |
40 | 41 | Username or Email address 42 | 43 | 44 | We'll never share your email with anyone else. 45 | 46 | 47 | 48 | 49 | Password 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | Click here to Register 59 | 60 | 61 |
62 |
63 | ) 64 | } 65 | } 66 | 67 | const mapDispatchToProps = (dispatch) => ({ 68 | saveAuthToken: (token) => dispatch(saveAuthToken(token)) 69 | }) 70 | 71 | export default connect(null, mapDispatchToProps)(Login); -------------------------------------------------------------------------------- /src/containers/Register/index.js: -------------------------------------------------------------------------------- 1 | import React, { Component } from "react" 2 | import { Link } from "react-router-dom"; 3 | import { Container, Form, Button } from "react-bootstrap"; 4 | 5 | class Register extends Component { 6 | 7 | constructor(props) { 8 | super(props); 9 | 10 | this.state = { 11 | name: "", 12 | username: "", 13 | password: "" 14 | }; 15 | 16 | [ 17 | "_handleChange", 18 | "_handleSubmit" 19 | ].forEach((fn) => this[fn] = this[fn].bind(this)); 20 | } 21 | 22 | _handleSubmit(e) { 23 | e.preventDefault(); 24 | } 25 | 26 | _handleChange(e) { 27 | this.setState({ [e.target.name]: e.target.value }) 28 | } 29 | 30 | render() { 31 | const { name, username, password } = this.state; 32 | 33 | return ( 34 | 35 |
36 | 37 | Full name 38 | 39 | 40 | 41 | 42 | Username or Email address 43 | 44 | 45 | 46 | 47 | Password 48 | 49 | 50 | 51 | 52 | Click here to Login 53 | 54 | 55 | 56 |
57 |
58 | ) 59 | } 60 | } 61 | 62 | export default Register; -------------------------------------------------------------------------------- /src/helpers/api.js: -------------------------------------------------------------------------------- 1 | import axios from "axios"; 2 | import _ from "lodash"; 3 | 4 | import { store } from "../store"; 5 | 6 | export default function () { 7 | const state = store.getState(); 8 | const token = _.get(state, "auth.data.token", ""); 9 | 10 | return axios.create({ 11 | baseURL: process.env.REACT_APP_API_ENDPOINT, 12 | headers: { "authorization": `bearer ${token}` } 13 | }); 14 | } -------------------------------------------------------------------------------- /src/helpers/utils.js: -------------------------------------------------------------------------------- 1 | export const requireAll = (requireContext) => requireContext.keys().map(requireContext); 2 | 3 | export default { 4 | requireAll, 5 | }; 6 | -------------------------------------------------------------------------------- /src/index.js: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import ReactDOM from "react-dom"; 3 | 4 | import Root from "./Root"; 5 | import * as serviceWorker from "./serviceWorker"; 6 | 7 | // variables from .env 8 | require("dotenv").config(); 9 | 10 | ReactDOM.render(, document.getElementById("root")); 11 | 12 | // If you want your app to work offline and load faster, you can change 13 | // unregister() to register() below. Note this comes with some pitfalls. 14 | // Learn more about service workers: http://bit.ly/CRA-PWA 15 | serviceWorker.unregister(); 16 | -------------------------------------------------------------------------------- /src/logo.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /src/reducers/auth.js: -------------------------------------------------------------------------------- 1 | import { combineReducers } from "redux"; 2 | import actionTypes from "../actions"; 3 | 4 | // ====================================================================================== 5 | /* 6 | * Reducer to store logged in user 's token 7 | */ 8 | 9 | export const data = (state = null, action) => { 10 | switch (action.type) { 11 | case actionTypes.SAVE_OAUTH_TOKEN: 12 | return action.token; 13 | case actionTypes.DELETE_OAUTH_TOKEN: 14 | return null; 15 | default: 16 | return state; 17 | } 18 | }; 19 | 20 | // ====================================================================================== 21 | 22 | export default { 23 | auth: combineReducers({ 24 | data 25 | }) 26 | }; 27 | -------------------------------------------------------------------------------- /src/reducers/index.js: -------------------------------------------------------------------------------- 1 | import { combineReducers } from "redux"; 2 | import { requireAll } from "../helpers/utils"; 3 | 4 | const objModules = {}; 5 | 6 | // require all files in the current directory, except index.js 7 | requireAll(require.context(".", true, /^((?!index).)*\.js$/)).forEach(module => 8 | Object.assign(objModules, module.default) 9 | ); 10 | 11 | export default combineReducers(objModules); 12 | -------------------------------------------------------------------------------- /src/sagas/auth.js: -------------------------------------------------------------------------------- 1 | import { take, takeLatest, fork, call } from "redux-saga/effects"; 2 | 3 | // redux actions and action creatores. 4 | import actionTypes from "../actions"; 5 | 6 | function* workerRegister(){ 7 | // code for handling registration. 8 | } 9 | 10 | function* workerLogin(){ 11 | // code for handling login. 12 | } 13 | 14 | // watch for registration action. 15 | function* watchRegister(){ 16 | yield takeLatest(actionTypes.REQUEST_REGISTER, workerRegister); 17 | } 18 | 19 | // watch for login action. 20 | function* watchLogin(){ 21 | const action = yield take(actionTypes.REQUEST_LOGIN); 22 | yield call(workerLogin, action); 23 | } 24 | 25 | // running auth related saga. 26 | export default [ 27 | fork(watchLogin), 28 | fork(watchRegister), 29 | ] 30 | 31 | // Note: just demo code, not in used anywhere. -------------------------------------------------------------------------------- /src/sagas/index.js: -------------------------------------------------------------------------------- 1 | import { all } from "redux-saga/effects"; 2 | 3 | // auth related sagas. 4 | import auth from "./auth"; 5 | 6 | // root saga. 7 | export default function* root(){ 8 | yield all([ 9 | ...auth 10 | ]) 11 | } -------------------------------------------------------------------------------- /src/serviceWorker.js: -------------------------------------------------------------------------------- 1 | // This optional code is used to register a service worker. 2 | // register() is not called by default. 3 | 4 | // This lets the app load faster on subsequent visits in production, and gives 5 | // it offline capabilities. However, it also means that developers (and users) 6 | // will only see deployed updates on subsequent visits to a page, after all the 7 | // existing tabs open on the page have been closed, since previously cached 8 | // resources are updated in the background. 9 | 10 | // To learn more about the benefits of this model and instructions on how to 11 | // opt-in, read http://bit.ly/CRA-PWA 12 | 13 | const isLocalhost = Boolean( 14 | window.location.hostname === 'localhost' || 15 | // [::1] is the IPv6 localhost address. 16 | window.location.hostname === '[::1]' || 17 | // 127.0.0.1/8 is considered localhost for IPv4. 18 | window.location.hostname.match( 19 | /^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/ 20 | ) 21 | ); 22 | 23 | export function register(config) { 24 | if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) { 25 | // The URL constructor is available in all browsers that support SW. 26 | const publicUrl = new URL(process.env.PUBLIC_URL, window.location.href); 27 | if (publicUrl.origin !== window.location.origin) { 28 | // Our service worker won't work if PUBLIC_URL is on a different origin 29 | // from what our page is served on. This might happen if a CDN is used to 30 | // serve assets; see https://github.com/facebook/create-react-app/issues/2374 31 | return; 32 | } 33 | 34 | window.addEventListener('load', () => { 35 | const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`; 36 | 37 | if (isLocalhost) { 38 | // This is running on localhost. Let's check if a service worker still exists or not. 39 | checkValidServiceWorker(swUrl, config); 40 | 41 | // Add some additional logging to localhost, pointing developers to the 42 | // service worker/PWA documentation. 43 | navigator.serviceWorker.ready.then(() => { 44 | console.log( 45 | 'This web app is being served cache-first by a service ' + 46 | 'worker. To learn more, visit http://bit.ly/CRA-PWA' 47 | ); 48 | }); 49 | } else { 50 | // Is not localhost. Just register service worker 51 | registerValidSW(swUrl, config); 52 | } 53 | }); 54 | } 55 | } 56 | 57 | function registerValidSW(swUrl, config) { 58 | navigator.serviceWorker 59 | .register(swUrl) 60 | .then(registration => { 61 | registration.onupdatefound = () => { 62 | const installingWorker = registration.installing; 63 | if (installingWorker == null) { 64 | return; 65 | } 66 | installingWorker.onstatechange = () => { 67 | if (installingWorker.state === 'installed') { 68 | if (navigator.serviceWorker.controller) { 69 | // At this point, the updated precached content has been fetched, 70 | // but the previous service worker will still serve the older 71 | // content until all client tabs are closed. 72 | console.log( 73 | 'New content is available and will be used when all ' + 74 | 'tabs for this page are closed. See http://bit.ly/CRA-PWA.' 75 | ); 76 | 77 | // Execute callback 78 | if (config && config.onUpdate) { 79 | config.onUpdate(registration); 80 | } 81 | } else { 82 | // At this point, everything has been precached. 83 | // It's the perfect time to display a 84 | // "Content is cached for offline use." message. 85 | console.log('Content is cached for offline use.'); 86 | 87 | // Execute callback 88 | if (config && config.onSuccess) { 89 | config.onSuccess(registration); 90 | } 91 | } 92 | } 93 | }; 94 | }; 95 | }) 96 | .catch(error => { 97 | console.error('Error during service worker registration:', error); 98 | }); 99 | } 100 | 101 | function checkValidServiceWorker(swUrl, config) { 102 | // Check if the service worker can be found. If it can't reload the page. 103 | fetch(swUrl) 104 | .then(response => { 105 | // Ensure service worker exists, and that we really are getting a JS file. 106 | const contentType = response.headers.get('content-type'); 107 | if ( 108 | response.status === 404 || 109 | (contentType != null && contentType.indexOf('javascript') === -1) 110 | ) { 111 | // No service worker found. Probably a different app. Reload the page. 112 | navigator.serviceWorker.ready.then(registration => { 113 | registration.unregister().then(() => { 114 | window.location.reload(); 115 | }); 116 | }); 117 | } else { 118 | // Service worker found. Proceed as normal. 119 | registerValidSW(swUrl, config); 120 | } 121 | }) 122 | .catch(() => { 123 | console.log( 124 | 'No internet connection found. App is running in offline mode.' 125 | ); 126 | }); 127 | } 128 | 129 | export function unregister() { 130 | if ('serviceWorker' in navigator) { 131 | navigator.serviceWorker.ready.then(registration => { 132 | registration.unregister(); 133 | }); 134 | } 135 | } 136 | -------------------------------------------------------------------------------- /src/store/index.js: -------------------------------------------------------------------------------- 1 | import { createStore, applyMiddleware } from "redux"; 2 | import { composeWithDevTools } from "redux-devtools-extension"; 3 | import { persistStore, persistReducer } from "redux-persist"; 4 | import storage from "redux-persist/lib/storage"; 5 | import createSagaMiddleware from "redux-saga" 6 | import thunk from "redux-thunk"; 7 | 8 | // reducers & sagas. 9 | import rootReducer from "../reducers"; 10 | import rootSaga from "../sagas"; 11 | 12 | const persistConfig = { 13 | key: "store", 14 | storage, 15 | whitelist: ["auth"] 16 | }; 17 | 18 | // initiating the saga middleware. 19 | const sagaMiddleware = createSagaMiddleware(); 20 | 21 | let middleware; 22 | 23 | // loading required middlewares depending upon the environment. 24 | if (process.env.NODE_ENV === "production") { 25 | middleware = applyMiddleware( 26 | sagaMiddleware, // applying saga middleware. 27 | thunk, // applying thunk middleware for distatching action based upon conditions. 28 | ); 29 | } else { 30 | middleware = composeWithDevTools( 31 | applyMiddleware( 32 | sagaMiddleware, 33 | thunk, 34 | ) 35 | ); 36 | } 37 | 38 | // persist reducer. 39 | const pReducer = persistReducer(persistConfig, rootReducer); 40 | 41 | // creating the main store. 42 | export const store = createStore(pReducer, middleware); 43 | export const persistor = persistStore(store); 44 | 45 | // running the sagas in background. 46 | sagaMiddleware.run(rootSaga); -------------------------------------------------------------------------------- /src/styles/scss/abstracts/_functions.scss: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imukeshtivari/react-boilerplate/736368aa16ebdea78db6fd3487680e4358f0ec0d/src/styles/scss/abstracts/_functions.scss -------------------------------------------------------------------------------- /src/styles/scss/abstracts/_mixins.scss: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imukeshtivari/react-boilerplate/736368aa16ebdea78db6fd3487680e4358f0ec0d/src/styles/scss/abstracts/_mixins.scss -------------------------------------------------------------------------------- /src/styles/scss/abstracts/_variables.scss: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imukeshtivari/react-boilerplate/736368aa16ebdea78db6fd3487680e4358f0ec0d/src/styles/scss/abstracts/_variables.scss -------------------------------------------------------------------------------- /src/styles/scss/base/_reset.scss: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imukeshtivari/react-boilerplate/736368aa16ebdea78db6fd3487680e4358f0ec0d/src/styles/scss/base/_reset.scss -------------------------------------------------------------------------------- /src/styles/scss/base/_typography.scss: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imukeshtivari/react-boilerplate/736368aa16ebdea78db6fd3487680e4358f0ec0d/src/styles/scss/base/_typography.scss -------------------------------------------------------------------------------- /src/styles/scss/components/_button.scss: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imukeshtivari/react-boilerplate/736368aa16ebdea78db6fd3487680e4358f0ec0d/src/styles/scss/components/_button.scss -------------------------------------------------------------------------------- /src/styles/scss/containers/_login.scss: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imukeshtivari/react-boilerplate/736368aa16ebdea78db6fd3487680e4358f0ec0d/src/styles/scss/containers/_login.scss -------------------------------------------------------------------------------- /src/styles/scss/containers/_register.scss: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imukeshtivari/react-boilerplate/736368aa16ebdea78db6fd3487680e4358f0ec0d/src/styles/scss/containers/_register.scss -------------------------------------------------------------------------------- /src/styles/scss/helpers/_icon.scss: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imukeshtivari/react-boilerplate/736368aa16ebdea78db6fd3487680e4358f0ec0d/src/styles/scss/helpers/_icon.scss -------------------------------------------------------------------------------- /src/styles/scss/helpers/_spacing.scss: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imukeshtivari/react-boilerplate/736368aa16ebdea78db6fd3487680e4358f0ec0d/src/styles/scss/helpers/_spacing.scss -------------------------------------------------------------------------------- /src/styles/scss/helpers/_theming.scss: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imukeshtivari/react-boilerplate/736368aa16ebdea78db6fd3487680e4358f0ec0d/src/styles/scss/helpers/_theming.scss -------------------------------------------------------------------------------- /src/styles/scss/helpers/_utilities.scss: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imukeshtivari/react-boilerplate/736368aa16ebdea78db6fd3487680e4358f0ec0d/src/styles/scss/helpers/_utilities.scss -------------------------------------------------------------------------------- /src/styles/scss/main.scss: -------------------------------------------------------------------------------- 1 | // ================================= 2 | // abstracts [functions, variables, mixins] 3 | // ================================= 4 | @import "abstracts/functions"; 5 | @import "abstracts/variables"; 6 | @import "abstracts/mixins"; 7 | 8 | // ================================= 9 | // vendors [bootstrap-4.3.1] 10 | // ================================= 11 | @import "vendors/bootstrap-4.3.1/bootstrap"; 12 | 13 | // ================================= 14 | // base 15 | // ================================= 16 | @import "base/reset"; 17 | @import "base/typography"; 18 | 19 | // ================================= 20 | // helpers 21 | // ================================= 22 | @import "helpers/icon"; 23 | @import "helpers/theming"; 24 | @import "helpers/utilities"; 25 | @import "helpers/spacing"; 26 | 27 | // ================================= 28 | // components 29 | // ================================= 30 | // @import "components/cash"; 31 | @import "components/button"; 32 | 33 | // ================================= 34 | // layout 35 | // ================================= 36 | // @import "layout/navigation"; 37 | 38 | // ================================= 39 | // containers 40 | // ================================= 41 | @import "containers/login"; 42 | @import "containers/register"; 43 | 44 | // ================================= 45 | // themes 46 | // ================================= -------------------------------------------------------------------------------- /src/styles/scss/vendors/bootstrap-4.3.1/_alert.scss: -------------------------------------------------------------------------------- 1 | // 2 | // Base styles 3 | // 4 | 5 | .alert { 6 | position: relative; 7 | padding: $alert-padding-y $alert-padding-x; 8 | margin-bottom: $alert-margin-bottom; 9 | border: $alert-border-width solid transparent; 10 | @include border-radius($alert-border-radius); 11 | } 12 | 13 | // Headings for larger alerts 14 | .alert-heading { 15 | // Specified to prevent conflicts of changing $headings-color 16 | color: inherit; 17 | } 18 | 19 | // Provide class for links that match alerts 20 | .alert-link { 21 | font-weight: $alert-link-font-weight; 22 | } 23 | 24 | 25 | // Dismissible alerts 26 | // 27 | // Expand the right padding and account for the close button's positioning. 28 | 29 | .alert-dismissible { 30 | padding-right: $close-font-size + $alert-padding-x * 2; 31 | 32 | // Adjust close link position 33 | .close { 34 | position: absolute; 35 | top: 0; 36 | right: 0; 37 | padding: $alert-padding-y $alert-padding-x; 38 | color: inherit; 39 | } 40 | } 41 | 42 | 43 | // Alternate styles 44 | // 45 | // Generate contextual modifier classes for colorizing the alert. 46 | 47 | @each $color, $value in $theme-colors { 48 | .alert-#{$color} { 49 | @include alert-variant(theme-color-level($color, $alert-bg-level), theme-color-level($color, $alert-border-level), theme-color-level($color, $alert-color-level)); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/styles/scss/vendors/bootstrap-4.3.1/_badge.scss: -------------------------------------------------------------------------------- 1 | // Base class 2 | // 3 | // Requires one of the contextual, color modifier classes for `color` and 4 | // `background-color`. 5 | 6 | .badge { 7 | display: inline-block; 8 | padding: $badge-padding-y $badge-padding-x; 9 | @include font-size($badge-font-size); 10 | font-weight: $badge-font-weight; 11 | line-height: 1; 12 | text-align: center; 13 | white-space: nowrap; 14 | vertical-align: baseline; 15 | @include border-radius($badge-border-radius); 16 | @include transition($badge-transition); 17 | 18 | @at-root a#{&} { 19 | @include hover-focus { 20 | text-decoration: none; 21 | } 22 | } 23 | 24 | // Empty badges collapse automatically 25 | &:empty { 26 | display: none; 27 | } 28 | } 29 | 30 | // Quick fix for badges in buttons 31 | .btn .badge { 32 | position: relative; 33 | top: -1px; 34 | } 35 | 36 | // Pill badges 37 | // 38 | // Make them extra rounded with a modifier to replace v3's badges. 39 | 40 | .badge-pill { 41 | padding-right: $badge-pill-padding-x; 42 | padding-left: $badge-pill-padding-x; 43 | @include border-radius($badge-pill-border-radius); 44 | } 45 | 46 | // Colors 47 | // 48 | // Contextual variations (linked badges get darker on :hover). 49 | 50 | @each $color, $value in $theme-colors { 51 | .badge-#{$color} { 52 | @include badge-variant($value); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/styles/scss/vendors/bootstrap-4.3.1/_breadcrumb.scss: -------------------------------------------------------------------------------- 1 | .breadcrumb { 2 | display: flex; 3 | flex-wrap: wrap; 4 | padding: $breadcrumb-padding-y $breadcrumb-padding-x; 5 | margin-bottom: $breadcrumb-margin-bottom; 6 | list-style: none; 7 | background-color: $breadcrumb-bg; 8 | @include border-radius($breadcrumb-border-radius); 9 | } 10 | 11 | .breadcrumb-item { 12 | // The separator between breadcrumbs (by default, a forward-slash: "/") 13 | + .breadcrumb-item { 14 | padding-left: $breadcrumb-item-padding; 15 | 16 | &::before { 17 | display: inline-block; // Suppress underlining of the separator in modern browsers 18 | padding-right: $breadcrumb-item-padding; 19 | color: $breadcrumb-divider-color; 20 | content: $breadcrumb-divider; 21 | } 22 | } 23 | 24 | // IE9-11 hack to properly handle hyperlink underlines for breadcrumbs built 25 | // without `