Skip to content

Commit 8cb0804

Browse files
committed
Merge branch 'development' into master
2 parents f1c7e8d + c4922e6 commit 8cb0804

File tree

14 files changed

+436
-141
lines changed

14 files changed

+436
-141
lines changed

README.md

Lines changed: 12 additions & 111 deletions
Original file line numberDiff line numberDiff line change
@@ -3,37 +3,6 @@
33
A simple chat application that uses react.js, redux and socket.io.
44

55

6-
## things left to have the v1
7-
8-
- [x] finish UI/layout components and styles with light/dark color themes
9-
10-
- [x] finish the redux code to manage the application data/states
11-
12-
- [x] socket.io
13-
14-
- [x] socket.io-client mock
15-
16-
- [x] connect to the socket.io server to handle the messages
17-
18-
- [x] build a local socket.io server
19-
20-
- [x] connect to the local socket.io server
21-
22-
- [x] deploy socket.io server to a now.sh instance
23-
24-
- [x] connect to the remote socket.io server
25-
26-
- [x] use the settings theme state to switch between the themes
27-
28-
- [x] add local storage support to persist the changes on the settings page
29-
30-
- [x] add i18n (internationalization) support
31-
32-
- [x] add the unreaded messages to the chat tab when user is on the settings tab
33-
34-
- [ ] write down the documentation under the `docs/` directory
35-
36-
376
## Prerequisites
387

