- Links
- Project Overview
- File Structure
- Configuration
- Pages
- Components
- Styling
- Getting Started
- Development
- Building
- Contributing
- License
The PROVIDE Climate Risk Dashboard is a web application that allows users to explore future impacts of climate change as the world warms. It provides visualizations and data on various climate scenarios, impacts, and adaptation strategies.
Current development version 2.3 (on Provide Netlify): https://phase-2-3--hilarious-treacle-096169.netlify.app/explore/impacts
Previous development version 2.0 (on Provide Netliy): https://phase-2--hilarious-treacle-096169.netlify.app/
Previous production version (on Provide Netlify): https://chimerical-baklava-ad903f.netlify.app
The whole application for this website consists of these parts:
- The front facing website, which build with SvelteKit and Tailwind CSS and hosted in this repository.
- The backend API providing the data, which is build in Python and hosted by Climate Analytics.
- The content of the text pages, the description of scenarios and sectors and the stories are stored in Strapi.
- A script for screenshotting the graphs is also running on a separate server.
Most text content is stored in Strapi. The content is fetched via the Strapi API (loadFromStrapi) and displayed on the website. The content is stored in the following collections:
- Case Studies
- FAQ
- Glossary
- Indicators
- Scenarios
- Sceanario Presets
- Stories
- Videos
- About page
- Adaptation page
- Case Study Outro
- Contact page
- Disclaimer
- Issue list
- Methodology
- Technical documentation
The content is either fetched as meta data (loadMetaData) or as full content (loadFromStrapi).
The scenario data is fetched from the Climate Analytics API (loadFromAPI). The documentation of the different endpoints can be found in the following issues:
- API endpoints
- /impact-time
- /impact-geo
- /geo-shape
- /unavoidable-risk
- /meta
- /avoiding-impacts
- /avoiding-reference
The most important files and folders are:
project-root/
│
├── src/
│ ├── routes/
│ │ ├── (default)/ # The main pages of the website
│ │ │ ├── about/
│ │ │ ├── adaptation/
│ │ │ ├── contact/
│ │ │ ├── impacts/
│ │ │ ├── keyconcepts/
│ │ │ ├── landing-page/
│ │ │ └── methodology/
│ │ └── +page.svelte # The landing page
│ │ └── +layout.server.js # Meta data is loaded here so that it is available on all pages
│ │ ├── (embed)/ # This is used for screenshots. This layout leaves out the header and footer and only displays the graph.
│ ├── lib/
│ │ ├── charts/ # All the components that are used for the charts
│ │ ├── MapboxMap/ # Components for the map
│ │ ├── helper/ # Smaller components that are used multiple times somewhere on the site
│ │ ├── controls/ # Smaller components like select, radio buttons, and checkboxes
│ │ ├── site/ # Components like the header, footer, and the sidebar
│ │ └── utils/ # Smaller dunctions that are used multiple times
│ │ └── workers/ # The masking of the maps is happening in a Web Worker
│ │ └── api/ # Functions that are used to fetch data from the API and Strapi
│ ├── stores/
│ │ ├── meta.js # States for the meta data
│ │ └── state.js # States like the selected scenario, indicator, and region
│ ├── styles/ # Design tokens coming from Figma and other styling
│ ├── config.js # Global configuration settings
├── static/ # Static files like the favicon, fonts, preview image and PDFs.
├── tailwind.config.cjs # Style configuration
├── package.json # Libraries used in this repositoryThe page is build in JavaScript/TypeScript with Svelte 4 using SvelteKit. The underlying engine is Bun. It uses Tailwind CSS for styling. The page is hosted on Netlify while in development and on Climate Analytics in production. Maps are created using Mapbox and Charts are craeted using D3 and Layercake for the charts.
The main configuration files include:
src/config.js: Contains global configuration settings..env: Stores environment variables (not included in the repository). The documentation for the environment variables can be found in the Environment variables issuetailwind.config.cjs: Configures Tailwind CSS. Note that we also use design tokens imported from Figma. Code for this is located indesign-tokensandsrc/styles.svelte.config.js: Svelte-specific configuration.
Some configurations are:
- Aliases for easier imports (defined in
svelte.config.js). - Adapter configuration for Netlify or static builds (defined in
svelte.config.js) - Prerendering configuration for specific routes.
- Custom Tailwind CSS extensions for colors, fonts, and other utilities (defined in
tailwind.config.cjs)
The main pages of the application include:
- Home (
/): Landing page with an overview of the dashboard. - Explore (
/impacts/explore): Allows users to explore future climate impacts, by first selecting a scenario and then exploring matching impacts. - Avoid (
/impacts/avoid): Focuses on avoiding future climate impacts, by first selecting an impact level and then exploring matching scenarios - Adaptation (
/adaptation): Provides information on climate adaptation strategies, by giving three case studies from Nassau, Lisbon and Islamabad. - Methodology (
/methodology): Details the methodology and models used on the page. The models for each data type are explained in detail. - Key Concepts (
/keyconcepts): Explains important terms and concepts used in the dashboard. - About (
/about): Provides information about the project and its contributors. - Contact (
/contact): Contains contact information and a form for user feedback.
The project uses Tailwind CSS for styling, with custom configurations:
- Custom color tokens are imported from Figma using a build script in the
design-tokensfolder. See further down for details. - The main styling file is
src/styles/app.postcss. - A
ThemeProvidercomponent manages theme-related styling. - Custom Tailwind plugins and extensions are defined in
tailwind.config.cjs.
Color values however come directly from Figma. This happens via the Export/Import Variables plugin. For the moment only the color-tokens collection is exportet. It has to be stored in /design-tokens/00_input/color-tokens.json. To transform the tokens into a useable format run pnpm run build inside the design-tokens folder. This will create a new file /src/styles/color-tokens-light.json. This file is then used by tailwind.config.cjs as well as ThemeProvider.svelte to provide the correct color values across the application.
The most important state management is done in src/stores/state.js. The store is used to determine the available geographies, indicators, scenarios and other parameters based on the user’s input.
To run this project locally:
-
Clone the repository
-
Install dependencies:
bun install -
Set up environment variables:
- Create a
.envfile with the required variables (see issue #298 for details)
- Create a
-
Run the development server:
bun run dev -
Open http://localhost:5173/ in your browser.
-
To build the project for production:
bun run build
- Files containing svelte components have a camel case name starting with an uppercase letter
- Other files have a kebap case name
- Folders that contain one primary svelte component are named after this component e.g.
LineChart/LineChart.svelte. Other components and files can be in the same folder but they are normally not used directly from the outside but are only used by the primary component. - Folders containing multiple components or other files get a kebap case name e.g.
explore-impacts/. - These naming rules don't apply to the
routesfolder.