Skip to content

Commit 90489b9

Browse files
committed
Adding Tippy in TimeSince component
1 parent 95fd4a4 commit 90489b9

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/Frontend/src/components/TimeSince.vue

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,25 @@
11
<script setup lang="ts">
22
import { onMounted, onUnmounted, ref } from "vue";
33
import moment from "moment";
4+
import { Tippy } from "vue-tippy";
45
56
const emptyDate = "0001-01-01T00:00:00";
67
78
const props = withDefaults(defineProps<{ dateUtc?: string; defaultTextOnFailure?: string; titleValue?: string }>(), { dateUtc: emptyDate, defaultTextOnFailure: "n/a", titleValue: undefined });
89
910
let interval: number | undefined = undefined;
1011
11-
const title = ref(),
12+
const title = ref<string[]>([]),
1213
text = ref();
1314
1415
function updateText() {
1516
if (props.dateUtc != null && props.dateUtc !== emptyDate) {
1617
const m = moment.utc(props.dateUtc);
1718
text.value = m.fromNow();
18-
title.value = props.titleValue ?? m.local().format("LLLL") + " (local)\n" + m.utc().format("LLLL") + " (UTC)";
19+
title.value = props.titleValue ? [props.titleValue] : [`${m.local().format("LLLL")} (local)`, `${m.utc().format("LLLL")} (UTC)`];
1920
} else {
2021
text.value = props.defaultTextOnFailure;
21-
title.value = props.titleValue ?? props.defaultTextOnFailure;
22+
title.value = [props.titleValue ?? props.defaultTextOnFailure];
2223
}
2324
}
2425
@@ -34,5 +35,10 @@ onUnmounted(() => window.clearInterval(interval));
3435
</script>
3536

3637
<template>
37-
<span :title="title">{{ text }}</span>
38+
<Tippy>
39+
<template #content>
40+
<div v-for="row in title" :key="row">{{ row }}</div>
41+
</template>
42+
<span>{{ text }}</span>
43+
</Tippy>
3844
</template>

0 commit comments

Comments
 (0)