From 52b6b0eaee420892f20022e1d61e6734cc319f4c Mon Sep 17 00:00:00 2001 From: Joshua Coles Date: Sun, 24 Dec 2023 18:40:33 +0000 Subject: [PATCH] Bring some more things into the render fn --- src/heatmap/index.tsx | 48 +++++++++++++++++-------------------------- 1 file changed, 19 insertions(+), 29 deletions(-) diff --git a/src/heatmap/index.tsx b/src/heatmap/index.tsx index 4879eb5..62185f2 100644 --- a/src/heatmap/index.tsx +++ b/src/heatmap/index.tsx @@ -274,33 +274,6 @@ class CalendarHeatmap extends React.Component { ); } - renderAllWeeks() { - return getRange(this.getWeekCount()).map((weekIndex) => this.renderWeek(weekIndex)); - } - - renderMonthLabels() { - if (!this.props.showMonthLabels) { - return null; - } - - const adapter = (date) => { - const [x, y] = this.getMonthLabelCoordinates(dFns.differenceInWeeks(date, this.props.startDate)); - return { - x, - y - } - }; - - return <> - - {/*{...a}*/} - - } - renderWeekdayLabels() { if (!this.props.showWeekdayLabels) { return null; @@ -322,19 +295,36 @@ class CalendarHeatmap extends React.Component { render() { this.valueCache = this.getValueCache(this.props); + const monthPositionAdapter = (date) => { + const [x, y] = this.getMonthLabelCoordinates(dFns.differenceInWeeks(date, this.props.startDate)); + return { + x, + y + } + }; + + const weeks = dFns.eachWeekOfInterval({ + start: this.props.startDate, + end: this.props.endDate, + }); + return ( - {this.renderMonthLabels()} + {this.props.showMonthLabels && } - {this.renderAllWeeks()} + {weeks.map((_, index) => this.renderWeek(index))}