Giter VIP home page Giter VIP logo

act-now-packages's Introduction

act-now-packages

NPM Packages for Act Now Coalition

This is a multi-package repository to host NPM packages for the Act Now Coalition.

Setup

Make sure you have Node.js installed. We recommend using nvm to quickly install and use different versions of node via the command line. In this project, we use Node 16 (the latest LTS version).

nvm install v16
nvm use v16

Workflow

Publishing

Once the code is merged to develop, we can publish the package by merging the changeset-release/develop branch to develop. To publish your package

  1. Go to the changeset-release/develop branch. This should be titled "Version Packages" and should be automatically generated when we ship updates with changesets attached to their PRs. If there is no changeset-release/develop branch, then no changeset has been detected since the last package release.
  2. Once step one is complete, the updated package should be published on NPM. Check our Github Actions page or NPM to see if it published successfully.
  3. In most cases, it is good practice to also update Act Now Template to use the newly updated package. More information here.

Installing the package

If you want to use the package on a different project, you can install it as you would normally do with any other package. For example, to install the package on a different repository, just go to that project and run:

yarn add @actnowcoalition/actnow.js

If you need a specific version, you can install

yarn add @actnowcoalition/[email protected]

Updating a package

If you change the code on a package, you will need to update its version number and re-publish the package. We use semantic versioning to determine what the new version number should be.

Links

act-now-packages's People

Contributors

pnavarrc avatar mikelehen avatar chasulin avatar github-actions[bot] avatar faihegberg avatar smcclure17 avatar dependabot[bot] avatar

Stargazers

Ruxandra Fediuc avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

ruxandrafed

act-now-packages's Issues

Implement MetricSparklines

It should take two metrics, one for the bar chart (raw data series) and one for the line chart (normally a rolling average). We should also pass a number of days (or a date range) to filter the timeseries by, that way we can make multiple series consistent with each other.

// width: 100% height: 100%, 
<MetricSparklines
  region={region}
  metricLineChart={metricCasesRollingAvg}
  metricBarChart={metricCases}
  numDays={30}
/>

Image

BarChart component

Implement the BarChart component, following the model of LineChart and similar props (yScale, xScale). Note that the chart below also includes a line chart, ignore that for the time being.

Figma

Image

Implement GridLines

Implement components GridRows and GridColumns based of @visx/grid, but adapting the style to match our theme variables.

Image

Figma

MetricDot

Implement the metric dot component. See ActNow Design System and Figma - Monkeypox for examples in context

Image

Recommendations for components:

  • If the component needs a metric, we can make it receive a Metric | string to make it more flexible. All metric-aware components have access to the metricCatalog and can call metricCatalog.getMetric(metricId)
  • Prefer using MUI Stack, Grid or Box when possible to minimize the amount of custom code/css to write, review and debug.
  • Avoid importing the theme, use the theme from the context instead (either using styled or useTheme)
  • Provide good default that match the ActNow Design System

Implement chart Axes

Implement AxisLeft and AxisBottom, using the API from @visx/axis, but adapting lines and typography to use our theme variables for colors. Don't try to make the date format match the mocks yet - we probably need to think more about that (when to abbreviate month names, when to put the year, what to do on mobile, etc.)

Figma

Image

ProgressBar (multiple values)

We need to implement a multi-level ProgressBar component to represent related values such as vaccination percent for multiple doses. I would recommend to keep the interface similar to ProgressBar, but receiving a list of items with accessor methods.

<MultiProgressBar
  items={items}
  getItemColor={(item:T, itemIndex:number) => string}
  getItemLabel={(item:T, itemIndex:number) => string}
  getItemValue={(item:T, itemIndex:number) => number}
  {/* ... */}
/>

Image

Act Now Design System (Figma)

Write CanDataProvider

I'm not sure what kind of data provider we’d want in order to fetch data from the CAN API.

Ideally it’d be able to fetch data for one region at a time (rather than all states/counties/etc. at once) which I think means using the JSON endpoints. Though maybe it could just use the timeseries CSV endpoints?

I’m not sure if there’s a generic JsonDataProvider we could create that would be flexible enough to work with the CAN API, so it might make sense to just write a bespoke CanDataProvider to start and then see if there’s anything we can generalize from that.

This isn't exactly urgent, but I think would be a useful exercise and will let us use CAN data in our hackathons.

Markdown bug

Description in progress

When we try to use the Markdown component using the template (or hackathon) repository, Next.js throws an error (ESM). It looks like this error is caused by Next not handling ESM-only packages correctly (react-markdown is ESM-only).

We need to find a workaround to be able to implement and use the Markdown component.

Notes

Write RollingAverageDataProvider

This is a bit broader than just implementing RollingAverageDataProvider. I think we need to come up with a mechanism to define metric data providers that depend on other metrics (or regions).

In my original metrics refactor I had prototyped a "DerivedDataProvider" that would basically let you write a data provider that depends on other metrics. A simple example is a RollingAverageDataProvider that provides a rolling average metric from a "raw" metric... The definitions are here: https://github.com/covid-projections/who-demo/blob/82eddb59ba6237cce39ac0c3ce9a007f2ca3c582/src/metrics/data_providers.ts#L32

I think we want something similar, but I'm not sure exactly what it should look like. Maybe we should just amend the MetricDataProvider.fetchData() function so that it receives the MetricCatalog as an additional argument. That way it can fetch data for other metrics in the catalog if it wants / needs to. I'm not sure. Happy to brainstorm more on this.

Implement Options component

Implement the metric dot component. See ActNow Design System and Figma - Monkeypox for examples in context

Image

Recommendations for components:

  • If the component needs a metric, we can make it receive a Metric | string to make it more flexible. All metric-aware components have access to the metricCatalog and can call metricCatalog.getMetric(metricId)
  • Prefer using MUI Stack, Grid or Box when possible to minimize the amount of custom code/css to write, review and debug.
  • Avoid importing the theme, use the theme from the context instead (either using styled or useTheme)
  • Provide good default that match the ActNow Design System

Implement MetricLegendThreshold component

Implement the metric legend component. See Figma - MetricLegend

Image

Recommendations for components:

  • If the component needs a metric, we can make it receive a Metric | string to make it more flexible. All metric-aware components have access to the metricCatalog and can call metricCatalog.getMetric(metricId)
  • Prefer using MUI Stack, Grid or Box when possible to minimize the amount of custom code/css to write, review and debug.
  • Avoid importing the theme, use the theme from the context instead (either using styled or useTheme)
  • Provide good default that match the ActNow Design System

Implement Tab component

I would recommend to implement a non-metric aware version first with the styles of the tab (width, border-bottom, styles for the active tab, etc) and then implement the metric-aware version, probably by customizing the MuiTab component in the src/styles/theme/components.ts and creating a story file under src/stories (similar to ToggleButton, Button, etc)

Image

Implement MetricOverview component

We need to implement the MetricOverview component. It's probably worth discussing with the group what the best API for the component is as well as some behaviours:

Open Questions

  • Should it take Metric, MetricData or both?
  • Should it load the timeseries async to load the current values faster?
  • Does it make sense to load the metric def. statically (metric name, description) and current value and timelines async?
  • Thoughts on naming for metric-aware components (let's say, for the metric-aware version of LegendThreshold?)

Example from the Monkeypox mocks:

Image

Mobile

Image

Desktop

Image

Design System - Figma

Implement SocialMetaTags component

Let's use a placeholder for now. The social copy, title, etc will ultimately be written in the CMS, but we can implement the component and add it to the template pages

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.