Skip to content

Commit eb412ac

Browse files
committed
Show stats exlude today
1 parent 0738ac1 commit eb412ac

File tree

3 files changed

+129
-7
lines changed

3 files changed

+129
-7
lines changed

src/assets/css/main.css

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,3 +203,28 @@ body {
203203
.tabs ul li label img {
204204
height: 1.2em;
205205
}
206+
.tooltip {
207+
position: relative;
208+
display: inline-block;
209+
vertical-align: middle;
210+
}
211+
.tooltip .tooltiptext {
212+
font-size: 11px;
213+
font-weight: 500;
214+
visibility: hidden;
215+
width: 180px;
216+
background-color: #555;
217+
color: #fff;
218+
text-align: center;
219+
padding: 10px 10px;
220+
border-radius: 6px;
221+
position: absolute;
222+
z-index: 1;
223+
transform: translate(-55%) translateY(-125%);
224+
opacity: 0;
225+
transition: opacity 0.3s;
226+
}
227+
.tooltip:hover .tooltiptext {
228+
visibility: visible;
229+
opacity: 1;
230+
}

src/assets/icons/no-today.svg

Lines changed: 1 addition & 1 deletion
Loading

src/components/OverallStatistics.vue

Lines changed: 103 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,62 @@
3030
</div>
3131
<div class="row">
3232
<div class="block">
33-
<div class="header">The most active day</div>
34-
<p>{{ data.mostActiveDay.date.toLocaleDateString() }}</p>
35-
<p>{{ convertSummaryTimeToString(data.mostActiveDay.summaryTime) }}</p>
33+
<div class="header">
34+
The most active day
35+
<div class="tooltip">
36+
<img
37+
v-if="isIncludedCurrentForActiveDays"
38+
src="../assets/icons/today.svg"
39+
height="20"
40+
class="most-day"
41+
@click="excludeTodayFromMostActive()"
42+
/>
43+
<img
44+
v-if="!isIncludedCurrentForActiveDays"
45+
src="../assets/icons/no-today.svg"
46+
height="20"
47+
class="most-day"
48+
@click="excludeTodayFromMostActive()"
49+
/>
50+
<span class="tooltiptext">{{
51+
isIncludedCurrentForActiveDays
52+
? 'Today is included in the statistics. Click if you want to exclude today.'
53+
: 'Today is excluded from the statistics. Click if you want to include today.'
54+
}}</span>
55+
</div>
56+
</div>
57+
<p>{{ mostActiveDay }}</p>
58+
<p>{{ mostActiveDayTime }}</p>
3659
</div>
3760
<div class="block">
38-
<div class="header">The most inactive day</div>
39-
<p>{{ data.mostInactiveDay.date.toLocaleDateString() }}</p>
40-
<p>{{ convertSummaryTimeToString(data.mostInactiveDay.summaryTime) }}</p>
61+
<div class="header">
62+
The most inactive day
63+
<div class="tooltip">
64+
<img
65+
v-if="isIncludedCurrentForInActiveDays"
66+
src="../assets/icons/today.svg"
67+
height="20"
68+
class="most-day"
69+
@click="excludeTodayFromMostInActive()"
70+
/>
71+
<img
72+
v-if="!isIncludedCurrentForInActiveDays"
73+
src="../assets/icons/no-today.svg"
74+
height="20"
75+
class="most-day"
76+
@click="excludeTodayFromMostInActive()"
77+
/>
78+
<span class="tooltiptext">{{
79+
isIncludedCurrentForInActiveDays
80+
? 'Today is included in the statistics. Click if you want to exclude today.'
81+
: 'Today is excluded from the statistics. Click if you want to include today.'
82+
}}</span>
83+
</div>
84+
</div>
85+
<p>{{ mostInActiveDay }}</p>
86+
<p>
87+
{{ mostInActiveDayTime }}
88+
</p>
4189
</div>
4290
</div>
4391
</div>
@@ -50,12 +98,57 @@ export default {
5098
</script>
5199

52100
<script lang="ts" setup>
101+
import { computed, onMounted, ref } from 'vue';
53102
import { OverallStats } from '../dto/tabListSummary';
54103
import { convertSummaryTimeToString } from '../utils/converter';
55104
56105
const props = defineProps<{
57106
data: OverallStats;
58107
}>();
108+
109+
onMounted(() => {
110+
isIncludedCurrentForActiveDays.value = true;
111+
isIncludedCurrentForInActiveDays.value = true;
112+
});
113+
114+
const isIncludedCurrentForActiveDays = ref<boolean>();
115+
const isIncludedCurrentForInActiveDays = ref<boolean>();
116+
117+
const mostActiveDay = computed(() =>
118+
isIncludedCurrentForActiveDays.value
119+
? props.data.mostActiveDay.date.toLocaleDateString()
120+
: props.data.mostActiveDayExceptToday?.date.toLocaleDateString(),
121+
);
122+
123+
const mostActiveDayTime = computed(() =>
124+
isIncludedCurrentForActiveDays.value
125+
? convertSummaryTimeToString(props.data.mostActiveDay.summaryTime)
126+
: props.data.mostActiveDayExceptToday != null
127+
? convertSummaryTimeToString(props.data.mostActiveDayExceptToday.summaryTime)
128+
: '-',
129+
);
130+
131+
const mostInActiveDay = computed(() =>
132+
isIncludedCurrentForInActiveDays.value
133+
? props.data.mostInactiveDay.date.toLocaleDateString()
134+
: props.data.mostInactiveDayExceptToday?.date.toLocaleDateString(),
135+
);
136+
137+
const mostInActiveDayTime = computed(() =>
138+
isIncludedCurrentForInActiveDays.value
139+
? convertSummaryTimeToString(props.data.mostInactiveDay.summaryTime)
140+
: props.data.mostInactiveDayExceptToday != null
141+
? convertSummaryTimeToString(props.data.mostInactiveDayExceptToday.summaryTime)
142+
: '-',
143+
);
144+
145+
function excludeTodayFromMostActive() {
146+
isIncludedCurrentForActiveDays.value = !isIncludedCurrentForActiveDays.value;
147+
}
148+
149+
function excludeTodayFromMostInActive() {
150+
isIncludedCurrentForInActiveDays.value = !isIncludedCurrentForInActiveDays.value;
151+
}
59152
</script>
60153

61154
<style scoped>
@@ -89,4 +182,8 @@ const props = defineProps<{
89182
font-size: 13px;
90183
color: rgb(59, 59, 59);
91184
}
185+
.most-day {
186+
cursor: pointer;
187+
margin-left: 5px;
188+
}
92189
</style>

0 commit comments

Comments
 (0)