CNN Interactive Election Map Clone

This is a clone of the CNN Interactive Election Map. It is built with React, TypeScript, and Vite.

Media

https://www.loom.com/share/c7937ebc80c04a76a6f52c326dc37cc2?sid=75ac5a71-381d-4570-bafe-a46b7c96eef5

Notes

  • This project was built in a sprint in 2 days. Theres some lint issues due to TS and probably there's a better way to build this app 😅

Tech Stack

  • React
  • TypeScript
  • Vite
  • TailwindCSS
  • MapboxGL
  • React-Map-GL
  • Shadcn/ui
  • Zustand for state management (due to time constraints, Zustand is faster to setup than Redux)

Features

  • MapboxGL
  • Interactive Map
  • Reset Map
  • Responsive

Getting Started

  1. Clone the repo
  2. Add a .env file with the following variables (you can get a Mapbox token from here):
REACT_APP_MAPBOX_TOKEN=
  1. Install dependencies
  2. Run the app

React + TypeScript + Vite

This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.

Currently, two official plugins are available:

Expanding the ESLint configuration

If you are developing a production application, we recommend updating the configuration to enable type aware lint rules:

  • Configure the top-level parserOptions property like this:
export default {
  // other rules...
  parserOptions: {
    ecmaVersion: "latest",
    sourceType: "module",
    project: ["./tsconfig.json", "./tsconfig.node.json"],
    tsconfigRootDir: __dirname,
  },
};
  • Replace plugin:@typescript-eslint/recommended to plugin:@typescript-eslint/recommended-type-checked or plugin:@typescript-eslint/strict-type-checked
  • Optionally add plugin:@typescript-eslint/stylistic-type-checked
  • Install eslint-plugin-react and add plugin:react/recommended & plugin:react/jsx-runtime to the extends list