Make first day of week settable through UI

This commit is contained in:
Henrik Giesel 2021-01-22 17:51:15 +01:00
parent aebaa04652
commit 806e52d6db
2 changed files with 10 additions and 11 deletions

View file

@ -51,8 +51,9 @@
targetYear, targetYear,
i18n, i18n,
nightMode, nightMode,
revlogRange revlogRange,
); calendarFirstDayOfWeek.set,
)
} }
const title = i18n.tr(i18n.TR.STATISTICS_CALENDAR_TITLE); const title = i18n.tr(i18n.TR.STATISTICS_CALENDAR_TITLE);

View file

@ -85,7 +85,8 @@ export function renderCalendar(
targetYear: number, targetYear: number,
i18n: I18n, i18n: I18n,
nightMode: boolean, nightMode: boolean,
revlogRange: RevlogRange revlogRange: RevlogRange,
setFirstDayOfWeek: (d: number) => void,
): void { ): void {
const svg = select(svgElem); const svg = select(svgElem);
const now = new Date(); const now = new Date();
@ -181,7 +182,10 @@ export function renderCalendar(
.attr("text-anchor", "end") .attr("text-anchor", "end")
.attr("font-size", "small") .attr("font-size", "small")
.attr("font-family", "monospace") .attr("font-family", "monospace")
.style("user-select", "none"); .style("user-select", "none")
.on("click", null)
.filter((d: number) => [Weekday.SUNDAY, Weekday.MONDAY, Weekday.FRIDAY, Weekday.SATURDAY].includes(d))
.on("click", setFirstDayOfWeek);
svg.select("g.days") svg.select("g.days")
.selectAll("rect") .selectAll("rect")
@ -199,11 +203,5 @@ export function renderCalendar(
.on("mouseout", hideTooltip) .on("mouseout", hideTooltip)
.transition() .transition()
.duration(800) .duration(800)
.attr("fill", (d) => { .attr("fill", (d) => d.count === 0 ? emptyColour : blues(d.count)!);
if (d.count === 0) {
return emptyColour;
} else {
return blues(d.count)!;
}
});
} }