2020-04-06 07:01:11 +05:30
|
|
|
<script>
|
2022-10-01 19:56:38 +05:30
|
|
|
import {CalendarHeatmap} from 'vue3-calendar-heatmap';
|
2020-04-06 07:01:11 +05:30
|
|
|
|
|
|
|
export default {
|
2020-11-07 20:41:09 +05:30
|
|
|
components: {CalendarHeatmap},
|
2020-11-19 03:30:16 +05:30
|
|
|
props: {
|
|
|
|
values: {
|
|
|
|
type: Array,
|
|
|
|
default: () => [],
|
|
|
|
},
|
2022-10-28 19:18:24 +05:30
|
|
|
locale: {
|
|
|
|
type: Object,
|
|
|
|
default: () => {},
|
|
|
|
}
|
2020-11-19 03:30:16 +05:30
|
|
|
},
|
2020-11-07 20:41:09 +05:30
|
|
|
data: () => ({
|
2020-11-08 02:34:40 +05:30
|
|
|
colorRange: [
|
2023-05-17 16:25:34 +05:30
|
|
|
'var(--color-secondary-alpha-60)',
|
|
|
|
'var(--color-secondary-alpha-60)',
|
2020-11-14 01:19:46 +05:30
|
|
|
'var(--color-primary-light-4)',
|
|
|
|
'var(--color-primary-light-2)',
|
2020-11-08 02:34:40 +05:30
|
|
|
'var(--color-primary)',
|
2020-11-14 01:19:46 +05:30
|
|
|
'var(--color-primary-dark-2)',
|
|
|
|
'var(--color-primary-dark-4)',
|
2020-11-08 02:34:40 +05:30
|
|
|
],
|
|
|
|
endDate: new Date(),
|
2020-11-07 20:41:09 +05:30
|
|
|
}),
|
2022-12-20 02:44:49 +05:30
|
|
|
mounted() {
|
|
|
|
// work around issue with first legend color being rendered twice and legend cut off
|
|
|
|
const legend = document.querySelector('.vch__external-legend-wrapper');
|
|
|
|
legend.setAttribute('viewBox', '12 0 80 10');
|
|
|
|
legend.style.marginRight = '-12px';
|
|
|
|
},
|
2021-02-21 03:38:58 +05:30
|
|
|
methods: {
|
|
|
|
handleDayClick(e) {
|
|
|
|
// Reset filter if same date is clicked
|
|
|
|
const params = new URLSearchParams(document.location.search);
|
|
|
|
const queryDate = params.get('date');
|
|
|
|
// Timezone has to be stripped because toISOString() converts to UTC
|
|
|
|
const clickedDate = new Date(e.date - (e.date.getTimezoneOffset() * 60000)).toISOString().substring(0, 10);
|
|
|
|
|
|
|
|
if (queryDate && queryDate === clickedDate) {
|
|
|
|
params.delete('date');
|
|
|
|
} else {
|
|
|
|
params.set('date', clickedDate);
|
|
|
|
}
|
|
|
|
|
2023-02-25 02:45:10 +05:30
|
|
|
params.delete('page');
|
|
|
|
|
2021-02-21 03:38:58 +05:30
|
|
|
const newSearch = params.toString();
|
|
|
|
window.location.search = newSearch.length ? `?${newSearch}` : '';
|
|
|
|
}
|
|
|
|
},
|
2020-11-07 20:41:09 +05:30
|
|
|
};
|
2020-04-06 07:01:11 +05:30
|
|
|
</script>
|
2023-09-02 20:29:07 +05:30
|
|
|
<template>
|
|
|
|
<div class="total-contributions">
|
|
|
|
{{ locale.contributions_in_the_last_12_months }}
|
|
|
|
</div>
|
|
|
|
<calendar-heatmap
|
|
|
|
:locale="locale"
|
2024-03-20 12:01:23 +05:30
|
|
|
:no-data-text="locale.no_contributions"
|
|
|
|
:tooltip-unit="locale.contributions"
|
2023-09-02 20:29:07 +05:30
|
|
|
:end-date="endDate"
|
|
|
|
:values="values"
|
|
|
|
:range-color="colorRange"
|
|
|
|
@day-click="handleDayClick($event)"
|
|
|
|
/>
|
|
|
|
</template>
|