Giter VIP home page Giter VIP logo

het-frontend's Introduction

het-frontend

The frontend codebase for Health Equity Tracker has moved to health-equity-tracker

Developer Instructions

Code in the app/ directory was bootstrapped with Create React App. In that directory you can run various npm scripts, which are described below.

You can learn more in the Create React App documentation.

To learn React, check out the React documentation.

Note: The following instructions assume running all commands from the app/ directory.

Install

Change directories to the app/ directory, then install dependencies using NPM.

Note: you will need a compatible verison of Node.JS and NPM installed locally. See the "engines" field in app/package.json for the required / minimum versions of each. It's recommended to use Node Version Manager (nvm) if you need to have multiple versions of Node.JS / NPM installed on your machine.

cd app && npm install

Trouble-shooting

If you encounter errors during install that mention gyp, that refers to a Node.js native addon build tool that is required for some modules. Follow the instructions on the gyp github repo for installation and setting up required dependencies (eg Python and certain build tools like XCode Command Line Tools for OS X).

Develop

To run the app in development mode, start a local web server, and watch for changes do:

npm start

The site should now be visible at localhost:3000. Any changes to source code will cause a live reload of the site.

Tests

To run unit tests do:

npm test

This will run tests in watch mode, so you may have the tests running while developing.

Build

To create a "production" build do:

npm run build

This should output bundled files in the app/build/ directory. Use these files for hosting the web app.

Ejecting Create React App

Note: this is a one-way operation. Once you eject, you can’t go back!

If you aren’t satisfied with the Create React App build tool and configuration choices, you can eject at any time. This command will remove the single build dependency from your project.

Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except eject will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.

You don’t have to ever use eject. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.

License

MIT

het-frontend's People

Contributors

ebonyrespress avatar kkatzen avatar

Watchers

 avatar  avatar

het-frontend's Issues

Move WithVariables from Reports to CardWrapper

Each Card will get data from datastore in isolation based on provided variables instead of having the data passed in. Will also need to refactor WithVariables to take in a load screen element probably

Set up CSS to consistently style components

This sort of depends on whether we continue using the material-ui library. For now I just used the material-ui CssBaseline component which gives some reasonable defaults. If we continue using the library we'll probably want to customize the theme. If not we'll need to do more of our own styling across various components.

Also, Chris initially suggested setting font-size to 62.5% so we can use rems for font-size elsewhere and 1rem == 10px, etc. I reset this to 100% because it was overriding the font-size in the material-ui library. Going to postpone this decision until we know whether we're even going to stick with that library (#10). After that we can look more into whether we can do the 62.5% strategy and not break the material-ui library, or if we want to drop that piece.

Isolate key inside components

Create wrapper around Cards that require special key specifications so that the report level caller doesn't have to specify them

Decide on Charting / Data Viz solution(s)

For creating or embedding any charts, maps, etc. Some options could be:

  • A charting framework such as Vega/VegaLite, Chart.JS
  • Using D3JS for charts
  • Using a React / D3 abstraction layer
  • Using an interactive geographic map library such as MapBox GL JS
  • Using external software that allows for embedding / iframe'ing charts and maps such as Tableau, Data Wrapper, etc.

Refactor files into sub-folders

