50 | );
51 | }
52 | }
53 |
54 | Clicker.defaultProps = {
55 | count: 0
56 | };
57 |
58 | Clicker.propTypes = {
59 | count: PropTypes.number
60 | };
61 |
62 | export default Clicker;
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # React Clicker
2 |
3 | A basic React app that allows one to increase, decrease, or reset a counter.
4 |
5 | Go **[here](http://react-clicker.drminnaar.me/)** for live demo.
6 |
7 | This project also demonstrates:
8 |
9 | * a typcial React project layout structure
10 | * babel setup and configuration
11 | * webpack setup and configuration
12 | * eslint setup and configuration
13 | * SCSS setup and configuration
14 | * How to run application in a Docker container
15 |
16 | ... | ...
17 | --- | ---
18 |  | 
19 |
20 | ---
21 |
22 | ## Developed With
23 |
24 | * [Node.js](https://nodejs.org/en/) - Javascript runtime
25 | * [React](https://reactjs.org/) - A javascript library for building user interfaces
26 | * [Babel](https://babeljs.io/) - A transpiler for javascript
27 | * [Webpack](https://webpack.js.org/) - A module bundler
28 | * [SCSS](http://sass-lang.com/) - A css metalanguage
29 | * [Bootstrap 4](https://getbootstrap.com/) - Bootstrap is an open source toolkit for developing with HTML, CSS, and JS
30 | * [Surge] - Static web publishing for Front-End Developers
31 | * [Docker] - A container management system
32 |
33 | ---
34 |
35 | ## Related Projects
36 |
37 | * [react-starter]
38 |
39 | A basic template that consists of the essential elements that are required to start building a React application
40 |
41 | * [react-clock-basic]
42 |
43 | A basic clock that displays the current date and time
44 |
45 | * [react-timer-basic]
46 |
47 | A basic timer that will start a countdown based on an input of time in seconds
48 |
49 | * [react-timer-advanced]
50 |
51 | A basic countdown timer that offers an advanced UI experience
52 |
53 | * [react-masterminds]
54 |
55 | A basic game of guessing a number with varying degrees of difficulty
56 |
57 | * [react-movie-cards]
58 |
59 | A basic application that displays a list of movies as a list of cards
60 |
61 | * [react-calculator-standard]
62 |
63 | A calculator that provides the essential arithmetic operations, an expression builder, and a complete history of all expressions
64 |
65 | * [react-bitcoin-monitor]
66 |
67 | An app that monitors changes in the Bitcoin Price Index (BPI)
68 |
69 | * [react-weather-standard]
70 |
71 | A weather application that displays the current weather, daily forecasts, and hourly forecasts based on your current geolocation
72 |
73 | ---
74 |
75 | ## Getting Started
76 |
77 | These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.
78 |
79 | ### Prerequisites
80 |
81 | The following software is required to be installed on your system:
82 |
83 | * Node 8.x
84 | * Npm 3.x
85 |
86 | Type the following commands in the terminal to verify your node and npm versions
87 |
88 | ```bash
89 | node -v
90 | npm -v
91 | ```
92 |
93 | ### Install
94 |
95 | Follow the following steps to get development environment running.
96 |
97 | * Clone _'react-clicker'_ repository from GitHub
98 |
99 | ```bash
100 | git clone https://github.com/drminnaar/react-clicker.git
101 | ```
102 |
103 | _OR USING SSH_
104 |
105 | ```bash
106 | git clone git@github.com:drminnaar/react-clicker.git
107 | ```
108 |
109 | * Install node modules
110 |
111 | ```bash
112 | cd react-clicker
113 | npm install
114 | ```
115 |
116 | ### Build
117 |
118 | * Build application
119 |
120 | This command will also run ESLint as part of build process.
121 |
122 | ```bash
123 | npm run build
124 | ```
125 |
126 | * Build application and start watching for changes
127 |
128 | This command will also run ESLint as part of build process.
129 |
130 | ```bash
131 | npm run build:watch
132 | ```
133 |
134 | ### Run ESlint
135 |
136 | * Lint project using ESLint
137 |
138 | ```bash
139 | npm run lint
140 | ```
141 |
142 | * Lint project using ESLint, and autofix
143 |
144 | ```bash
145 | npm run lint:fix
146 | ```
147 |
148 | ### Run
149 |
150 | * Run start
151 |
152 | This will run the _'serve'_ npm task
153 |
154 | ```bash
155 | npm start
156 | ```
157 |
158 | * Run webpack dev server
159 |
160 | ```bash
161 | npm run serve:dev
162 | ```
163 |
164 | * Alternatively run live-server (simple development http server with live reload capability)
165 |
166 | ```bash
167 | npm run serve
168 | ```
169 |
170 | ### Docker Instructions
171 |
172 | An alternative to installing and running application on your local machine is to build and run your own Docker container that will host the application. There are 2 files related to Docker setup namely:
173 |
174 | * Dockerfile - Used to create Docker Image
175 |
176 | * .dockerignore - Used to ignore files in local path that are not required in the container
177 |
178 | To get the application up and running in a Docker container, please follow the following instructions:
179 |
180 | 1. Build Docker Image
181 |
182 | The following command will build a new Docker Image called _'react-clicker'_ with the tag _'1.0.0'_ using the Docker file found in the application root.
183 |
184 | ```docker
185 | docker build -t react-clicker:1.0.0 .
186 | ```
187 |
188 | 1. Run Docker Container
189 |
190 | The following command will start a new container based on the Docker image created above. The application within the container runs on port 8080, therefore, as part of command we map container port to local host port. We also give the container a name and run it in the background. The '--rm' switch indicates that the container will be automatically removed once it is stopped.
191 |
192 | ```docker
193 | docker run --rm --name react-clicker -p 8080:8080 -d react-clicker:1.0.0
194 | ```
195 |
196 | 1. Open application
197 |
198 | By typing the following command, you should see a runing container having the name _'react-clciker'_.
199 |
200 | ```docker
201 | docker container ls
202 | ```
203 |
204 | If the container is running, you may navigate to the application using your browser at the following address:
205 |
206 | ```bash
207 | http://localhost:8080
208 | ```
209 |
210 | Lastly, if you're curious to have a look inside container, then you may type the following command:
211 |
212 | ```docker
213 | docker exec -it react-clicker /bin/sh
214 | ```
215 |
216 | The above command provides you an interactive shell on the container. Please note that the above command must be executed on a running container.
217 |
218 | ---
219 |
220 | ## Versioning
221 |
222 | I use [SemVer](http://semver.org/) for versioning. For the versions available, see the [tags on this repository](https://github.com/drminnaar/react-clicker/tags).
223 |
224 | ## Authors
225 |
226 | * **Douglas Minnaar** - *Initial work* - [drminnaar](https://github.com/drminnaar)
227 |
228 | [Surge]: https://surge.sh/
229 | [Docker]: https://www.docker.com/
230 | [react-starter]: https://github.com/drminnaar/react-starter
231 | [react-clicker]: https://github.com/drminnaar/react-clicker
232 | [react-clock-basic]: https://github.com/drminnaar/react-clock-basic
233 | [react-timer-basic]: https://github.com/drminnaar/react-timer-basic
234 | [react-timer-advanced]: https://github.com/drminnaar/react-timer-advanced
235 | [react-masterminds]: https://github.com/drminnaar/react-masterminds
236 | [react-movie-cards]: https://github.com/drminnaar/react-movie-cards
237 | [react-calculator-standard]: https://github.com/drminnaar/react-calculator-standard
238 | [react-bitcoin-monitor]: https://github.com/drminnaar/react-bitcoin-monitor
239 | [react-weather-standard]: https://github.com/drminnaar/react-weather-standard
--------------------------------------------------------------------------------