diff --git a/src/components/HeatMap.tsx b/src/components/HeatMap.tsx
index 271a03c..c9aa32b 100644
--- a/src/components/HeatMap.tsx
+++ b/src/components/HeatMap.tsx
@@ -1,5 +1,6 @@
import React from "react";
import * as dFns from "date-fns";
+import * as R from 'ramda';
interface DateValue {
date: Date;
@@ -12,6 +13,7 @@ interface Props {
data: DateValue[];
className?: string;
goal: number;
+ penaliseOvertime?: boolean;
}
function GitHubCalendarHeatmap({
@@ -19,7 +21,8 @@ function GitHubCalendarHeatmap({
endDate,
data,
className,
- goal
+ goal,
+ penaliseOvertime = false,
}: Props) {
const numDays = dFns.differenceInDays(endDate, startDate);
@@ -38,22 +41,47 @@ function GitHubCalendarHeatmap({
const weekGoalTime = 5 * dayGoalTime;
const getColorForValue = (value: number, goalTime: number): string => {
- const values = [
- "#eeeeee",
- "#d6e685",
- "#8cc665",
- "#44a340",
- "#1e6823",
- ]
+ const buckets = [
+ {
+ min: -Infinity,
+ max: 0,
+ color: '#eeeeee'
+ },
+ {
+ min: 0,
+ max: 0.40,
+ color: '#d6e685'
+ },
+ {
+ min: 0.40,
+ max: 0.50,
+ color: '#8cc665'
+ },
+ {
+ min: 0.50,
+ max: 0.90,
+ color: '#44a340'
+ },
+ {
+ min: 0.90,
+ // If penalising overtime, the max is 1.125, otherwise it's infinity (ie this is the last bucket)
+ max: penaliseOvertime ? 1.125 : Infinity,
+ color: '#1e6823'
+ },
+ {
+ min: 1.125,
+ max: 1.25,
+ color: '#f59e0b'
+ },
+ {
+ min: 1.25,
+ max: Infinity,
+ color: '#ef4444'
+ },
+ ];
- const linearValue = Math.round((value / goalTime) * 4);
-
- // If we did something, but not enough to reach the first level, return 1
- if (linearValue == 0 && value > 0) return values[1];
-
- // Clamp to the granularity
- if (linearValue > 4) return values[4];
- return values[linearValue];
+ const linearValue = value / goalTime;
+ return R.find(minMax => minMax.min < linearValue && linearValue <= minMax.max, buckets)!.color;
};
const getWeekTotal = (weekIndex: number): number => {
diff --git a/src/components/OverviewPage.tsx b/src/components/OverviewPage.tsx
index 2b9f45e..873d8a9 100644
--- a/src/components/OverviewPage.tsx
+++ b/src/components/OverviewPage.tsx
@@ -47,6 +47,7 @@ export default function OverviewPage({