Skip to content

Commit 2024db4

Browse files
committed
fixes for hover state on SessionTimer
1 parent 05a1228 commit 2024db4

File tree

2 files changed

+36
-61
lines changed

2 files changed

+36
-61
lines changed
Lines changed: 34 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,34 @@
1-
<!-- @vue-skuilder/common-ui/src/components/study/StudySessionTimer.vue -->
1+
<!-- @vue-skuilder/common-ui/src/components/StudySessionTimer.vue -->
22
<template>
3-
<v-tooltip
4-
v-model="showTooltip"
5-
location="right"
6-
:open-delay="0"
7-
:close-delay="200"
8-
color="secondary"
9-
class="text-subtitle-1"
10-
>
3+
<v-tooltip location="right" :open-delay="0" :close-delay="200" color="secondary" class="text-subtitle-1">
114
<template #activator="{ props }">
12-
<v-progress-circular
13-
alt="Time remaining in study session"
14-
size="64"
15-
width="8"
16-
rotate="0"
17-
:color="timerColor"
18-
:model-value="percentageRemaining"
19-
>
20-
<v-btn
21-
v-if="isActive"
22-
v-bind="props"
23-
icon
24-
color="grey-lighten-4"
25-
location="bottom left"
26-
@click="addSessionTime"
5+
<div class="timer-container" v-bind="props" @mouseenter="hovered = true" @mouseleave="hovered = false">
6+
<v-progress-circular
7+
alt="Time remaining in study session"
8+
size="64"
9+
width="8"
10+
rotate="0"
11+
:color="timerColor"
12+
:model-value="percentageRemaining"
2713
>
28-
<v-icon v-if="isActive" size="large">mdi-plus</v-icon>
29-
</v-btn>
30-
</v-progress-circular>
14+
<v-btn
15+
v-if="timeRemaining > 0 && hovered"
16+
icon
17+
color="transparent"
18+
location="bottom left"
19+
@click="addSessionTime"
20+
>
21+
<v-icon size="large">mdi-plus</v-icon>
22+
</v-btn>
23+
</v-progress-circular>
24+
</div>
3125
</template>
3226
{{ formattedTimeRemaining }}
3327
</v-tooltip>
3428
</template>
3529

3630
<script lang="ts">
37-
import { defineComponent, computed, toRefs } from 'vue';
31+
import { defineComponent, computed, ref } from 'vue';
3832
3933
export default defineComponent({
4034
name: 'StudySessionTimer',
@@ -55,35 +49,19 @@ export default defineComponent({
5549
required: true,
5650
default: 5,
5751
},
58-
/**
59-
* Whether the timer is currently active
60-
*/
61-
isActive: {
62-
type: Boolean,
63-
required: true,
64-
default: false,
65-
},
66-
/**
67-
* Whether the tooltip should be shown
68-
*/
69-
showTooltip: {
70-
type: Boolean,
71-
required: false,
72-
default: false,
73-
},
7452
},
7553
7654
emits: ['add-time'],
7755
7856
setup(props, { emit }) {
79-
const { timeRemaining, sessionTimeLimit, isActive } = toRefs(props);
57+
const hovered = ref(false);
8058
8159
/**
8260
* Formats the time remaining into a readable string
8361
*/
8462
const formattedTimeRemaining = computed(() => {
8563
let timeString = '';
86-
const seconds = timeRemaining.value;
64+
const seconds = props.timeRemaining;
8765
8866
if (seconds > 60) {
8967
timeString = Math.floor(seconds / 60).toString() + ':';
@@ -105,31 +83,27 @@ export default defineComponent({
10583
* Calculates the percentage of time remaining for the progress indicator
10684
*/
10785
const percentageRemaining = computed(() => {
108-
return timeRemaining.value > 60
109-
? 100 * (timeRemaining.value / (60 * sessionTimeLimit.value))
110-
: 100 * (timeRemaining.value / 60);
86+
return props.timeRemaining > 60
87+
? 100 * (props.timeRemaining / (60 * props.sessionTimeLimit))
88+
: 100 * (props.timeRemaining / 60);
11189
});
11290
11391
/**
11492
* Determines the color of the timer based on time remaining
11593
*/
11694
const timerColor = computed(() => {
117-
return timeRemaining.value > 60 ? 'primary' : 'orange darken-3';
95+
return props.timeRemaining > 60 ? 'primary' : 'orange darken-3';
11896
});
11997
12098
/**
12199
* Handles adding time to the session
122100
*/
123101
const addSessionTime = () => {
124-
console.log(`[timer] addSessionTime called`);
125-
if (isActive.value) {
126-
emit('add-time');
127-
} else {
128-
console.log(`[timer] addSessionTime called when session is not active`);
129-
}
102+
emit('add-time');
130103
};
131104
132105
return {
106+
hovered,
133107
formattedTimeRemaining,
134108
percentageRemaining,
135109
timerColor,
@@ -140,5 +114,8 @@ export default defineComponent({
140114
</script>
141115

142116
<style scoped>
143-
/* The component inherits styles from parent application */
117+
.timer-container {
118+
display: inline-flex;
119+
cursor: pointer;
120+
}
144121
</style>

packages/platform-ui/src/views/Study.vue

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,6 @@
7878
<StudySessionTimer
7979
:time-remaining="timeRemaining"
8080
:session-time-limit="sessionTimeLimit"
81-
:is-active="timerIsActive"
82-
:show-tooltip="false"
8381
@add-time="incrementSessionClock"
8482
/>
8583
</v-col>
@@ -231,7 +229,7 @@ export default defineComponent({
231229
sessionFinished: false,
232230
sessionRecord: [] as StudySessionRecord[],
233231
percentageRemaining: 100,
234-
timerIsActive: false,
232+
timerIsActive: true,
235233
loading: false,
236234
userCourseRegDoc: null as CourseRegistrationDoc | null,
237235
sessionContentSources: [] as StudyContentSource[],
@@ -441,7 +439,7 @@ export default defineComponent({
441439
async processResponse(this: StudyInstance, r: CardRecord) {
442440
this.$emit('emitResponse', r);
443441
444-
this.timerIsActive = false;
442+
this.timerIsActive = true;
445443
446444
r.cardID = this.cardID;
447445
r.courseID = this.courseID;

0 commit comments

Comments
 (0)