-
Notifications
You must be signed in to change notification settings - Fork 28
Expand file tree
/
Copy pathlegend.js
More file actions
60 lines (59 loc) · 1.66 KB
/
Copy pathlegend.js
File metadata and controls
60 lines (59 loc) · 1.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import _ from 'lodash';
import { removePackage } from '../../packages/packages.js';
import {
isSameMonth,
format as formatDate,
addDays,
isSameYear,
} from 'date-fns';
import withRender from './legend.html';
export default withRender({
props: {
modules: Array,
date: Date,
interval: Number,
},
computed: {
sortedModules() {
return _.orderBy(this.modules, module => module.entries, ['desc']);
},
},
template: require('./legend.html'),
methods: {
removePackage(packageName) {
ga('send', 'event', 'legend', 'remove', packageName);
removePackage(packageName);
this.$emit('legend-blur');
},
handleMouseEnterLegend() {
this.$emit('legend-focus');
},
handleMouseLeaveLegend() {
this.$emit('legend-blur');
},
handleMouseEnterPackage(packageName) {
this.$emit('package-focus', packageName);
},
handleMouseLeavePackage(packageName) {
this.$emit('package-blur', packageName);
},
formatInterval(startOfPeriod) {
const endOfPeriod = addDays(startOfPeriod, this.interval - 1);
if (isSameMonth(startOfPeriod, endOfPeriod)) {
return `${formatDate(startOfPeriod, 'MMMM Do')} - ${formatDate(
endOfPeriod,
'Do',
)}, ${formatDate(startOfPeriod, 'YYYY')}`;
} else if (isSameYear(startOfPeriod, endOfPeriod)) {
return `${formatDate(startOfPeriod, 'MMMM Do')} - ${formatDate(
endOfPeriod,
'MMMM Do',
)}, ${formatDate(startOfPeriod, 'YYYY')}`;
}
return `${formatDate(startOfPeriod, 'MMMM Do, YYYY')} - ${formatDate(
endOfPeriod,
'MMMM Do, YYYY',
)}`;
},
},
});