Recommendation (based on Chris's suggestion):

src/
  -> features/
      -> dataset_explorer/ (may want to rename this to dataset_catalog or something since I think the term "data explorer" is being used in other contexts)
  -> data_processing/ (IMO it would be good to have this for anything that gets/processes data, separate from components)
      -> DataFetcher.ts
  -> utils/

Figure out what UI component library to use or whether to build our own

This depends on UX deciding on a design system. Looks like UX is leaning towards material.

Some popular options for libraries include:

I'm sure there are many more but these are both widely used/supported/documented.

Alternatively we could create our own component library, which would allow much more granular control and customizability, but at the cost of extra time to develop and maintain it. Chris suggested that if we do this, use https://storybook.js.org/ to manage/document the library.

My instinct is to use an existing design system and use a popular library that implements it to save ourselves the additional work. Note that if we do use an existing component library we should make sure it supports the customizations we need.

Sticky MadLib Carousel

Is it possible to have the MadLib Carousel stick to the top when you scroll past it so you can always see the MadLib text

Attach frontend to real domain

Right now it's getting deployed to some generated netlify domain. We want to move it to healthequitytracker.org or possibly app.healthequitytracker.org

Align dropdown options

All dropdowns should be a button with text underline (with offset of 3px) and also the same font size
All popups open underneath the madlib (like the geo one does)

Bug: doesn't jump back to top

For instance, on landing page, scroll down and click a link to the explore data page, notice that the page doesn't start off at the top again

Card data sources text

Update card footer text per mock to spell out names of data sources and last update times

Generalize variable configuration

We should generalize how variables are configured so we can reuse logic across charts/madlibs/variables. Here's a very rough draft of how we might structure configuration:

VariableConfig: {
  variableId
  fullName
  shortName
  variableType
  description?
}

VariableType: count | pct_share | pct_share_to_pop_ratio | per100k | percentile | index

MadlibVariable: {
  Variable: {
    Metric: VariableConfig
    ...
  }
}

// Example:
covid: { // MadlibVariable
  cases: { // Variable
    count: { // Metric
      id: “covid_cases”,
      fullName: “Covid19 cases”,
      shortName: “cases”,
      variableType: “count”
    },
    pct_share: {
      id: “covid_pct_share”,
      fullName: “Share of COVID-19 cases”,
      shortName: “...”,
      variableType: “pct_share”
    }
  },
  deaths: {
    ...
  }

The goal should be that we can write generalized code in the UI that doesn't need to know about the specifics of what variables we're using, and allows us to add more variables without making significant UI code changes.

Finalize web server hosting decision and document tradeoffs

Right now we're using a netlify setup, which has a lot of conveniences like automatic previews from github, but is much less flexible. For features that require more server support like an admin login, we'd need to switch to a Node.js or Flask server (or other, but those are the two natural choices so we don't have to fragment our codebase into three languages).

With a Node.js or Flask server, you don't get as much out of the box like with Netlify, but they have other flexibility benefits like being able to implement features that require server-side support and hosting in GCP (which means it can be managed the same as other resources, we can control backend API access, etc).

Some other considerations with Netlify:

  • Requires a paid account for more than one login. This would very likely be a requirement for the main website as we'd want developers to be able to access it
  • The marketing/informational website is on Netlify. It may be convenient to have both of them there. Is this website going to stick around long-term or be turned into a landing page for the main website?
  • Does netlify scale with production apps?

We should definitely sort this out but I'd recommend punting the decision until we've built more of the frontend and data server.

404 page

Add 404 page for unknown routing

Heat Map multi tiered dropdown

Heat map only lets you filter by race- ideally we would have a multi tiered filter
Age -> [age options as supported by the dataset]
Gender -> [gender options as supported by the dataset]
Race -> [race options as supported by the dataset]

Migrate frontend code to main health-equity-tracker repo

Ideally we should migrate the frontend to the health-equity-tracker repo. Our codebase isn't large enough for a monorepo to be an issue, and long-term this will simplify deploy deploy processes and open source contributions. This also allows us to unify github actions, terraform config, etc under one repo. We still plan on prod releases being separate, but dev releases can happen automatically after any merge to master.

That being said, we should be careful not to cause development strain while doing this. We need to make sure presubmits for the frontend aren't interfering with the backend and vice versa. If there are issues, we can keep the repo as is but will need to revisit our cloud run deployment flow.

Set up repo with framework & build system

Use Create React App with:

According to the docs, I think the above should be achievable by doing:

npx create-react-app my-app --template typescript 
yarn add node-sass react-app-polyfill

Up for discussion:

  • One caveat will be that the above command will install everything to my-app and not this repo het-frontend. We may need to cp -r from the CRA output dir to this repo as I'm not sure if we can use an existing dir with the npx create-react-app cmd.
  • We should pin a NodeJS version, probably whatever the latest LTS version is, via the package.json engine field or a .nvmrc file if using Node Version Manager.
  • We should decide on whether or not to use npm or yarn as a package manager. CRA uses yarn by default but by passing the --use-npm flag when running the above cmd we can default to npm.
  • Code formatting: are we okay with using Prettier to automatically format our files? (this can be set up to happen on a git commit hook)
  • add an .editorconfig file to help normalize various IDEs & code editors? Prettier may take care of this as well?

Unit testing setup

Make sure our unit tests are set up properly and run on presubmit and submit

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.