fix: use innerText as tooltip text instead of bindings

-
this fixes the updates problem
-
This commit is contained in:
geoffrey45
2022-09-21 01:32:28 +03:00
parent fa8be2cde4
commit e03ed66f44
9 changed files with 70 additions and 46 deletions
+9 -3
View File
@@ -25,29 +25,35 @@
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
// @libraries
import { onMounted } from "vue"; import { onMounted } from "vue";
import { useRouter } from "vue-router"; import { useRouter } from "vue-router";
import { onStartTyping } from "@vueuse/core"; import { onStartTyping } from "@vueuse/core";
import { vElementSize } from "@vueuse/components"; import { vElementSize } from "@vueuse/components";
// @stores
import useQStore from "@/stores/queue"; import useQStore from "@/stores/queue";
import useModalStore from "@/stores/modal"; import useModalStore from "@/stores/modal";
import useContextStore from "@/stores/context"; import useContextStore from "@/stores/context";
import useSettingsStore from "@/stores/settings"; import useSettingsStore from "@/stores/settings";
import { content_width } from "@/stores/content-width";
// @utils
import { xl, xxl } from "./composables/useBreakpoints"; import { xl, xxl } from "./composables/useBreakpoints";
import handleShortcuts from "@/composables/useKeyboard"; import handleShortcuts from "@/composables/useKeyboard";
import { readLocalStorage, writeLocalStorage } from "@/utils"; import { readLocalStorage, writeLocalStorage } from "@/utils";
// @small-components
import Modal from "@/components/modal.vue"; import Modal from "@/components/modal.vue";
import NavBar from "@/components/nav/NavBar.vue";
import ContextMenu from "@/components/contextMenu.vue"; import ContextMenu from "@/components/contextMenu.vue";
import Notification from "@/components/Notification.vue"; import Notification from "@/components/Notification.vue";
// @app-grid-components
import NavBar from "@/components/nav/NavBar.vue";
import LeftSidebar from "./components/LeftSidebar/index.vue";
import RightSideBar from "@/components/RightSideBar/Main.vue"; import RightSideBar from "@/components/RightSideBar/Main.vue";
import SearchInput from "@/components/RightSideBar/SearchInput.vue"; import SearchInput from "@/components/RightSideBar/SearchInput.vue";
import NowPlayingRight from "@/components/RightSideBar/NowPlayingRight.vue"; import NowPlayingRight from "@/components/RightSideBar/NowPlayingRight.vue";
import LeftSidebar from "./components/LeftSidebar/index.vue";
import { content_width } from "@/stores/content-width";
const queue = useQStore(); const queue = useQStore();
const router = useRouter(); const router = useRouter();
+1 -1
View File
@@ -25,7 +25,7 @@
<span v-else-if="album.is_single">Single</span> <span v-else-if="album.is_single">Single</span>
<span v-else>Album</span> <span v-else>Album</span>
</div> </div>
<div class="title ellip" v-tooltip="album.title"> <div class="title ellip" v-tooltip>
{{ album.title }} {{ album.title }}
</div> </div>
</div> </div>
+1 -1
View File
@@ -25,7 +25,7 @@
</div> </div>
<div class="bottom"> <div class="bottom">
<div class="title ellip t-center" v-tooltip="track?.title"> <div class="title ellip t-center" v-tooltip>
{{ track?.title || " Hello " }} {{ track?.title || " Hello " }}
</div> </div>
<ArtistName <ArtistName
+1 -1
View File
@@ -8,7 +8,7 @@
> >
<img class="rounded" :src="imguri + album.image" alt="" /> <img class="rounded" :src="imguri + album.image" alt="" />
<div> <div>
<h4 class="title ellip" v-tooltip="album.title">{{ album.title }}</h4> <h4 class="title ellip" v-tooltip>{{ album.title }}</h4>
<div class="artist ellip">{{ album.artist }}</div> <div class="artist ellip">{{ album.artist }}</div>
</div> </div>
</router-link> </router-link>
+1 -8
View File
@@ -1,5 +1,5 @@
<template> <template>
<div v-tooltip="returnArtists()" style="width: auto"> <div v-tooltip style="width: auto">
<div class="ellip" v-if="artists === null || artists.length === 0"> <div class="ellip" v-if="artists === null || artists.length === 0">
<span>{{ albumartist }}</span> <span>{{ albumartist }}</span>
</div> </div>
@@ -18,11 +18,4 @@ const props = defineProps<{
artists: string[] | null; artists: string[] | null;
albumartist: string | undefined; albumartist: string | undefined;
}>(); }>();
function returnArtists() {
if (props.artists === null || props.artists.length === 0)
return props.albumartist;
return props.artists.join(", ");
}
</script> </script>
+2 -2
View File
@@ -25,7 +25,7 @@
:class="{ last_played: !isPlaying }" :class="{ last_played: !isPlaying }"
></div> ></div>
</div> </div>
<div v-tooltip="track.title" class="song-title"> <div v-tooltip class="song-title">
<div class="title ellip" @click="emitUpdate(track)" ref="artisttitle"> <div class="title ellip" @click="emitUpdate(track)" ref="artisttitle">
{{ track.title }} {{ track.title }}
</div> </div>
@@ -42,7 +42,7 @@
</div> </div>
<router-link <router-link
class="song-album ellip" class="song-album ellip"
v-tooltip="track.album" v-tooltip
:to="{ :to="{
name: 'AlbumView', name: 'AlbumView',
params: { params: {
+1 -1
View File
@@ -23,7 +23,7 @@
></div> ></div>
</div> </div>
<div class="tags"> <div class="tags">
<div class="title ellip" v-tooltip="track.title"> <div class="title ellip" v-tooltip>
{{ track.title }} {{ track.title }}
</div> </div>
<hr /> <hr />
+50 -26
View File
@@ -1,10 +1,45 @@
import { Directive } from "vue"; import { Directive } from "vue";
import { createPopper } from "@popperjs/core"; import { createPopper, Instance, VirtualElement } from "@popperjs/core";
let tooltip: HTMLElement; let tooltip: HTMLElement;
let popperInstance: Instance;
let store: any;
function getTooltip() { // @ts-ignore
return document.getElementById("tooltip") as HTMLElement; const virtualEl = {
getBoundingClientRect: () => null,
} as VirtualElement;
const getTooltip = () => document.getElementById("tooltip") as HTMLElement;
function getInstance() {
if (tooltip && virtualEl) {
return createPopper(virtualEl, getTooltip(), {
placement: "top",
modifiers: [
{
name: "offset",
options: {
offset: [0, 10],
},
},
{
name: "hide",
enabled: true,
},
{
name: "eventListeners",
enabled: false,
},
],
});
}
return null;
}
function showTooltip() {
tooltip.style.visibility = "visible";
} }
function hideTooltip() { function hideTooltip() {
@@ -12,37 +47,26 @@ function hideTooltip() {
} }
export default { export default {
mounted(el, binding) { mounted(el: HTMLElement, binding) {
let isHovered = false; if (!tooltip) {
if (tooltip === undefined) {
tooltip = getTooltip(); tooltip = getTooltip();
} }
if (!popperInstance) {
popperInstance = getInstance() as Instance;
}
let isHovered = false;
el.addEventListener("mouseover", () => { el.addEventListener("mouseover", () => {
isHovered = true; isHovered = true;
setTimeout(() => { setTimeout(() => {
if (isHovered) { if (!isHovered) return;
tooltip.innerText = binding.value; tooltip.innerText = el.innerText;
tooltip.style.visibility = "visible";
createPopper(el, tooltip, { virtualEl.getBoundingClientRect = () => el.getBoundingClientRect();
placement: "top", popperInstance.update().then(showTooltip);
modifiers: [
{
name: "offset",
options: {
offset: [0, 10],
},
},
{
name: "hide",
enabled: true,
},
],
});
}
}, 1500); }, 1500);
}); });
+4 -3
View File
@@ -1,12 +1,13 @@
import "./assets/scss/index.scss"; import "./assets/scss/index.scss";
import { createPinia } from "pinia";
import { createApp } from "vue"; import { createApp } from "vue";
import { createPinia } from "pinia";
import piniaPluginPersistedstate from "pinia-plugin-persistedstate"; import piniaPluginPersistedstate from "pinia-plugin-persistedstate";
import vTooltip from "./directives/vTooltip";
import App from "./App.vue"; import App from "./App.vue";
import router from "./router"; import router from "./router";
import vTooltip from "./directives/vTooltip";
const app = createApp(App); const app = createApp(App);
const pinia = createPinia(); const pinia = createPinia();
@@ -16,4 +17,4 @@ app.use(pinia);
app.use(router); app.use(router);
app.directive("tooltip", vTooltip); app.directive("tooltip", vTooltip);
app.mount("#app"); app.mount("#app")