398
* Must have [Git](https://git-scm.com/) installed
@@ -72,95 +41,27 @@ A simple chat application that uses react.js, redux and socket.io.
7241
* deploy the production build to the github gh-pages: `yarn do-deploy` or `npm run do-deploy`
7342

7443

75-
## Useful links
76-
77-
### Styles (CSS and SASS)
78-
79-
* [Understanding and Using rem Units in CSS — SitePoint](https://www.sitepoint.com/understanding-and-using-rem-units-in-css/)
80-
81-
* [Sass's `@content` Directive Use Cases](https://robots.thoughtbot.com/sasss-content-directive)
82-
83-
* [BEM](http://getbem.com/)
84-
85-
* [Using Sass to Control Scope With BEM Naming | CSS-Tricks](https://css-tricks.com/using-sass-control-scope-bem-naming/) - 2018/02/28
86-
87-
* [Modular CSS with Sass & BEM | Mat Hayward](http://mathayward.com/modular-css-with-sass-and-bem/) - 2014/01/17
88-
89-
90-
### Webpack
91-
92-
* [Webpack](https://webpack.js.org/)
93-
94-
* [How to use Webpack with React: an in-depth tutorial | freeCodeCamp](https://medium.freecodecamp.org/learn-webpack-for-react-a36d4cac5060)
95-
96-
* [Optimizing front-end delivery with Webpack 4 | Jasel Gadhia](https://jes.al/2018/04/optimizing-front-end-delivery-with-Webpack-4/)
97-
98-
99-
### React and Redux( middleware( thunk ) )
100-
101-
* [React](https://reactjs.org/)
102-
103-
* [[YouTube] 6 Pro Tips from React Developers](https://www.youtube.com/watch?v=xa-_FIy2NgE)
104-
105-
* [React Stateless Functional Components: Nine Wins You Might Have Overlooked | Hackernoon](https://hackernoon.com/react-stateless-functional-components-nine-wins-you-might-have-overlooked-997b0d933dbc) - 2016/03/28
106-
107-
* [[YouTube] Get derived state from props in React 16.3 | hackages.tv](https://www.youtube.com/watch?v=p_m4TrYGtCo) - 2018/03/14
108-
109-
110-
* Forms
111-
112-
* [Forms | React Docs](https://reactjs.org/docs/forms.html)
113-
114-
* [React Forms: Using Refs | CSS-Tricks](https://css-tricks.com/react-forms-using-refs/)
115-
116-
* [Better Form Management | Robbie Dela Victoria – Medium](https://medium.com/@robbiedelavictoria/better-form-management-37c994095b1c)
117-
118-
119-
* i18n
120-
121-
* [i18n next](https://www.i18next.com/)
122-
123-
* [react i18n next](https://react.i18next.com/)
124-
125-
* [I18n with React and i18next | Danny Hurlburt - Alligator.io](https://alligator.io/react/i18n-with-react-and-i18next)
126-
127-
* [[GitHub] i18next / react-i18next / examples](https://github.com/i18next/react-i18next/tree/master/example)
128-
129-
* [[SandBox Editor] react i18n next example](https://codesandbox.io/s/l4qrory2nl)
130-
131-
--
132-
133-
* [Redux Integration | React Router Docs](https://reacttraining.com/react-router/web/guides/redux-integration)
134-
135-
--
136-
137-
* [Redux](https://redux.js.org/)
138-
139-
* [[Sandbox Editor] Todos](https://codesandbox.io/s/github/reduxjs/redux/tree/master/examples/todos)
140-
141-
* [A Dummy's Guide to Redux and Thunk in React | Matt Stow on CodePen](https://codepen.io/stowball/post/a-dummy-s-guide-to-redux-and-thunk-in-react)
142-
143-
* [[GitHub] stowball / dummys-guide-to-redux-and-thunk-react](https://github.com/stowball/dummys-guide-to-redux-and-thunk-react)
44+
## [Documentation](docs/README.md)
14445

145-
* [Redux: Persisting the State to the Local Storage | @dan_abramov on @eggheadio](https://egghead.io/lessons/javascript-redux-persisting-the-state-to-the-local-storage)
46+
* [Versioning system](docs/README.md#versioning-system)
14647

147-
* [[GitHub] reduxjs / redux-thunk](https://github.com/reduxjs/redux-thunk) - use [withExtraArgument](https://github.com/reduxjs/redux-thunk#injecting-a-custom-argument) to inject the SocketIO service and localstorage service API
48+
* [Application requirements](docs/README.md#application-requirements)
14849

149-
* [Super Simple Redux Thunk Example | Tyler Buchea](http://blog.tylerbuchea.com/super-simple-redux-thunk-example/) - 2017/10/10 ([Sandbox Editor](https://codesandbox.io/s/github/tylerbuchea/my-simple-async-app))
50+
* [Features](docs/requirements/features.md)
15051

151-
* Multiple actions
52+
* [Techinal](docs/requirements/techinal.md)
15253

153-
* [Can I dispatch multiple actions from Redux action creators?](http://jamesknelson.com/can-i-dispatch-multiple-actions-from-redux-action-creators/)
54+
* [About the project](docs/README.md#about-the-project)
15455

155-
* [Redux Thunk – how to populate various reducers](http://frontendinsights.com/redux-thunk-populate-various-reducers/)
56+
* [Architecture](docs/project/README.md#architecture)
15657

58+
* [Folders](docs/project/README.md#folders)
15759

158-
#### Code Style Guide
60+
* [Code](docs/project/README.md#code)
15961

160-
* [[Gist] datchley / react-redux-style-guide.md](https://gist.github.com/datchley/4e0d05c526d532d1b05bf9b48b174faf) - React + [Redux](https://gist.github.com/datchley/4e0d05c526d532d1b05bf9b48b174faf#redux) Style Guide
62+
* [Dependencies](docs/project/README.md#dependencies)
16163

162-
* Project architecture re-ducks: [Scaling your Redux App with ducks | freeCodeCamp](https://medium.freecodecamp.org/scaling-your-redux-app-with-ducks-6115955638be)
64+
* [Features](docs/project/features.md)
16365

164-
* [[GitHub] alexnm / re-ducks](https://github.com/alexnm/re-ducks) - An attempt to extend the original proposal for redux modular architecture
66+
* [Useful references](docs/project/useful-references.md)
16567

166-
* [[GitHub] FortechRomania / react-redux-complete-example](https://github.com/FortechRomania/react-redux-complete-example) - A react+redux example project based on the re-ducks folder structure

docs/README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# React Socket Simple Chat - Documentation
2+
3+
## Versioning system
4+
5+
* This project follows the [Semantic Versioning](https://semver.org/) pattern
6+
7+
8+
## Application requirements
9+
10+
* [Features](requirements/features.md)
11+
12+
* [Techinal](requirements/techinal.md)
13+
14+
15+
## [About the project](project)
16+
17+
* [Architecture](project/README.md#architecture)
18+
19+
* [Folders](project/README.md#folders)
20+
21+
* [Code](project/README.md#code)
22+
23+
* [Dependencies](project/README.md#dependencies)
24+
25+
* [Features](project/features.md)
26+
27+
* [Useful references](project/useful-references.md)

docs/assets/mobile-ui-mockups.png

76.4 KB
Loading
73 KB
Binary file not shown.

docs/project/README.md

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
# Project
2+
3+
4+
## Architecture
5+
6+
### Frontend
7+
8+
* It uses React to build the UI, React Router to handle its pages, Redux to manage its data/states, Redux Thunk to have a middleware where is possible to inject the socket.io client to send the messages and the function to switch between languages. ([useful references](useful-references.md#react-and-redux-middleware-thunk---) about them)
9+
10+
* It follows the redux re-ducks pattern and try to follow some react + redux code style guide ([useful references](useful-references.md#code-style-guide) about it)
11+
12+
* It uses SASS to handle the styles, follows the BEM pattern and uses the flexbox to handle the layout ([useful references](useful-references.md#styles-css-and-sass))
13+
14+
15+
### Backend - socket.io server
16+
17+
* It has it own socket.io server and also has a deployed version of it over the now.sh ([read more about](../../server/README.md))
18+
19+
20+
### Tools
21+
22+
* It uses the [node.js](https://nodejs.org/) LTS (v8)
23+
24+
* It uses the [Webpack](https://webpack.js.org/) v4 with the HMR support and is tunned to enable a multi devices development ([useful references](useful-references.md#webpack))
25+
26+
* It is also has a configuration to make it possible to do imports where the `./src/` is the root folder, so we can do imports like `import constants from 'chat/constants';` from anywhere in the project code
27+
28+
* It has support for dotenv files to configure the application variables through them
29+
30+
* [.env.example](/.env.example) (present on the repository and serve as model)
31+
32+
* [load](/webpack.config.js#L45-L85) the file following the search order
33+
34+
```
35+
1. .env.(production|development)
36+
2. .env.local
37+
3. .env
38+
4. .env.example
39+
```
40+
41+
## Folders
42+
43+
* main folders
44+
45+
```
46+
./
47+
docs/
48+
server/
49+
src/
50+
```
51+
52+
* `docs/` - documentation
53+
54+
* `server/` - socket.io server code
55+
56+
* `src/` - project code
57+
58+
* build folder
59+
60+
* when executes a command `yarn build` or `npm run build` the build content will be placed at the `./dist` folder
61+
62+
63+
## Code
64+
65+
* on the root `./`
66+
67+
* It uses the ES6+ through Webpack + Babel ([.babelrc](/.babelrc) file)
68+
69+
* It defines the web browsers support on the [.browserslistrc](/.browserslistrc) file, that is loaded and used by the Webpack to generate the production build
70+
71+
* on the `./src/`
72+
73+
* `index.html` - html template, where is define the injection point to be used by the `ReactDOM.render`
74+
75+
* `index.scss` - main scss (SASS) file
76+
77+
* `index.js` - loads the main scss file, the application component and inject it on the html
78+
79+
* each inner folder has it own `index.js` file that exposes its content as a module, to be imported like `import localStorageService from 'chat/services/localstorage';`
80+
81+
* sass styles
82+
83+
* global definitions `./src/styles/`
84+
85+
* main file `_all.scss` - has the imports of all `.scss` files on the folder
86+
87+
* all others scss files area placed with each module/component folder
88+
89+
* `./src/index.scss` imports `./src/styles/_all.scss` and `./src/chat/_styles.scss` files
90+
91+
* `./src/chat/_styles.scss` imports `./src/chat/(components/containers)/_styles.scss`
92+
93+
* and so one, where each `_style.scss` will import the `_styles.scss` from it's inner folders
94+
95+
* dumb/presentation components: `./src/chat/components/`
96+
97+
* only used to presentation, where most of them are stateless/functional components
98+
99+
* container components: `./src/chat/container`
100+
101+
* components that will receive data through injection, following the HOC ([Hight-Order Components](https://reactjs.org/docs/higher-order-components.html)): Redux > React Router > i18next (internationalization)
102+
103+
* services: `./src/chat/services`
104+
105+
* hash - used to generate a random id to the initial user name, following the pattern `Guest_{random}`
106+
107+
* i18n - internationalization config and resources
108+
109+
* is-mobile - check if the application was loaded over a device mobile/tablet
110+
111+
* localstorage - handle and manages the web browser localstorage to persist the application data/states
112+
113+
* socketclient - uses socket.io client to connect or uses a mock client that emulates the socket.io client expected behaviors
114+
115+
* states - redux re-ducks modules ([useful references](useful-references.md#code-style-guide) about it): `./src/chat/states`
116+
117+
* each redux module should expose its reducer by default
118+
119+
* those modules are imported on the `./src/chat/states/store.js`
120+
121+
* it manage 3 datasets/states of the application: connection, messages, settings (this last one has all of its inner reducers assigned at the redux root state)
122+
123+
## Dependencies
124+
125+
* defined on the [package.json](/package.json#L27-L74) file
126+
127+
**TODO:** list them and its links

docs/project/features.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Project features by versions
2+
3+
## 1.0.0
4+
5+
* Simple chat application which uses a socket.io server to handle and deliver its messages
6+
7+
* This project has it own socker.io server implementation, which is used on the local development environment and has a deployed version of it, learn more about it on the [server/README.md](../../server/README.md)
8+
9+
* Mobile first with responsible layout that adjusts on the mobile/table devices to the portrait or landspace orientation
10+
11+
* It has light or dark color themes
12+
13+
* It has internationalization with the available languages: English, Portuguese and Spanish
14+
15+
* The application detects which is the users language and apply it as the default settings
16+
17+
* It has a shortcut keyboard to submit the messages, where on the mobile/table devices is `ENTER` and on the desktop is `CTRL + ENTER`
18+
19+
* By default it is active, but the user can disable it on the settings page
20+
21+
* The application uses the localstorage to persist its data
22+
23+
* Messages
24+
25+
* Selected settings
26+
27+
* On the settings page has options to cleanup the cached messages or reset to default settings
28+
29+
* It has a socket.io server connection status, online or offline, displayed on the navigation bar at right
30+
31+
* It has an unread counter displayed over the chat tab when the user is on the settings page
32+
33+
## next
34+
35+
* Improve the documentation
36+
37+
* Review/improve services

0 commit comments

Comments
 (0)