nemac / climate-explorer

Climate Explorer map application
9 stars 11 forks source link

Climate Explorer

Built to accompany the U.S. Climate Resilience Toolkit, the Climate Explorer offers graphs and maps of observed and projected temperature, precipitation, and related climate variables for every county in the contiguous United States.

The live version of this project can be found at crt-climate-explorer.nemac.org

Coding Conventions

Climate Explorer is a large web application and was (mostly) developed before modern web frameworks existed, which is to say much of its codebase uses outdated patterns and different areas of the project may use different naming conventions.

Here are a few rules to make the future of the application a little brighter:

  1. Use let/const appropriately, not var.
  2. Name variables and functions with snake_case.
  3. Name JS classes with TitleCase.
  4. Name CSS classes with kebab-case.
  5. Explicitly set global variables using window.my_var = my_var.
  6. No hidden links, buttons, or form control elements.
  7. Clean up derelict code immediately. Do not comment things out for later, just remove them, you can always look up the history in git later. Make sure to look for related HTML/JS/CSS that may also be removed.
  8. Use a spellchecker in addition to a linter, clean code is easier to maintain.
  9. Do not modify files in /vendor/ or /node_modules/.
  10. Use the full file path in module imports import get from '../node_modules/lodash/get.js not import get from 'lodash/get'.

Development environment

To set up your development environment use npm install then run npm run build to build and npm run start to start the development server. Changes to html or js may require you to re-run npm run build. Alternatively, run npm run start:dev to symlink /dist/js/ to /js/ so you don't have to re-build for js file changes.

Additional tools and what they do

Deployment notes

This project is intended for deployment as a static site, but there are a handful of services aside from the code in this repo that are expected:

As of 2021, many data JSON files have been moved out of the Climate Explorer source repo to be hosted at https://crt-climate-explorer.nemac.org/data/

State variables

This project has a number of url-persisted state variables that are passed from page to page when applicable. Primarily these variables are managed by /js/main.js as a form of global state management, but it depends on each page to give it variables and not all pages use this convention.

Changelog

3.1.0

3.0

Complete user interface revamp for improved responsiveness and added limited mobile device compatibility.