From eb8bb82e584f0d0cb91ebc0e37e40c53da729ce8 Mon Sep 17 00:00:00 2001 From: wxiaoguang Date: Thu, 2 May 2024 21:22:55 +0800 Subject: [PATCH] Fix activity heat map padding & locale (#30823) Fix #30808 --------- Co-authored-by: silverwind --- package-lock.json | 26 +++++++++++------------ package.json | 2 +- web_src/js/components/ActivityHeatmap.vue | 12 ++++++----- web_src/js/features/heatmap.js | 17 +++++++++------ 4 files changed, 31 insertions(+), 26 deletions(-) diff --git a/package-lock.json b/package-lock.json index 917ff1029b..bba4ca5a9d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -14,6 +14,7 @@ "@github/text-expander-element": "2.6.1", "@mcaptcha/vanilla-glue": "0.1.0-alpha-3", "@primer/octicons": "19.9.0", + "@silverwind/vue3-calendar-heatmap": "2.0.6", "add-asset-webpack-plugin": "2.0.1", "ansi_up": "6.0.2", "asciinema-player": "3.7.1", @@ -57,7 +58,6 @@ "vue-bar-graph": "2.0.0", "vue-chartjs": "5.3.1", "vue-loader": "17.4.2", - "vue3-calendar-heatmap": "2.0.5", "webpack": "5.91.0", "webpack-cli": "5.1.4", "wrap-ansi": "9.0.0" @@ -1626,6 +1626,18 @@ "win32" ] }, + "node_modules/@silverwind/vue3-calendar-heatmap": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/@silverwind/vue3-calendar-heatmap/-/vue3-calendar-heatmap-2.0.6.tgz", + "integrity": "sha512-efX+nf2GR7EfA7iNgZDeM9Jue5ksglSXvN0C/ja0M1bTmkCpAxKlGJ3vki7wfTPQgX1O0nCfAM62IKqUUEM0cQ==", + "engines": { + "node": ">=16" + }, + "peerDependencies": { + "tippy.js": "^6.3.7", + "vue": "^3.2.29" + } + }, "node_modules/@sinclair/typebox": { "version": "0.27.8", "resolved": "https://registry.npmjs.org/@sinclair/typebox/-/typebox-0.27.8.tgz", @@ -12200,18 +12212,6 @@ } } }, - "node_modules/vue3-calendar-heatmap": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/vue3-calendar-heatmap/-/vue3-calendar-heatmap-2.0.5.tgz", - "integrity": "sha512-qvveNQlTS5Aw7AvRLs0zOyu3uP5iGJlXJAnkrkG2ElDdyQ8H1TJhQ8rL702CROjAg16ezIveUY10nCO7lqZ25w==", - "engines": { - "node": ">=16" - }, - "peerDependencies": { - "tippy.js": "^6.3.7", - "vue": "^3.2.29" - } - }, "node_modules/watchpack": { "version": "2.4.1", "resolved": "https://registry.npmjs.org/watchpack/-/watchpack-2.4.1.tgz", diff --git a/package.json b/package.json index 5f9b810320..107f0c96cf 100644 --- a/package.json +++ b/package.json @@ -13,6 +13,7 @@ "@github/text-expander-element": "2.6.1", "@mcaptcha/vanilla-glue": "0.1.0-alpha-3", "@primer/octicons": "19.9.0", + "@silverwind/vue3-calendar-heatmap": "2.0.6", "add-asset-webpack-plugin": "2.0.1", "ansi_up": "6.0.2", "asciinema-player": "3.7.1", @@ -56,7 +57,6 @@ "vue-bar-graph": "2.0.0", "vue-chartjs": "5.3.1", "vue-loader": "17.4.2", - "vue3-calendar-heatmap": "2.0.5", "webpack": "5.91.0", "webpack-cli": "5.1.4", "wrap-ansi": "9.0.0" diff --git a/web_src/js/components/ActivityHeatmap.vue b/web_src/js/components/ActivityHeatmap.vue index 9592a0df3c..71f41dda1a 100644 --- a/web_src/js/components/ActivityHeatmap.vue +++ b/web_src/js/components/ActivityHeatmap.vue @@ -1,5 +1,6 @@ diff --git a/web_src/js/features/heatmap.js b/web_src/js/features/heatmap.js index b6f06d0cfb..719eeb75fb 100644 --- a/web_src/js/features/heatmap.js +++ b/web_src/js/features/heatmap.js @@ -20,13 +20,16 @@ export function initHeatmap() { // last heatmap tooltip localization attempt https://github.com/go-gitea/gitea/pull/24131/commits/a83761cbbae3c2e3b4bced71e680f44432073ac8 const locale = { - months: new Array(12).fill().map((_, idx) => translateMonth(idx)), - days: new Array(7).fill().map((_, idx) => translateDay(idx)), - contributions: 'contributions', - contributions_in_the_last_12_months: el.getAttribute('data-locale-total-contributions'), - no_contributions: el.getAttribute('data-locale-no-contributions'), - more: el.getAttribute('data-locale-more'), - less: el.getAttribute('data-locale-less'), + heatMapLocale: { + months: new Array(12).fill().map((_, idx) => translateMonth(idx)), + days: new Array(7).fill().map((_, idx) => translateDay(idx)), + on: ' - ', // no correct locale support for it, because in many languages the sentence is not "something on someday" + more: el.getAttribute('data-locale-more'), + less: el.getAttribute('data-locale-less'), + }, + tooltipUnit: 'contributions', + textTotalContributions: el.getAttribute('data-locale-total-contributions'), + noDataText: el.getAttribute('data-locale-no-contributions'), }; const View = createApp(ActivityHeatmap, {values, locale});