Link to website: https://rilmxp-global-warming.netlify.app/
An environmental information website created with React that renders charts about global warming's key factors by fetching data from different APIs. It promotes awareness about human impact on nature following the UN's Climate Action goal.
HTTP requests for charts are made to Global Warming and Climate Change API at https://global-warming.org/api
To run the app on local sever:
- Clone repository
- Install dependencies:
npm install
- Launch local server:
npm run dev
The website consists of seven different routes to components that represent "pages".
All data displayed inside the charts is fetched directly from the APIs.
All data displayed outside the charts is retrieved from a local file at src/data/contentData.js
Each factor page consists of a chart and a list of causes, effects, and improvements to be made("What you can do"), regarding that particular factor.
-
Home: A banner displaying a carousel of famous quotations regarding commitment to change, importance of education and climate change. An introductory summary of the current status of factors that have a deep impact on the environment.
-
Temperature: chart displaying celsius anomalies through the years.
-
Carbon dioxide: chart displaying carbon dioxide levels.
-
Methane: chart displaying methane levels.
-
Nitrous oxide: chart displaying nitrous oxide levels.
-
Polar ice: chart displaying ice land extent in million square kilometers.
-
Error Page: to be displayed whenever the user inserts invalid route information directly on the url.
- Brand/Logo link to Home.
- Links to all global warming factors.
- Horizonal inline display of links on wide screens. Vertical canvas on click of toggle button on narrow screens.
On page load, it retrieves data from local file at src/data/contentData.js to feed the Factors section.
-
Banner
- Main heading containing a responsive image and a carousel of quotations.
- Main heading containing a responsive image and a carousel of quotations.
-
Factors section
- Each factor consists of a summary of its current status and a button that links to its dedicated page.
- To be rendered through animation only when the element enters the viewport.
-
Chart
-
On page load, data will be fetched from its corresponding factor API and a chart will be rendered.
-
On data chart loading, a loader animation will be shown.
-
In cases of huge amount of data, the same has been reduced in favor of a nicer/cleaner display. As an example, temperature data has been reduced to 1 value every ten years from 1880 until 1980, and annually from 1981 to present.
-
Linear, Area and Bar charts have been used to represent the data recieved.
-
On hover, a tooltip will be displayed to provide an easier reading of data.
-
In case of Error, a feedback message will be displayed.
-
-
Facts Section
- They consist of a list of "Causes", "Effects", and "What you can do" guidelines.
- Data is dinamically retrieved from local file at src/data/contentData.js.
Whenever the user manually inserts invalid data on the url, they will be redirected to the error page which consists of a background picture (the same used for the banner), and a button to go back to home.
-
Application created with ViteJs.
-
State management.
- No global state context setup was necessary for this app.
- Charts state is managed internally by Recharts library.
- Animations state is managed internally by framer motion library.
- Asynchronous state is managed by React Query.
- Bootstrap's Navbar state has been manually modified to close canvas after clicking on links.
-
Components. They can be found inside the
features
folder with the exception of page components which are located in their dedicated folder namedpages
. -
Folders and file structure.
-
Note on
public/images
folder. Given the fact that images are dinamically imported withinFactor.jsx
, they have been placed inside thepublic
folder instead ofsrc
. All other files and folders have been created insidesrc
folder -
features
folder has been divided into different categories to reduce clutter. Each folder has anindex.js
which imports and exports in only one place all the components from that specific feature. As an example, chart components for each factor will be found in thecharts
folder and, navbar and footer in thelayout
folder. -
features/configuration
folder contains different animation setups for page transitions.RoutesTransitionAnimation
contains allRoute
components. It configures them withuseLocation
so Framer Motion can animate their transition. -
data
folder containscontentData.js
file with static data to feedFactorsContainer.jsx
andFactsContainer.jsx
andTextCarousel.jsx
(quotations). -
styles
folder contains minimum common configuration sass files as most styles have been set using css modules. -
api
folder contains axios base configuration for async calls ongraphDataApiConfig.js
and functions to handle API responses for each chart ongraphDataResponseHandlers.js
.
-
- Used for creation of charts.
- Used for HTTP requests. Its base configuration can be found in
graphDataApiConfig.js
inside theapi
folder
- Used for asynchronous state management of HTTP requests.
- Used for fade-in of page transitions and charts, scale-in of factors, spring-in of facts, and elements' display on entereing the viewport.
-
A few sass partials have been created.
_config.scss
for basic global styles._custom-bootstrap-main.scss
and_custom-bootstrap-maps.scss
to modify some bootstrap defaults. And_exports.module.scss
which is needed in chart components for <defs> and tooltip inline styles as per Recharts specifications since classes will simply not work. -
Apart from that, most of the styles have been defined in Css modules adjacent to each corresponding component.
-
React-Icons. Github, briefcase, lightbulb, thermometer and magnifying glass icons.
-
Nanoid. To create ids for react lists internal indexing.
-
React-router-dom. To route to different page-like components.
-
React Bootstrap. Used for navigation bar.
The responsive nature of each component has been set directly on their own css module. Depending on the component, breakpoints have been set at min-width: 700px, 900px, 1400px.
-
Responsive images:
- Banner: achieved by changing the url value from
background-image
property. - Factors: achieved by setting
srcSet
attribute on the <img> tag.
- Banner: achieved by changing the url value from
-
Responsive elements:
- Chart page: width and height of
GraphContainer
andFactsContainer
. - Homepage: width of
FactorsContainer
and layout of its elements from vertical to horizontal.
- Chart page: width and height of