Fix sizing of the heatmap and make goal configurable
This commit is contained in:
parent
f2dd382cf3
commit
ec91f6df42
@ -10,12 +10,16 @@ interface Props {
|
|||||||
startDate: Date;
|
startDate: Date;
|
||||||
endDate: Date;
|
endDate: Date;
|
||||||
data: DateValue[];
|
data: DateValue[];
|
||||||
|
className?: string;
|
||||||
|
goal: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
function GitHubCalendarHeatmap({
|
function GitHubCalendarHeatmap({
|
||||||
startDate,
|
startDate,
|
||||||
endDate,
|
endDate,
|
||||||
data,
|
data,
|
||||||
|
className,
|
||||||
|
goal
|
||||||
}: Props) {
|
}: Props) {
|
||||||
const numDays = dFns.differenceInDays(endDate, startDate);
|
const numDays = dFns.differenceInDays(endDate, startDate);
|
||||||
|
|
||||||
@ -30,7 +34,7 @@ function GitHubCalendarHeatmap({
|
|||||||
const totalHeight = 8 * (squareSize + padding) + weekTotalPadding; // Added an extra row for week total
|
const totalHeight = 8 * (squareSize + padding) + weekTotalPadding; // Added an extra row for week total
|
||||||
|
|
||||||
// Goal times for the daily and weekly squares
|
// Goal times for the daily and weekly squares
|
||||||
const dayGoalTime = 8;
|
const dayGoalTime = goal;
|
||||||
const weekGoalTime = 5 * dayGoalTime;
|
const weekGoalTime = 5 * dayGoalTime;
|
||||||
|
|
||||||
const getColorForValue = (value: number, goalTime: number): string => {
|
const getColorForValue = (value: number, goalTime: number): string => {
|
||||||
@ -74,7 +78,7 @@ function GitHubCalendarHeatmap({
|
|||||||
});
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<svg width={totalWidth} height={totalHeight}>
|
<svg width="100%" height="100%" viewBox={`0 0 ${totalWidth} ${totalHeight}`} className={className}>
|
||||||
{dateValues.map(({
|
{dateValues.map(({
|
||||||
date,
|
date,
|
||||||
count
|
count
|
||||||
|
|||||||
@ -56,7 +56,9 @@ export function CalendarOverviewCard({
|
|||||||
|
|
||||||
return <Card className="col-span-1">
|
return <Card className="col-span-1">
|
||||||
<Tooltip id="calendar-tooltip"/>
|
<Tooltip id="calendar-tooltip"/>
|
||||||
<Title>Overview</Title>
|
<Title>Semester Overview</Title>
|
||||||
<HeatMap startDate={initialDate} endDate={endDate} data={calendarData}/>
|
<div className="m-2">
|
||||||
|
<HeatMap startDate={initialDate} endDate={endDate} data={calendarData} goal={goal}/>
|
||||||
|
</div>
|
||||||
</Card>
|
</Card>
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user