├── Design
└── FocusBlock-Design.sketch
├── README.md
├── Server
├── .gitignore
├── Database
│ └── db.js
├── package-lock.json
├── package.json
└── server.js
└── focus-block
├── .gitignore
├── README.md
├── package-lock.json
├── package.json
├── public
├── favicon.ico
├── index.html
└── manifest.json
└── src
├── App.css
├── App.js
├── App.scss
├── App.test.js
├── Assets
├── cmjio-button@2x.png
├── delete-trash@2x.png
├── edit-pencil@2x.png
├── github_logo.png
└── twitch_logo.png
├── Components
├── About
│ ├── About.js
│ ├── styles.css
│ └── styles.scss
├── BlockForm
│ ├── BlockForm.js
│ ├── styles.css
│ └── styles.scss
├── Dashboard
│ ├── AddBlockButton
│ │ ├── AddBlockButton.js
│ │ ├── styles.css
│ │ └── styles.scss
│ ├── Dashboard.js
│ ├── styles.css
│ └── styles.scss
└── FocusBlock
│ ├── FocusBlock.js
│ ├── styles.css
│ └── styles.scss
├── Containers
├── ServiceContainer.js
└── SmtpContainer.js
├── index.css
├── index.js
└── registerServiceWorker.js
/Design/FocusBlock-Design.sketch:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PixelogicDev/FocusBlock/e42a2f6e418d4b13bb4402c1c10125ba422e3ec0/Design/FocusBlock-Design.sketch
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # FocusBlock
2 |
3 | ### Be The Most Productive Version Of You.
4 |
5 | #### FocusBlock is here to help you stay on track with your tasks.
6 |
7 | #### Table Of Contents
8 |
9 | 1. [Introduction](#introduction)
10 | 2. [Tech](#tech)
11 | 3. [How to use](#how-to-use)
12 | 1. [Dashboard](#dashboard)
13 | 2. [Custom URL](#custom-url)
14 | 4. [Contributing](#contributing)
15 | 5. [Thank you](#thank-you)
16 | 6. [License](#license)
17 |
18 | ### Introduction
19 |
20 | Welcome to FocusBlock! FocusBlock is a web application that was created to help anyone manage their time in a more productive way. FocusBlock helps you take a task and time block it and realize when you are taking longer then expected to complete a task.
21 |
22 | The great thing about FocusBlock is that you are able to reach out to someone automatically if you are struggling. If your FocusBlock goes over time and you designate someone's email as a contact, they will recieve a message requesting assistance!
23 |
24 | FocusBlock is part of the PixelogicDev 28 Day Projects stream. Visit the channel [here](https://www.twitch.tv/pixelogicdev) to see more projects like this!
25 |
26 | ### Tech
27 |
28 | FocusBlock was built using all Javascript tech in a full stack soluton:
29 | **_Client_**: React v16.3.2
30 | **_Server_**: Node.js v8.9.4
31 | **_Storage_**: MongoDB v3.4.3
32 | **_Note: FocusBlock has only been tested in Google Chrome browser and may have issues on other browsers._**
33 |
34 | ### How to use
35 |
36 | FocusBlock was made with simplicity in mind. There are only two different views, About & Dashboard. The About view will give you a basic overview of FocusBlock and the Dashboard view is where all the magic happens.
37 |
38 | #### Dashboard
39 |
40 | When you hit the Dashboard view you will be greeted with a form to start creating your first FocusBlock. This form will consist of the following:
41 |
42 | - Title: Name of the FocusBlock
43 | - Timer: Amount of time to focus on this task
44 | - Contact (Optional): Email of the person to contact if needed
45 |
46 | Once you create your first FocusBlock all you need to do is select "Get Focused" and you can begin working on your task. Once you complete your task make sure to press "Stop Focusing". This is how FocusBlock knows that you are done with your task!
47 |
48 | If you do not press "Stop Focusing" before time is complete AND you have someone set as a contact, an email will automatically be sent out to them requesting assistance on your task.
49 |
50 | #### Custom URL
51 |
52 | FocusBlock uses a database to help store multiple FocusBlocks at a time. Don't worry, all email addresses are stripped from your FocusBlock before saving for privacy purposes. In order for FocusBlock to know which FocusBlocks it needs to pull, a custom URL is generated for you. The first time you go to https://focusblock.stream you will see the url above all your FocusBlocks and it should look like this: `https://focusblock.stream/dashboard/SomeIdHere`.
53 |
54 | From that point on, make sure to use that URL to get access to all the FocusBlocks you have already created. When you return, you will need to re-enter any emails for your blocks for the reason stated above.
55 |
56 | ### Contributing
57 |
58 | FocusBlock is an open source application that is looking for contributions! If you are interested in contributing and/or found a bug, please see below to get started with contributing.
59 |
60 | #### Github Issues
61 |
62 | All contributing will be done through Github Issues. If you have a bug/improvement please create a Github Issue in this repository.
63 |
64 | #### MongoDB Storage
65 |
66 | FocusBlock uses a MongoDB Database that stores very basic user settings. Here is a list of everything being stored in the database:
67 | `id` -> Custom URL ID
68 | `url` -> Custom URL path for each person
69 | `focusBlocks` -> Array of all focusBlocks
70 |
71 | ##### Install MongoDB
72 |
73 | Make sure to have MongoDB installed before you run it by following [this doc](https://docs.mongodb.com/manual/installation/).
74 |
75 | ##### Start Database
76 |
77 | Before starting up the database make sure to do these commands:
78 |
79 | - Open up a terminal window and type `mongod`
80 | - Open up another terminal window and type `mongo`
81 | - In the `mongo` terminal use command `use MyDatabaseName`. This will create a local database (Don't forget to add the name of your db to your server `.env` file).
82 |
83 | This setup will only happen the first time around. Every other time after do these commands:
84 |
85 | - Open up a terminal window and type `mongod`
86 | - Open up another terminal window and type `mongo`
87 | - In the `mongo` terminal use command `use MyDatabaseName`.
88 |
89 | #### Node Server
90 |
91 | FocusBlock uses a Node.js server in order to handle communication between the client and database. There are a few environment properties that need to be set before running the server.
92 |
93 | ##### ENV Properties
94 |
95 | Start by creating a `.env` file that will store these properties:
96 |
97 | - `BASE_PATH`=localhost:3000
98 | - `DB_PATH`=mongodb://localhost:27017/focusblock
99 | - `DB_NAME`=focusblock
100 |
101 | ##### Start Server
102 |
103 | When you are ready to run the server, follow these commands:
104 |
105 | - `cd Server`
106 | - `npm install && npm start`
107 |
108 | #### SendGrid
109 |
110 | In order to get email working on the client, you will need to create a basic SendGrid account. This will allow SMTP sending via the client. Once you create this account you will need the username and API token.
111 |
112 | #### React Client
113 |
114 | FocusBlock runs a React client that is simple to get up and running.
115 |
116 | ##### ENV Properties
117 |
118 | There are some properties within the client that are needed to run the app. You will need to create a `.env.development.local` file before starting the app locally:
119 |
120 | - `REACT_APP_SMTP_USERNAME` ---> SMTP Username for SMTPJS (From Sengrid)
121 | - `REACT_APP_SMTP_PW` ---> SMTP Password for SMTPJS (From Sengrid)
122 | - `REACT_APP_API_BASE` ---> The route for your Node Server (ex. `http://localhost:8000`)
123 |
124 | ##### Start Client
125 |
126 | When you are ready to run the client, follow these commands:
127 |
128 | - `cd focus-block`
129 | - `npm install`
130 | - `npm start`
131 | - Visit `localhost:3000`
132 |
133 | This will run and build the client. At this point you are good to go with the client side.
134 |
135 | ### Thank you
136 |
137 | I want to give a huge shout out to all the libraries I was able to use to make this project possible:
138 | [`body-parser`](https://github.com/expressjs/body-parser)
139 | [`cors`](https://github.com/expressjs/cors)
140 | [`dotenv`](https://github.com/motdotla/dotenv)
141 | [`express`](https://github.com/expressjs/express)
142 | [`mongodb`](https://github.com/mongodb/mongo)
143 | [`shortid`](https://github.com/dylang/shortid)
144 | [`classnames`](https://github.com/JedWatson/classnames)
145 | [`node-sass-chokidar`](https://github.com/michaelwayman/node-sass-chokidar)
146 | [`npm-run-all`](https://github.com/mysticatea/npm-run-all)
147 | [`react`](https://github.com/facebook/react)
148 | [`smtpjs`](https://smtpjs.com/)
149 | [`SendGrid`](https://sendgrid.com/)
150 |
151 | ### License
152 |
153 | Copyright 2018 Pixelogic
154 |
155 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
156 |
157 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
158 |
159 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
160 |
--------------------------------------------------------------------------------
/Server/.gitignore:
--------------------------------------------------------------------------------
1 | # Logs
2 | logs
3 | *.log
4 | npm-debug.log*
5 | yarn-debug.log*
6 | yarn-error.log*
7 |
8 | # Runtime data
9 | pids
10 | *.pid
11 | *.seed
12 | *.pid.lock
13 |
14 | # Directory for instrumented libs generated by jscoverage/JSCover
15 | lib-cov
16 |
17 | # Coverage directory used by tools like istanbul
18 | coverage
19 |
20 | # nyc test coverage
21 | .nyc_output
22 |
23 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
24 | .grunt
25 |
26 | # Bower dependency directory (https://bower.io/)
27 | bower_components
28 |
29 | # node-waf configuration
30 | .lock-wscript
31 |
32 | # Compiled binary addons (https://nodejs.org/api/addons.html)
33 | build/Release
34 |
35 | # Dependency directories
36 | node_modules/
37 | jspm_packages/
38 |
39 | # TypeScript v1 declaration files
40 | typings/
41 |
42 | # Optional npm cache directory
43 | .npm
44 |
45 | # Optional eslint cache
46 | .eslintcache
47 |
48 | # Optional REPL history
49 | .node_repl_history
50 |
51 | # Output of 'npm pack'
52 | *.tgz
53 |
54 | # Yarn Integrity file
55 | .yarn-integrity
56 |
57 | # dotenv environment variables file
58 | .env
59 |
60 | # next.js build output
61 | .next
62 |
63 | # vuepress build output
64 | .vuepress/dist
65 |
66 | # Serverless directories
67 | .serverless
--------------------------------------------------------------------------------
/Server/Database/db.js:
--------------------------------------------------------------------------------
1 | //-- Properties --//
2 | const MongoClient = require('mongodb').MongoClient;
3 | var db;
4 |
5 | // Connect to DB //
6 | MongoClient.connect(
7 | process.env.DB_PATH,
8 | { useNewUrlParser: true },
9 | (error, client) => {
10 | if (error) throw error;
11 |
12 | console.log('Connected to FocusBlock DB!');
13 | db = client.db(process.env.DB_NAME);
14 | }
15 | );
16 |
17 | module.exports = {
18 | addUser: user => {
19 | return new Promise((resolve, reject) => {
20 | console.log('[db.addUser] Starting to add user...');
21 |
22 | let collection = db.collection('users');
23 | collection.insertOne(user, (insertError, data) => {
24 | //-- MAD PROPS panthalassadigital --//
25 | if (insertError) return reject(insertError);
26 | });
27 |
28 | console.log('[db.addUser] New user added.');
29 | return resolve(user);
30 | });
31 | },
32 |
33 | findUser: id => {
34 | return new Promise((resolve, reject) => {
35 | console.log('[db.findUser] Looking for user...');
36 |
37 | let collection = db.collection('users');
38 | collection.findOne({ _id: id }, null, (error, result) => {
39 | if (error) return reject(error);
40 | console.log('Returning user.');
41 | return resolve(result);
42 | });
43 | });
44 | },
45 |
46 | updateUser: data => {
47 | return new Promise((resolve, reject) => {
48 | console.log('[db.updateUser] Updating user...');
49 |
50 | let collection = db.collection('users');
51 | collection.update(
52 | { _id: data.id },
53 | { $set: { focusBlocks: data.focusBlocks } },
54 | (error, result) => {
55 | if (error) return reject(error);
56 | console.log('User updated.');
57 | return resolve(result);
58 | }
59 | );
60 | });
61 | }
62 | };
63 |
--------------------------------------------------------------------------------
/Server/package-lock.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "focus-block-server",
3 | "version": "1.0.0",
4 | "lockfileVersion": 1,
5 | "requires": true,
6 | "dependencies": {
7 | "accepts": {
8 | "version": "1.3.5",
9 | "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.5.tgz",
10 | "integrity": "sha1-63d99gEXI6OxTopywIBcjoZ0a9I=",
11 | "requires": {
12 | "mime-types": "~2.1.18",
13 | "negotiator": "0.6.1"
14 | }
15 | },
16 | "array-flatten": {
17 | "version": "1.1.1",
18 | "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz",
19 | "integrity": "sha1-ml9pkFGx5wczKPKgCJaLZOopVdI="
20 | },
21 | "body-parser": {
22 | "version": "1.18.3",
23 | "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.18.3.tgz",
24 | "integrity": "sha1-WykhmP/dVTs6DyDe0FkrlWlVyLQ=",
25 | "requires": {
26 | "bytes": "3.0.0",
27 | "content-type": "~1.0.4",
28 | "debug": "2.6.9",
29 | "depd": "~1.1.2",
30 | "http-errors": "~1.6.3",
31 | "iconv-lite": "0.4.23",
32 | "on-finished": "~2.3.0",
33 | "qs": "6.5.2",
34 | "raw-body": "2.3.3",
35 | "type-is": "~1.6.16"
36 | },
37 | "dependencies": {
38 | "qs": {
39 | "version": "6.5.2",
40 | "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.2.tgz",
41 | "integrity": "sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA=="
42 | }
43 | }
44 | },
45 | "bson": {
46 | "version": "1.0.6",
47 | "resolved": "https://registry.npmjs.org/bson/-/bson-1.0.6.tgz",
48 | "integrity": "sha512-D8zmlb46xfuK2gGvKmUjIklQEouN2nQ0LEHHeZ/NoHM2LDiMk2EYzZ5Ntw/Urk+bgMDosOZxaRzXxvhI5TcAVQ=="
49 | },
50 | "bytes": {
51 | "version": "3.0.0",
52 | "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.0.0.tgz",
53 | "integrity": "sha1-0ygVQE1olpn4Wk6k+odV3ROpYEg="
54 | },
55 | "content-disposition": {
56 | "version": "0.5.2",
57 | "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.2.tgz",
58 | "integrity": "sha1-DPaLud318r55YcOoUXjLhdunjLQ="
59 | },
60 | "content-type": {
61 | "version": "1.0.4",
62 | "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.4.tgz",
63 | "integrity": "sha512-hIP3EEPs8tB9AT1L+NUqtwOAps4mk2Zob89MWXMHjHWg9milF/j4osnnQLXBCBFBk/tvIG/tUc9mOUJiPBhPXA=="
64 | },
65 | "cookie": {
66 | "version": "0.3.1",
67 | "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.3.1.tgz",
68 | "integrity": "sha1-5+Ch+e9DtMi6klxcWpboBtFoc7s="
69 | },
70 | "cookie-signature": {
71 | "version": "1.0.6",
72 | "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz",
73 | "integrity": "sha1-4wOogrNCzD7oylE6eZmXNNqzriw="
74 | },
75 | "cors": {
76 | "version": "2.8.4",
77 | "resolved": "https://registry.npmjs.org/cors/-/cors-2.8.4.tgz",
78 | "integrity": "sha1-K9OB8usgECAQXNUOpZ2mMJBpRoY=",
79 | "requires": {
80 | "object-assign": "^4",
81 | "vary": "^1"
82 | }
83 | },
84 | "debug": {
85 | "version": "2.6.9",
86 | "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz",
87 | "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==",
88 | "requires": {
89 | "ms": "2.0.0"
90 | }
91 | },
92 | "depd": {
93 | "version": "1.1.2",
94 | "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz",
95 | "integrity": "sha1-m81S4UwJd2PnSbJ0xDRu0uVgtak="
96 | },
97 | "destroy": {
98 | "version": "1.0.4",
99 | "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.0.4.tgz",
100 | "integrity": "sha1-l4hXRCxEdJ5CBmE+N5RiBYJqvYA="
101 | },
102 | "dotenv": {
103 | "version": "6.0.0",
104 | "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-6.0.0.tgz",
105 | "integrity": "sha512-FlWbnhgjtwD+uNLUGHbMykMOYQaTivdHEmYwAKFjn6GKe/CqY0fNae93ZHTd20snh9ZLr8mTzIL9m0APQ1pjQg=="
106 | },
107 | "ee-first": {
108 | "version": "1.1.1",
109 | "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz",
110 | "integrity": "sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0="
111 | },
112 | "encodeurl": {
113 | "version": "1.0.2",
114 | "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz",
115 | "integrity": "sha1-rT/0yG7C0CkyL1oCw6mmBslbP1k="
116 | },
117 | "escape-html": {
118 | "version": "1.0.3",
119 | "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz",
120 | "integrity": "sha1-Aljq5NPQwJdN4cFpGI7wBR0dGYg="
121 | },
122 | "etag": {
123 | "version": "1.8.1",
124 | "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz",
125 | "integrity": "sha1-Qa4u62XvpiJorr/qg6x9eSmbCIc="
126 | },
127 | "express": {
128 | "version": "4.16.3",
129 | "resolved": "https://registry.npmjs.org/express/-/express-4.16.3.tgz",
130 | "integrity": "sha1-avilAjUNsyRuzEvs9rWjTSL37VM=",
131 | "requires": {
132 | "accepts": "~1.3.5",
133 | "array-flatten": "1.1.1",
134 | "body-parser": "1.18.2",
135 | "content-disposition": "0.5.2",
136 | "content-type": "~1.0.4",
137 | "cookie": "0.3.1",
138 | "cookie-signature": "1.0.6",
139 | "debug": "2.6.9",
140 | "depd": "~1.1.2",
141 | "encodeurl": "~1.0.2",
142 | "escape-html": "~1.0.3",
143 | "etag": "~1.8.1",
144 | "finalhandler": "1.1.1",
145 | "fresh": "0.5.2",
146 | "merge-descriptors": "1.0.1",
147 | "methods": "~1.1.2",
148 | "on-finished": "~2.3.0",
149 | "parseurl": "~1.3.2",
150 | "path-to-regexp": "0.1.7",
151 | "proxy-addr": "~2.0.3",
152 | "qs": "6.5.1",
153 | "range-parser": "~1.2.0",
154 | "safe-buffer": "5.1.1",
155 | "send": "0.16.2",
156 | "serve-static": "1.13.2",
157 | "setprototypeof": "1.1.0",
158 | "statuses": "~1.4.0",
159 | "type-is": "~1.6.16",
160 | "utils-merge": "1.0.1",
161 | "vary": "~1.1.2"
162 | },
163 | "dependencies": {
164 | "body-parser": {
165 | "version": "1.18.2",
166 | "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.18.2.tgz",
167 | "integrity": "sha1-h2eKGdhLR9hZuDGZvVm84iKxBFQ=",
168 | "requires": {
169 | "bytes": "3.0.0",
170 | "content-type": "~1.0.4",
171 | "debug": "2.6.9",
172 | "depd": "~1.1.1",
173 | "http-errors": "~1.6.2",
174 | "iconv-lite": "0.4.19",
175 | "on-finished": "~2.3.0",
176 | "qs": "6.5.1",
177 | "raw-body": "2.3.2",
178 | "type-is": "~1.6.15"
179 | }
180 | },
181 | "iconv-lite": {
182 | "version": "0.4.19",
183 | "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.19.tgz",
184 | "integrity": "sha512-oTZqweIP51xaGPI4uPa56/Pri/480R+mo7SeU+YETByQNhDG55ycFyNLIgta9vXhILrxXDmF7ZGhqZIcuN0gJQ=="
185 | },
186 | "raw-body": {
187 | "version": "2.3.2",
188 | "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.3.2.tgz",
189 | "integrity": "sha1-vNYMd9Prk83gBQKVw/N5OJvIj4k=",
190 | "requires": {
191 | "bytes": "3.0.0",
192 | "http-errors": "1.6.2",
193 | "iconv-lite": "0.4.19",
194 | "unpipe": "1.0.0"
195 | },
196 | "dependencies": {
197 | "depd": {
198 | "version": "1.1.1",
199 | "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.1.tgz",
200 | "integrity": "sha1-V4O04cRZ8G+lyif5kfPQbnoxA1k="
201 | },
202 | "http-errors": {
203 | "version": "1.6.2",
204 | "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.6.2.tgz",
205 | "integrity": "sha1-CgAsyFcHGSp+eUbO7cERVfYOxzY=",
206 | "requires": {
207 | "depd": "1.1.1",
208 | "inherits": "2.0.3",
209 | "setprototypeof": "1.0.3",
210 | "statuses": ">= 1.3.1 < 2"
211 | }
212 | },
213 | "setprototypeof": {
214 | "version": "1.0.3",
215 | "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.0.3.tgz",
216 | "integrity": "sha1-ZlZ+NwQ+608E2RvWWMDL77VbjgQ="
217 | }
218 | }
219 | }
220 | }
221 | },
222 | "finalhandler": {
223 | "version": "1.1.1",
224 | "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.1.1.tgz",
225 | "integrity": "sha512-Y1GUDo39ez4aHAw7MysnUD5JzYX+WaIj8I57kO3aEPT1fFRL4sr7mjei97FgnwhAyyzRYmQZaTHb2+9uZ1dPtg==",
226 | "requires": {
227 | "debug": "2.6.9",
228 | "encodeurl": "~1.0.2",
229 | "escape-html": "~1.0.3",
230 | "on-finished": "~2.3.0",
231 | "parseurl": "~1.3.2",
232 | "statuses": "~1.4.0",
233 | "unpipe": "~1.0.0"
234 | }
235 | },
236 | "forwarded": {
237 | "version": "0.1.2",
238 | "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.1.2.tgz",
239 | "integrity": "sha1-mMI9qxF1ZXuMBXPozszZGw/xjIQ="
240 | },
241 | "fresh": {
242 | "version": "0.5.2",
243 | "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz",
244 | "integrity": "sha1-PYyt2Q2XZWn6g1qx+OSyOhBWBac="
245 | },
246 | "http-errors": {
247 | "version": "1.6.3",
248 | "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.6.3.tgz",
249 | "integrity": "sha1-i1VoC7S+KDoLW/TqLjhYC+HZMg0=",
250 | "requires": {
251 | "depd": "~1.1.2",
252 | "inherits": "2.0.3",
253 | "setprototypeof": "1.1.0",
254 | "statuses": ">= 1.4.0 < 2"
255 | }
256 | },
257 | "iconv-lite": {
258 | "version": "0.4.23",
259 | "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.23.tgz",
260 | "integrity": "sha512-neyTUVFtahjf0mB3dZT77u+8O0QB89jFdnBkd5P1JgYPbPaia3gXXOVL2fq8VyU2gMMD7SaN7QukTB/pmXYvDA==",
261 | "requires": {
262 | "safer-buffer": ">= 2.1.2 < 3"
263 | }
264 | },
265 | "inherits": {
266 | "version": "2.0.3",
267 | "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz",
268 | "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4="
269 | },
270 | "ipaddr.js": {
271 | "version": "1.6.0",
272 | "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.6.0.tgz",
273 | "integrity": "sha1-4/o1e3c9phnybpXwSdBVxyeW+Gs="
274 | },
275 | "media-typer": {
276 | "version": "0.3.0",
277 | "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz",
278 | "integrity": "sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g="
279 | },
280 | "merge-descriptors": {
281 | "version": "1.0.1",
282 | "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.1.tgz",
283 | "integrity": "sha1-sAqqVW3YtEVoFQ7J0blT8/kMu2E="
284 | },
285 | "methods": {
286 | "version": "1.1.2",
287 | "resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz",
288 | "integrity": "sha1-VSmk1nZUE07cxSZmVoNbD4Ua/O4="
289 | },
290 | "mime": {
291 | "version": "1.4.1",
292 | "resolved": "https://registry.npmjs.org/mime/-/mime-1.4.1.tgz",
293 | "integrity": "sha512-KI1+qOZu5DcW6wayYHSzR/tXKCDC5Om4s1z2QJjDULzLcmf3DvzS7oluY4HCTrc+9FiKmWUgeNLg7W3uIQvxtQ=="
294 | },
295 | "mime-db": {
296 | "version": "1.33.0",
297 | "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.33.0.tgz",
298 | "integrity": "sha512-BHJ/EKruNIqJf/QahvxwQZXKygOQ256myeN/Ew+THcAa5q+PjyTTMMeNQC4DZw5AwfvelsUrA6B67NKMqXDbzQ=="
299 | },
300 | "mime-types": {
301 | "version": "2.1.18",
302 | "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.18.tgz",
303 | "integrity": "sha512-lc/aahn+t4/SWV/qcmumYjymLsWfN3ELhpmVuUFjgsORruuZPVSwAQryq+HHGvO/SI2KVX26bx+En+zhM8g8hQ==",
304 | "requires": {
305 | "mime-db": "~1.33.0"
306 | }
307 | },
308 | "mongodb": {
309 | "version": "3.1.0-beta4",
310 | "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-3.1.0-beta4.tgz",
311 | "integrity": "sha512-nJAK59fFlMWTdEJaTyGp3HeerkIahnupoMNjbszPJVnO63/36aFnlWHqpYrrJwj9GKlmb47YWBIvNo6fdrUL4Q==",
312 | "requires": {
313 | "mongodb-core": "3.1.0-beta4"
314 | }
315 | },
316 | "mongodb-core": {
317 | "version": "3.1.0-beta4",
318 | "resolved": "https://registry.npmjs.org/mongodb-core/-/mongodb-core-3.1.0-beta4.tgz",
319 | "integrity": "sha512-aiwUKBGmFZwBx4CdC1iK5kjZyk0zhDxQ0edRtpTZUkk1jyWkdzYd6GEA6wMl7O6ZX/dOiFM2ujkrUR7+vkqJPw==",
320 | "requires": {
321 | "bson": "~1.0.4",
322 | "require_optional": "^1.0.1",
323 | "saslprep": "^1.0.0"
324 | }
325 | },
326 | "ms": {
327 | "version": "2.0.0",
328 | "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
329 | "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g="
330 | },
331 | "negotiator": {
332 | "version": "0.6.1",
333 | "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.1.tgz",
334 | "integrity": "sha1-KzJxhOiZIQEXeyhWP7XnECrNDKk="
335 | },
336 | "object-assign": {
337 | "version": "4.1.1",
338 | "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz",
339 | "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM="
340 | },
341 | "on-finished": {
342 | "version": "2.3.0",
343 | "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz",
344 | "integrity": "sha1-IPEzZIGwg811M3mSoWlxqi2QaUc=",
345 | "requires": {
346 | "ee-first": "1.1.1"
347 | }
348 | },
349 | "parseurl": {
350 | "version": "1.3.2",
351 | "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.2.tgz",
352 | "integrity": "sha1-/CidTtiZMRlGDBViUyYs3I3mW/M="
353 | },
354 | "path-to-regexp": {
355 | "version": "0.1.7",
356 | "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz",
357 | "integrity": "sha1-32BBeABfUi8V60SQ5yR6G/qmf4w="
358 | },
359 | "proxy-addr": {
360 | "version": "2.0.3",
361 | "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.3.tgz",
362 | "integrity": "sha512-jQTChiCJteusULxjBp8+jftSQE5Obdl3k4cnmLA6WXtK6XFuWRnvVL7aCiBqaLPM8c4ph0S4tKna8XvmIwEnXQ==",
363 | "requires": {
364 | "forwarded": "~0.1.2",
365 | "ipaddr.js": "1.6.0"
366 | }
367 | },
368 | "qs": {
369 | "version": "6.5.1",
370 | "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.1.tgz",
371 | "integrity": "sha512-eRzhrN1WSINYCDCbrz796z37LOe3m5tmW7RQf6oBntukAG1nmovJvhnwHHRMAfeoItc1m2Hk02WER2aQ/iqs+A=="
372 | },
373 | "range-parser": {
374 | "version": "1.2.0",
375 | "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.0.tgz",
376 | "integrity": "sha1-9JvmtIeJTdxA3MlKMi9hEJLgDV4="
377 | },
378 | "raw-body": {
379 | "version": "2.3.3",
380 | "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.3.3.tgz",
381 | "integrity": "sha512-9esiElv1BrZoI3rCDuOuKCBRbuApGGaDPQfjSflGxdy4oyzqghxu6klEkkVIvBje+FF0BX9coEv8KqW6X/7njw==",
382 | "requires": {
383 | "bytes": "3.0.0",
384 | "http-errors": "1.6.3",
385 | "iconv-lite": "0.4.23",
386 | "unpipe": "1.0.0"
387 | }
388 | },
389 | "require_optional": {
390 | "version": "1.0.1",
391 | "resolved": "https://registry.npmjs.org/require_optional/-/require_optional-1.0.1.tgz",
392 | "integrity": "sha512-qhM/y57enGWHAe3v/NcwML6a3/vfESLe/sGM2dII+gEO0BpKRUkWZow/tyloNqJyN6kXSl3RyyM8Ll5D/sJP8g==",
393 | "requires": {
394 | "resolve-from": "^2.0.0",
395 | "semver": "^5.1.0"
396 | }
397 | },
398 | "resolve-from": {
399 | "version": "2.0.0",
400 | "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-2.0.0.tgz",
401 | "integrity": "sha1-lICrIOlP+h2egKgEx+oUdhGWa1c="
402 | },
403 | "safe-buffer": {
404 | "version": "5.1.1",
405 | "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz",
406 | "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg=="
407 | },
408 | "safer-buffer": {
409 | "version": "2.1.2",
410 | "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz",
411 | "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg=="
412 | },
413 | "saslprep": {
414 | "version": "1.0.0",
415 | "resolved": "https://registry.npmjs.org/saslprep/-/saslprep-1.0.0.tgz",
416 | "integrity": "sha512-5lvKUEQ7lAN5/vPl5d3k8FQeDbEamu9kizfATfLLWV5h6Mkh1xcieR1FSsJkcSRUk49lF2tAW8gzXWVwtwZVhw==",
417 | "optional": true
418 | },
419 | "semver": {
420 | "version": "5.5.0",
421 | "resolved": "https://registry.npmjs.org/semver/-/semver-5.5.0.tgz",
422 | "integrity": "sha512-4SJ3dm0WAwWy/NVeioZh5AntkdJoWKxHxcmyP622fOkgHa4z3R0TdBJICINyaSDE6uNwVc8gZr+ZinwZAH4xIA=="
423 | },
424 | "send": {
425 | "version": "0.16.2",
426 | "resolved": "https://registry.npmjs.org/send/-/send-0.16.2.tgz",
427 | "integrity": "sha512-E64YFPUssFHEFBvpbbjr44NCLtI1AohxQ8ZSiJjQLskAdKuriYEP6VyGEsRDH8ScozGpkaX1BGvhanqCwkcEZw==",
428 | "requires": {
429 | "debug": "2.6.9",
430 | "depd": "~1.1.2",
431 | "destroy": "~1.0.4",
432 | "encodeurl": "~1.0.2",
433 | "escape-html": "~1.0.3",
434 | "etag": "~1.8.1",
435 | "fresh": "0.5.2",
436 | "http-errors": "~1.6.2",
437 | "mime": "1.4.1",
438 | "ms": "2.0.0",
439 | "on-finished": "~2.3.0",
440 | "range-parser": "~1.2.0",
441 | "statuses": "~1.4.0"
442 | }
443 | },
444 | "serve-static": {
445 | "version": "1.13.2",
446 | "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.13.2.tgz",
447 | "integrity": "sha512-p/tdJrO4U387R9oMjb1oj7qSMaMfmOyd4j9hOFoxZe2baQszgHcSWjuya/CiT5kgZZKRudHNOA0pYXOl8rQ5nw==",
448 | "requires": {
449 | "encodeurl": "~1.0.2",
450 | "escape-html": "~1.0.3",
451 | "parseurl": "~1.3.2",
452 | "send": "0.16.2"
453 | }
454 | },
455 | "setprototypeof": {
456 | "version": "1.1.0",
457 | "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.1.0.tgz",
458 | "integrity": "sha512-BvE/TwpZX4FXExxOxZyRGQQv651MSwmWKZGqvmPcRIjDqWub67kTKuIMx43cZZrS/cBBzwBcNDWoFxt2XEFIpQ=="
459 | },
460 | "shortid": {
461 | "version": "2.2.8",
462 | "resolved": "https://registry.npmjs.org/shortid/-/shortid-2.2.8.tgz",
463 | "integrity": "sha1-AzsRfWoul1gE9vCWnb59PQs1UTE="
464 | },
465 | "statuses": {
466 | "version": "1.4.0",
467 | "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.4.0.tgz",
468 | "integrity": "sha512-zhSCtt8v2NDrRlPQpCNtw/heZLtfUDqxBM1udqikb/Hbk52LK4nQSwr10u77iopCW5LsyHpuXS0GnEc48mLeew=="
469 | },
470 | "type-is": {
471 | "version": "1.6.16",
472 | "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.16.tgz",
473 | "integrity": "sha512-HRkVv/5qY2G6I8iab9cI7v1bOIdhm94dVjQCPFElW9W+3GeDOSHmy2EBYe4VTApuzolPcmgFTN3ftVJRKR2J9Q==",
474 | "requires": {
475 | "media-typer": "0.3.0",
476 | "mime-types": "~2.1.18"
477 | }
478 | },
479 | "unpipe": {
480 | "version": "1.0.0",
481 | "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz",
482 | "integrity": "sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw="
483 | },
484 | "utils-merge": {
485 | "version": "1.0.1",
486 | "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz",
487 | "integrity": "sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM="
488 | },
489 | "vary": {
490 | "version": "1.1.2",
491 | "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz",
492 | "integrity": "sha1-IpnwLG3tMNSllhsLn3RSShj2NPw="
493 | }
494 | }
495 | }
496 |
--------------------------------------------------------------------------------
/Server/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "focus-block-server",
3 | "version": "1.0.0",
4 | "description": "",
5 | "main": "server.js",
6 | "scripts": {
7 | "start": "node server.js",
8 | "test": "echo \"Error: no test specified\" && exit 1"
9 | },
10 | "author": "Pixelogic",
11 | "license": "ISC",
12 | "dependencies": {
13 | "body-parser": "^1.18.3",
14 | "cors": "^2.8.4",
15 | "dotenv": "^6.0.0",
16 | "express": "^4.16.3",
17 | "mongodb": "^3.1.0-beta4",
18 | "shortid": "^2.2.8"
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/Server/server.js:
--------------------------------------------------------------------------------
1 | //-- Modules --//
2 | require('dotenv').config();
3 | const express = require('express');
4 | const server = express();
5 | const bodyParser = require('body-parser');
6 | const db = require('./Database/db');
7 | const shortid = require('shortid');
8 | const cors = require('cors');
9 |
10 | // Middleware setup //
11 | server.use(cors());
12 | server.use(bodyParser.json());
13 | server.get('/', (req, res) => {
14 | res.send('Welcome to FocusBlock Server!');
15 | });
16 |
17 | // POST new user //
18 | server.post('/new', async (req, res) => {
19 | // Generate unique url & save to db //
20 | console.log('Creating new user...');
21 | let id = shortid.generate();
22 | let userObj = {
23 | _id: id,
24 | url: `${process.env.BASE_PATH}/dashboard/${id}`,
25 | focusBlocks: []
26 | };
27 |
28 | // Write to db //
29 | let result = await db.addUser(userObj).catch(error => {
30 | throw error;
31 | });
32 |
33 | res.send(result);
34 | });
35 |
36 | // GET user by ID //
37 | server.get('/:id', async (req, res) => {
38 | let id = req.params.id;
39 |
40 | // DB lookup to bring back data //
41 | let user = await db.findUser(id).catch(error => {
42 | throw error;
43 | });
44 |
45 | res.send(user);
46 | });
47 |
48 | // POST new data for user by ID //
49 | server.post('/:id', async (req, res) => {
50 | // Get json body //
51 | let data = {
52 | id: req.params.id,
53 | focusBlocks: req.body.focusBlocks
54 | };
55 |
56 | // Write to DB //
57 | let result = await db.updateUser(data).catch(error => {
58 | throw error;
59 | });
60 | res.send({ result: result });
61 | });
62 |
63 | server.listen(process.env.PORT || 8000, () => {
64 | console.log('Connected to FocusBlock Server!');
65 | });
66 |
--------------------------------------------------------------------------------
/focus-block/.gitignore:
--------------------------------------------------------------------------------
1 | # See https://help.github.com/ignore-files/ for more about ignoring files.
2 |
3 | # dependencies
4 | /node_modules
5 |
6 | # testing
7 | /coverage
8 |
9 | # production
10 | /build
11 |
12 | # misc
13 | .DS_Store
14 | .env.local
15 | .env.development.local
16 | .env.test.local
17 | .env.production.local
18 |
19 | npm-debug.log*
20 | yarn-debug.log*
21 | yarn-error.log*
22 |
--------------------------------------------------------------------------------
/focus-block/README.md:
--------------------------------------------------------------------------------
1 | This project was bootstrapped with [Create React App](https://github.com/facebookincubator/create-react-app).
2 |
3 | Below you will find some information on how to perform common tasks.
4 | You can find the most recent version of this guide [here](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md).
5 |
6 | ## Table of Contents
7 |
8 | - [Updating to New Releases](#updating-to-new-releases)
9 | - [Sending Feedback](#sending-feedback)
10 | - [Folder Structure](#folder-structure)
11 | - [Available Scripts](#available-scripts)
12 | - [npm start](#npm-start)
13 | - [npm test](#npm-test)
14 | - [npm run build](#npm-run-build)
15 | - [npm run eject](#npm-run-eject)
16 | - [Supported Browsers](#supported-browsers)
17 | - [Supported Language Features and Polyfills](#supported-language-features-and-polyfills)
18 | - [Syntax Highlighting in the Editor](#syntax-highlighting-in-the-editor)
19 | - [Displaying Lint Output in the Editor](#displaying-lint-output-in-the-editor)
20 | - [Debugging in the Editor](#debugging-in-the-editor)
21 | - [Formatting Code Automatically](#formatting-code-automatically)
22 | - [Changing the Page `
`](#changing-the-page-title)
23 | - [Installing a Dependency](#installing-a-dependency)
24 | - [Importing a Component](#importing-a-component)
25 | - [Code Splitting](#code-splitting)
26 | - [Adding a Stylesheet](#adding-a-stylesheet)
27 | - [Post-Processing CSS](#post-processing-css)
28 | - [Adding a CSS Preprocessor (Sass, Less etc.)](#adding-a-css-preprocessor-sass-less-etc)
29 | - [Adding Images, Fonts, and Files](#adding-images-fonts-and-files)
30 | - [Using the `public` Folder](#using-the-public-folder)
31 | - [Changing the HTML](#changing-the-html)
32 | - [Adding Assets Outside of the Module System](#adding-assets-outside-of-the-module-system)
33 | - [When to Use the `public` Folder](#when-to-use-the-public-folder)
34 | - [Using Global Variables](#using-global-variables)
35 | - [Adding Bootstrap](#adding-bootstrap)
36 | - [Using a Custom Theme](#using-a-custom-theme)
37 | - [Adding Flow](#adding-flow)
38 | - [Adding a Router](#adding-a-router)
39 | - [Adding Custom Environment Variables](#adding-custom-environment-variables)
40 | - [Referencing Environment Variables in the HTML](#referencing-environment-variables-in-the-html)
41 | - [Adding Temporary Environment Variables In Your Shell](#adding-temporary-environment-variables-in-your-shell)
42 | - [Adding Development Environment Variables In `.env`](#adding-development-environment-variables-in-env)
43 | - [Can I Use Decorators?](#can-i-use-decorators)
44 | - [Fetching Data with AJAX Requests](#fetching-data-with-ajax-requests)
45 | - [Integrating with an API Backend](#integrating-with-an-api-backend)
46 | - [Node](#node)
47 | - [Ruby on Rails](#ruby-on-rails)
48 | - [Proxying API Requests in Development](#proxying-api-requests-in-development)
49 | - ["Invalid Host Header" Errors After Configuring Proxy](#invalid-host-header-errors-after-configuring-proxy)
50 | - [Configuring the Proxy Manually](#configuring-the-proxy-manually)
51 | - [Configuring a WebSocket Proxy](#configuring-a-websocket-proxy)
52 | - [Using HTTPS in Development](#using-https-in-development)
53 | - [Generating Dynamic `` Tags on the Server](#generating-dynamic-meta-tags-on-the-server)
54 | - [Pre-Rendering into Static HTML Files](#pre-rendering-into-static-html-files)
55 | - [Injecting Data from the Server into the Page](#injecting-data-from-the-server-into-the-page)
56 | - [Running Tests](#running-tests)
57 | - [Filename Conventions](#filename-conventions)
58 | - [Command Line Interface](#command-line-interface)
59 | - [Version Control Integration](#version-control-integration)
60 | - [Writing Tests](#writing-tests)
61 | - [Testing Components](#testing-components)
62 | - [Using Third Party Assertion Libraries](#using-third-party-assertion-libraries)
63 | - [Initializing Test Environment](#initializing-test-environment)
64 | - [Focusing and Excluding Tests](#focusing-and-excluding-tests)
65 | - [Coverage Reporting](#coverage-reporting)
66 | - [Continuous Integration](#continuous-integration)
67 | - [Disabling jsdom](#disabling-jsdom)
68 | - [Snapshot Testing](#snapshot-testing)
69 | - [Editor Integration](#editor-integration)
70 | - [Debugging Tests](#debugging-tests)
71 | - [Debugging Tests in Chrome](#debugging-tests-in-chrome)
72 | - [Debugging Tests in Visual Studio Code](#debugging-tests-in-visual-studio-code)
73 | - [Developing Components in Isolation](#developing-components-in-isolation)
74 | - [Getting Started with Storybook](#getting-started-with-storybook)
75 | - [Getting Started with Styleguidist](#getting-started-with-styleguidist)
76 | - [Publishing Components to npm](#publishing-components-to-npm)
77 | - [Making a Progressive Web App](#making-a-progressive-web-app)
78 | - [Opting Out of Caching](#opting-out-of-caching)
79 | - [Offline-First Considerations](#offline-first-considerations)
80 | - [Progressive Web App Metadata](#progressive-web-app-metadata)
81 | - [Analyzing the Bundle Size](#analyzing-the-bundle-size)
82 | - [Deployment](#deployment)
83 | - [Static Server](#static-server)
84 | - [Other Solutions](#other-solutions)
85 | - [Serving Apps with Client-Side Routing](#serving-apps-with-client-side-routing)
86 | - [Building for Relative Paths](#building-for-relative-paths)
87 | - [Azure](#azure)
88 | - [Firebase](#firebase)
89 | - [GitHub Pages](#github-pages)
90 | - [Heroku](#heroku)
91 | - [Netlify](#netlify)
92 | - [Now](#now)
93 | - [S3 and CloudFront](#s3-and-cloudfront)
94 | - [Surge](#surge)
95 | - [Advanced Configuration](#advanced-configuration)
96 | - [Troubleshooting](#troubleshooting)
97 | - [`npm start` doesn’t detect changes](#npm-start-doesnt-detect-changes)
98 | - [`npm test` hangs on macOS Sierra](#npm-test-hangs-on-macos-sierra)
99 | - [`npm run build` exits too early](#npm-run-build-exits-too-early)
100 | - [`npm run build` fails on Heroku](#npm-run-build-fails-on-heroku)
101 | - [`npm run build` fails to minify](#npm-run-build-fails-to-minify)
102 | - [Moment.js locales are missing](#momentjs-locales-are-missing)
103 | - [Alternatives to Ejecting](#alternatives-to-ejecting)
104 | - [Something Missing?](#something-missing)
105 |
106 | ## Updating to New Releases
107 |
108 | Create React App is divided into two packages:
109 |
110 | * `create-react-app` is a global command-line utility that you use to create new projects.
111 | * `react-scripts` is a development dependency in the generated projects (including this one).
112 |
113 | You almost never need to update `create-react-app` itself: it delegates all the setup to `react-scripts`.
114 |
115 | When you run `create-react-app`, it always creates the project with the latest version of `react-scripts` so you’ll get all the new features and improvements in newly created apps automatically.
116 |
117 | To update an existing project to a new version of `react-scripts`, [open the changelog](https://github.com/facebookincubator/create-react-app/blob/master/CHANGELOG.md), find the version you’re currently on (check `package.json` in this folder if you’re not sure), and apply the migration instructions for the newer versions.
118 |
119 | In most cases bumping the `react-scripts` version in `package.json` and running `npm install` in this folder should be enough, but it’s good to consult the [changelog](https://github.com/facebookincubator/create-react-app/blob/master/CHANGELOG.md) for potential breaking changes.
120 |
121 | We commit to keeping the breaking changes minimal so you can upgrade `react-scripts` painlessly.
122 |
123 | ## Sending Feedback
124 |
125 | We are always open to [your feedback](https://github.com/facebookincubator/create-react-app/issues).
126 |
127 | ## Folder Structure
128 |
129 | After creation, your project should look like this:
130 |
131 | ```
132 | my-app/
133 | README.md
134 | node_modules/
135 | package.json
136 | public/
137 | index.html
138 | favicon.ico
139 | src/
140 | App.css
141 | App.js
142 | App.test.js
143 | index.css
144 | index.js
145 | logo.svg
146 | ```
147 |
148 | For the project to build, **these files must exist with exact filenames**:
149 |
150 | * `public/index.html` is the page template;
151 | * `src/index.js` is the JavaScript entry point.
152 |
153 | You can delete or rename the other files.
154 |
155 | You may create subdirectories inside `src`. For faster rebuilds, only files inside `src` are processed by Webpack.
156 | You need to **put any JS and CSS files inside `src`**, otherwise Webpack won’t see them.
157 |
158 | Only files inside `public` can be used from `public/index.html`.
159 | Read instructions below for using assets from JavaScript and HTML.
160 |
161 | You can, however, create more top-level directories.
162 | They will not be included in the production build so you can use them for things like documentation.
163 |
164 | ## Available Scripts
165 |
166 | In the project directory, you can run:
167 |
168 | ### `npm start`
169 |
170 | Runs the app in the development mode.
171 | Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
172 |
173 | The page will reload if you make edits.
174 | You will also see any lint errors in the console.
175 |
176 | ### `npm test`
177 |
178 | Launches the test runner in the interactive watch mode.
179 | See the section about [running tests](#running-tests) for more information.
180 |
181 | ### `npm run build`
182 |
183 | Builds the app for production to the `build` folder.
184 | It correctly bundles React in production mode and optimizes the build for the best performance.
185 |
186 | The build is minified and the filenames include the hashes.
187 | Your app is ready to be deployed!
188 |
189 | See the section about [deployment](#deployment) for more information.
190 |
191 | ### `npm run eject`
192 |
193 | **Note: this is a one-way operation. Once you `eject`, you can’t go back!**
194 |
195 | 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.
196 |
197 | 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.
198 |
199 | 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.
200 |
201 | ## Supported Browsers
202 |
203 | By default, the generated project uses the latest version of React.
204 |
205 | You can refer [to the React documentation](https://reactjs.org/docs/react-dom.html#browser-support) for more information about supported browsers.
206 |
207 | ## Supported Language Features and Polyfills
208 |
209 | This project supports a superset of the latest JavaScript standard.
210 | In addition to [ES6](https://github.com/lukehoban/es6features) syntax features, it also supports:
211 |
212 | * [Exponentiation Operator](https://github.com/rwaldron/exponentiation-operator) (ES2016).
213 | * [Async/await](https://github.com/tc39/ecmascript-asyncawait) (ES2017).
214 | * [Object Rest/Spread Properties](https://github.com/sebmarkbage/ecmascript-rest-spread) (stage 3 proposal).
215 | * [Dynamic import()](https://github.com/tc39/proposal-dynamic-import) (stage 3 proposal)
216 | * [Class Fields and Static Properties](https://github.com/tc39/proposal-class-public-fields) (part of stage 3 proposal).
217 | * [JSX](https://facebook.github.io/react/docs/introducing-jsx.html) and [Flow](https://flowtype.org/) syntax.
218 |
219 | Learn more about [different proposal stages](https://babeljs.io/docs/plugins/#presets-stage-x-experimental-presets-).
220 |
221 | While we recommend using experimental proposals with some caution, Facebook heavily uses these features in the product code, so we intend to provide [codemods](https://medium.com/@cpojer/effective-javascript-codemods-5a6686bb46fb) if any of these proposals change in the future.
222 |
223 | Note that **the project only includes a few ES6 [polyfills](https://en.wikipedia.org/wiki/Polyfill)**:
224 |
225 | * [`Object.assign()`](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Object/assign) via [`object-assign`](https://github.com/sindresorhus/object-assign).
226 | * [`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) via [`promise`](https://github.com/then/promise).
227 | * [`fetch()`](https://developer.mozilla.org/en/docs/Web/API/Fetch_API) via [`whatwg-fetch`](https://github.com/github/fetch).
228 |
229 | If you use any other ES6+ features that need **runtime support** (such as `Array.from()` or `Symbol`), make sure you are including the appropriate polyfills manually, or that the browsers you are targeting already support them.
230 |
231 | Also note that using some newer syntax features like `for...of` or `[...nonArrayValue]` causes Babel to emit code that depends on ES6 runtime features and might not work without a polyfill. When in doubt, use [Babel REPL](https://babeljs.io/repl/) to see what any specific syntax compiles down to.
232 |
233 | ## Syntax Highlighting in the Editor
234 |
235 | To configure the syntax highlighting in your favorite text editor, head to the [relevant Babel documentation page](https://babeljs.io/docs/editors) and follow the instructions. Some of the most popular editors are covered.
236 |
237 | ## Displaying Lint Output in the Editor
238 |
239 | >Note: this feature is available with `react-scripts@0.2.0` and higher.
240 | >It also only works with npm 3 or higher.
241 |
242 | Some editors, including Sublime Text, Atom, and Visual Studio Code, provide plugins for ESLint.
243 |
244 | They are not required for linting. You should see the linter output right in your terminal as well as the browser console. However, if you prefer the lint results to appear right in your editor, there are some extra steps you can do.
245 |
246 | You would need to install an ESLint plugin for your editor first. Then, add a file called `.eslintrc` to the project root:
247 |
248 | ```js
249 | {
250 | "extends": "react-app"
251 | }
252 | ```
253 |
254 | Now your editor should report the linting warnings.
255 |
256 | Note that even if you edit your `.eslintrc` file further, these changes will **only affect the editor integration**. They won’t affect the terminal and in-browser lint output. This is because Create React App intentionally provides a minimal set of rules that find common mistakes.
257 |
258 | If you want to enforce a coding style for your project, consider using [Prettier](https://github.com/jlongster/prettier) instead of ESLint style rules.
259 |
260 | ## Debugging in the Editor
261 |
262 | **This feature is currently only supported by [Visual Studio Code](https://code.visualstudio.com) and [WebStorm](https://www.jetbrains.com/webstorm/).**
263 |
264 | Visual Studio Code and WebStorm support debugging out of the box with Create React App. This enables you as a developer to write and debug your React code without leaving the editor, and most importantly it enables you to have a continuous development workflow, where context switching is minimal, as you don’t have to switch between tools.
265 |
266 | ### Visual Studio Code
267 |
268 | You would need to have the latest version of [VS Code](https://code.visualstudio.com) and VS Code [Chrome Debugger Extension](https://marketplace.visualstudio.com/items?itemName=msjsdiag.debugger-for-chrome) installed.
269 |
270 | Then add the block below to your `launch.json` file and put it inside the `.vscode` folder in your app’s root directory.
271 |
272 | ```json
273 | {
274 | "version": "0.2.0",
275 | "configurations": [{
276 | "name": "Chrome",
277 | "type": "chrome",
278 | "request": "launch",
279 | "url": "http://localhost:3000",
280 | "webRoot": "${workspaceRoot}/src",
281 | "sourceMapPathOverrides": {
282 | "webpack:///src/*": "${webRoot}/*"
283 | }
284 | }]
285 | }
286 | ```
287 | >Note: the URL may be different if you've made adjustments via the [HOST or PORT environment variables](#advanced-configuration).
288 |
289 | Start your app by running `npm start`, and start debugging in VS Code by pressing `F5` or by clicking the green debug icon. You can now write code, set breakpoints, make changes to the code, and debug your newly modified code—all from your editor.
290 |
291 | Having problems with VS Code Debugging? Please see their [troubleshooting guide](https://github.com/Microsoft/vscode-chrome-debug/blob/master/README.md#troubleshooting).
292 |
293 | ### WebStorm
294 |
295 | You would need to have [WebStorm](https://www.jetbrains.com/webstorm/) and [JetBrains IDE Support](https://chrome.google.com/webstore/detail/jetbrains-ide-support/hmhgeddbohgjknpmjagkdomcpobmllji) Chrome extension installed.
296 |
297 | In the WebStorm menu `Run` select `Edit Configurations...`. Then click `+` and select `JavaScript Debug`. Paste `http://localhost:3000` into the URL field and save the configuration.
298 |
299 | >Note: the URL may be different if you've made adjustments via the [HOST or PORT environment variables](#advanced-configuration).
300 |
301 | Start your app by running `npm start`, then press `^D` on macOS or `F9` on Windows and Linux or click the green debug icon to start debugging in WebStorm.
302 |
303 | The same way you can debug your application in IntelliJ IDEA Ultimate, PhpStorm, PyCharm Pro, and RubyMine.
304 |
305 | ## Formatting Code Automatically
306 |
307 | Prettier is an opinionated code formatter with support for JavaScript, CSS and JSON. With Prettier you can format the code you write automatically to ensure a code style within your project. See the [Prettier's GitHub page](https://github.com/prettier/prettier) for more information, and look at this [page to see it in action](https://prettier.github.io/prettier/).
308 |
309 | To format our code whenever we make a commit in git, we need to install the following dependencies:
310 |
311 | ```sh
312 | npm install --save husky lint-staged prettier
313 | ```
314 |
315 | Alternatively you may use `yarn`:
316 |
317 | ```sh
318 | yarn add husky lint-staged prettier
319 | ```
320 |
321 | * `husky` makes it easy to use githooks as if they are npm scripts.
322 | * `lint-staged` allows us to run scripts on staged files in git. See this [blog post about lint-staged to learn more about it](https://medium.com/@okonetchnikov/make-linting-great-again-f3890e1ad6b8).
323 | * `prettier` is the JavaScript formatter we will run before commits.
324 |
325 | Now we can make sure every file is formatted correctly by adding a few lines to the `package.json` in the project root.
326 |
327 | Add the following line to `scripts` section:
328 |
329 | ```diff
330 | "scripts": {
331 | + "precommit": "lint-staged",
332 | "start": "react-scripts start",
333 | "build": "react-scripts build",
334 | ```
335 |
336 | Next we add a 'lint-staged' field to the `package.json`, for example:
337 |
338 | ```diff
339 | "dependencies": {
340 | // ...
341 | },
342 | + "lint-staged": {
343 | + "src/**/*.{js,jsx,json,css}": [
344 | + "prettier --single-quote --write",
345 | + "git add"
346 | + ]
347 | + },
348 | "scripts": {
349 | ```
350 |
351 | Now, whenever you make a commit, Prettier will format the changed files automatically. You can also run `./node_modules/.bin/prettier --single-quote --write "src/**/*.{js,jsx,json,css}"` to format your entire project for the first time.
352 |
353 | Next you might want to integrate Prettier in your favorite editor. Read the section on [Editor Integration](https://prettier.io/docs/en/editors.html) on the Prettier GitHub page.
354 |
355 | ## Changing the Page ``
356 |
357 | You can find the source HTML file in the `public` folder of the generated project. You may edit the `` tag in it to change the title from “React App” to anything else.
358 |
359 | Note that normally you wouldn’t edit files in the `public` folder very often. For example, [adding a stylesheet](#adding-a-stylesheet) is done without touching the HTML.
360 |
361 | If you need to dynamically update the page title based on the content, you can use the browser [`document.title`](https://developer.mozilla.org/en-US/docs/Web/API/Document/title) API. For more complex scenarios when you want to change the title from React components, you can use [React Helmet](https://github.com/nfl/react-helmet), a third party library.
362 |
363 | If you use a custom server for your app in production and want to modify the title before it gets sent to the browser, you can follow advice in [this section](#generating-dynamic-meta-tags-on-the-server). Alternatively, you can pre-build each page as a static HTML file which then loads the JavaScript bundle, which is covered [here](#pre-rendering-into-static-html-files).
364 |
365 | ## Installing a Dependency
366 |
367 | The generated project includes React and ReactDOM as dependencies. It also includes a set of scripts used by Create React App as a development dependency. You may install other dependencies (for example, React Router) with `npm`:
368 |
369 | ```sh
370 | npm install --save react-router
371 | ```
372 |
373 | Alternatively you may use `yarn`:
374 |
375 | ```sh
376 | yarn add react-router
377 | ```
378 |
379 | This works for any library, not just `react-router`.
380 |
381 | ## Importing a Component
382 |
383 | This project setup supports ES6 modules thanks to Babel.
384 | While you can still use `require()` and `module.exports`, we encourage you to use [`import` and `export`](http://exploringjs.com/es6/ch_modules.html) instead.
385 |
386 | For example:
387 |
388 | ### `Button.js`
389 |
390 | ```js
391 | import React, { Component } from 'react';
392 |
393 | class Button extends Component {
394 | render() {
395 | // ...
396 | }
397 | }
398 |
399 | export default Button; // Don’t forget to use export default!
400 | ```
401 |
402 | ### `DangerButton.js`
403 |
404 |
405 | ```js
406 | import React, { Component } from 'react';
407 | import Button from './Button'; // Import a component from another file
408 |
409 | class DangerButton extends Component {
410 | render() {
411 | return ;
412 | }
413 | }
414 |
415 | export default DangerButton;
416 | ```
417 |
418 | Be aware of the [difference between default and named exports](http://stackoverflow.com/questions/36795819/react-native-es-6-when-should-i-use-curly-braces-for-import/36796281#36796281). It is a common source of mistakes.
419 |
420 | We suggest that you stick to using default imports and exports when a module only exports a single thing (for example, a component). That’s what you get when you use `export default Button` and `import Button from './Button'`.
421 |
422 | Named exports are useful for utility modules that export several functions. A module may have at most one default export and as many named exports as you like.
423 |
424 | Learn more about ES6 modules:
425 |
426 | * [When to use the curly braces?](http://stackoverflow.com/questions/36795819/react-native-es-6-when-should-i-use-curly-braces-for-import/36796281#36796281)
427 | * [Exploring ES6: Modules](http://exploringjs.com/es6/ch_modules.html)
428 | * [Understanding ES6: Modules](https://leanpub.com/understandinges6/read#leanpub-auto-encapsulating-code-with-modules)
429 |
430 | ## Code Splitting
431 |
432 | Instead of downloading the entire app before users can use it, code splitting allows you to split your code into small chunks which you can then load on demand.
433 |
434 | This project setup supports code splitting via [dynamic `import()`](http://2ality.com/2017/01/import-operator.html#loading-code-on-demand). Its [proposal](https://github.com/tc39/proposal-dynamic-import) is in stage 3. The `import()` function-like form takes the module name as an argument and returns a [`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) which always resolves to the namespace object of the module.
435 |
436 | Here is an example:
437 |
438 | ### `moduleA.js`
439 |
440 | ```js
441 | const moduleA = 'Hello';
442 |
443 | export { moduleA };
444 | ```
445 | ### `App.js`
446 |
447 | ```js
448 | import React, { Component } from 'react';
449 |
450 | class App extends Component {
451 | handleClick = () => {
452 | import('./moduleA')
453 | .then(({ moduleA }) => {
454 | // Use moduleA
455 | })
456 | .catch(err => {
457 | // Handle failure
458 | });
459 | };
460 |
461 | render() {
462 | return (
463 |
464 |
465 |
466 | );
467 | }
468 | }
469 |
470 | export default App;
471 | ```
472 |
473 | This will make `moduleA.js` and all its unique dependencies as a separate chunk that only loads after the user clicks the 'Load' button.
474 |
475 | You can also use it with `async` / `await` syntax if you prefer it.
476 |
477 | ### With React Router
478 |
479 | If you are using React Router check out [this tutorial](http://serverless-stack.com/chapters/code-splitting-in-create-react-app.html) on how to use code splitting with it. You can find the companion GitHub repository [here](https://github.com/AnomalyInnovations/serverless-stack-demo-client/tree/code-splitting-in-create-react-app).
480 |
481 | Also check out the [Code Splitting](https://reactjs.org/docs/code-splitting.html) section in React documentation.
482 |
483 | ## Adding a Stylesheet
484 |
485 | This project setup uses [Webpack](https://webpack.js.org/) for handling all assets. Webpack offers a custom way of “extending” the concept of `import` beyond JavaScript. To express that a JavaScript file depends on a CSS file, you need to **import the CSS from the JavaScript file**:
486 |
487 | ### `Button.css`
488 |
489 | ```css
490 | .Button {
491 | padding: 20px;
492 | }
493 | ```
494 |
495 | ### `Button.js`
496 |
497 | ```js
498 | import React, { Component } from 'react';
499 | import './Button.css'; // Tell Webpack that Button.js uses these styles
500 |
501 | class Button extends Component {
502 | render() {
503 | // You can use them as regular CSS styles
504 | return ;
505 | }
506 | }
507 | ```
508 |
509 | **This is not required for React** but many people find this feature convenient. You can read about the benefits of this approach [here](https://medium.com/seek-ui-engineering/block-element-modifying-your-javascript-components-d7f99fcab52b). However you should be aware that this makes your code less portable to other build tools and environments than Webpack.
510 |
511 | In development, expressing dependencies this way allows your styles to be reloaded on the fly as you edit them. In production, all CSS files will be concatenated into a single minified `.css` file in the build output.
512 |
513 | If you are concerned about using Webpack-specific semantics, you can put all your CSS right into `src/index.css`. It would still be imported from `src/index.js`, but you could always remove that import if you later migrate to a different build tool.
514 |
515 | ## Post-Processing CSS
516 |
517 | This project setup minifies your CSS and adds vendor prefixes to it automatically through [Autoprefixer](https://github.com/postcss/autoprefixer) so you don’t need to worry about it.
518 |
519 | For example, this:
520 |
521 | ```css
522 | .App {
523 | display: flex;
524 | flex-direction: row;
525 | align-items: center;
526 | }
527 | ```
528 |
529 | becomes this:
530 |
531 | ```css
532 | .App {
533 | display: -webkit-box;
534 | display: -ms-flexbox;
535 | display: flex;
536 | -webkit-box-orient: horizontal;
537 | -webkit-box-direction: normal;
538 | -ms-flex-direction: row;
539 | flex-direction: row;
540 | -webkit-box-align: center;
541 | -ms-flex-align: center;
542 | align-items: center;
543 | }
544 | ```
545 |
546 | If you need to disable autoprefixing for some reason, [follow this section](https://github.com/postcss/autoprefixer#disabling).
547 |
548 | ## Adding a CSS Preprocessor (Sass, Less etc.)
549 |
550 | Generally, we recommend that you don’t reuse the same CSS classes across different components. For example, instead of using a `.Button` CSS class in `` and `` components, we recommend creating a `