11<template >
22 <div id =" user-heatmap" >
3- <div class =" total-contributions" >
4- {{ sum }} contributions in the last 12 months
5- </div >
3+ <!-- eslint-disable-next-line vue/no-v-html (safely generated in the backend) -->
4+ <div class =" total-contributions" v-html =" locale.contributions_in_the_last_12_months_html" />
65 <calendar-heatmap
76 :locale =" locale"
87 :no-data-text =" locale.no_contributions"
9- :tooltip-unit = " locale.contributions "
8+ :tooltip-formatter = " (v) => tooltipFormatter(v, locale) "
109 :end-date =" endDate"
1110 :values =" values"
1211 :range-color =" colorRange"
@@ -41,15 +40,6 @@ export default {
4140 ],
4241 endDate: new Date (),
4342 }),
44- computed: {
45- sum () {
46- let s = 0 ;
47- for (let i = 0 ; i < this .values .length ; i++ ) {
48- s += this .values [i].count ;
49- }
50- return s;
51- }
52- },
5343 mounted () {
5444 // work around issue with first legend color being rendered twice and legend cut off
5545 const legend = document .querySelector (' .vch__external-legend-wrapper' );
@@ -74,6 +64,16 @@ export default {
7464
7565 const newSearch = params .toString ();
7666 window .location .search = newSearch .length ? ` ?${ newSearch} ` : ' ' ;
67+ },
68+ tooltipFormatter (v , locale ) {
69+ // TODO: use the localized number as below (why is it throwing Uncaught DOMException: Failed to execute
70+ // 'attachShadow' on 'Element': Shadow root cannot be created on a host which already hosts a shadow tree.?)
71+ // const number = `<gitea-locale-number data-number="${v.count}">${v.count}</gitea-locale-number>`;
72+ const number = v .count ;
73+ const datetime = v .date .toISOString ();
74+ const fallback = v .date .toLocaleDateString ();
75+ const date = ` <relative-time format="datetime" year="numeric" month="short" day="numeric" weekday="" datetime="${ datetime} ">${ fallback} </relative-time>` ;
76+ return locale .contributions_on .replace (' %[1]s' , number).replace (' %[2]s' , date);
7777 }
7878 },
7979};
0 commit comments