I created this live project to have a better experience while driving around the Niagara Region.
Other solutions do exist, but they are either paid or not super user friendly.
For this project I used Vite with React, as the hot reloading function makes visualizing changes and absolute breeze.
This app was developed and deployed in two parts, one of a server that retrieves the info from the canalstatus.com API and delivering it in a more mobile friendly interface.
Even though the basic functionality is all that is needed for every day use, I will continue to add to this, and potentially translate the code into native platforms in the future. The next step will be to turn this into a PWA.
- The app consists of two main parts, the server and the client.
- The server is responsible for retrieving the data from the canalstatus.com API and delivering a JSON response.
- The client is built with React and Vite and requests the data from the server.
- The client then renders the data in a mobile friendly interface.
- The app is built to be responsive and will adjust layout based on the device viewing the site.
- The app also includes a simple copyright notice.
- The server is located in the
serverdirectory. - It uses the Express framework and the
axioslibrary to make requests to the canalstatus.com API. - The server listens for GET requests to the
/apiendpoint and responds with the data retrieved from the API.
- The client is located in the
client/canal-statusdirectory. - It uses the React framework and the Vite build tool to create a mobile friendly interface.
- The client makes a GET request to the server's
/apiendpoint to retrieve the data. - The client then renders the data in a grid layout.
- The client also includes a simple loading state and error handling.
- The client is built with React components.
- The components are located in the
client/canal-status/src/componentsdirectory. - The components include a
Cardcomponent that renders the data in a grid layout. - The components also include a
Copyrightcomponent that includes a simple copyright notice.
- The data retrieved from the API is an array of objects.
- Each object represents a bridge and has several properties including
bridge,city,status, andstl. - The
stlproperty represents the state of the bridge and has a value of0,1, or2. - The
stlproperty is used to determine the style of theCardcomponent based on the state of the bridge.
- The styles are located in the
client/canal-status/src/App.cssfile. - The styles include a grid layout for the
Cardcomponents. - The styles also include different background colors for the
Cardcomponents based on the state of the bridge.
- The
Bridgescomponent has a complexity of 12 based on the following factors:- 2 props being passed in
- 1 state being used
- 2 conditional statements
- 1 function call
- 1 if statement
- 1 return statement
- 13 lines of code
- The
Bridgescomponent is a pure component based on the following factors:- The component does not modify any external state or have any side effects
- The component does not depend on any external state or props other than those passed in
- The component does not have any lifecycle methods
- The
Bridgescomponent is well tested with a coverage of 91.2%.
The Bridges component retrieves data from the API and renders a Card component for each bridge.
- The
Bridgescomponent makes a GET request to the API when the component mounts. - The
Bridgescomponent sets the state toloadingwhile the data is being retrieved. - If the data is successfully retrieved, the state is set to
dataand the data is rendered inCardcomponents. - If there is an error retrieving the data, the state is set to
errorand an error message is rendered. - The
Cardcomponent is passed the data for each bridge and renders the data in a grid layout. - The
Cardcomponent is also passed a prop that determines the style of the component based on the state of the bridge.