use directive to add tooltip

+ change grid size for search page
+
This commit is contained in:
geoffrey45
2022-09-04 12:48:56 +03:00
parent 4861429e4e
commit 24bfa73ab6
16 changed files with 111 additions and 81 deletions
+1
View File
@@ -2,6 +2,7 @@
<ContextMenu /> <ContextMenu />
<Modal /> <Modal />
<Notification /> <Notification />
<div id="tooltip"></div>
<div <div
id="app-grid" id="app-grid"
:class="{ :class="{
+4 -1
View File
@@ -87,7 +87,10 @@
grid-area: l-sidebar; grid-area: l-sidebar;
display: grid; display: grid;
grid-template-rows: 1fr max-content; grid-template-rows: 1fr max-content;
gap: 1rem; background-color: $gray;
height: 100vh;
margin-top: -$small;
margin-left: -$small;
} }
.b-bar { .b-bar {
+10
View File
@@ -111,3 +111,13 @@ button {
.card-dark { .card-dark {
background-color: #fff; background-color: #fff;
} }
#tooltip {
background-color: $darkestblue;
border-radius: $smaller;
padding: $smaller;
font-size: 0.85rem;
display: none;
position: absolute;
z-index: 300;
}
+2 -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"> <div class="title ellip" v-tooltip="album.title">
{{ album.title }} {{ album.title }}
</div> </div>
</div> </div>
@@ -141,6 +141,7 @@ useVisibility(albumheaderthing, handleVisibilityState);
.title { .title {
font-size: 2.5rem; font-size: 2.5rem;
font-weight: 600; font-weight: 600;
width: fit-content;
} }
.artist { .artist {
+1 -1
View File
@@ -1,6 +1,6 @@
<template> <template>
<div <div
class="table rounded border" class="table rounded"
v-if="tracks.length" v-if="tracks.length"
ref="tracklistElem" ref="tracklistElem"
:class="{ :class="{
+1 -1
View File
@@ -1,5 +1,5 @@
<template> <template>
<div class="l-sidebar rounded border"> <div class="l-sidebar">
<div class="withlogo"> <div class="withlogo">
<Logo /> <Logo />
<Navigation /> <Navigation />
@@ -51,7 +51,7 @@ defineProps<{
.search-results-grid { .search-results-grid {
display: grid; display: grid;
grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr)); grid-template-columns: repeat(auto-fill, minmax(8rem, 1fr));
gap: 0.75rem; gap: 0.75rem;
} }
</style> </style>
+4 -3
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">{{ album.title }}</h4> <h4 class="title ellip" v-tooltip="album.title">{{ album.title }}</h4>
<div class="artist ellip">{{ album.artist }}</div> <div class="artist ellip">{{ album.artist }}</div>
</div> </div>
</router-link> </router-link>
@@ -30,7 +30,7 @@ defineProps<{
gap: $small; gap: $small;
padding: $small; padding: $small;
transition: all 0.5s ease; transition: all 0.5s ease;
border-radius: .7rem; border-radius: 0.7rem;
img { img {
width: 100%; width: 100%;
@@ -44,12 +44,13 @@ defineProps<{
.title { .title {
margin-bottom: $smaller; margin-bottom: $smaller;
font-size: 0.9rem; font-size: 0.9rem;
width: fit-content;
} }
.artist { .artist {
font-size: 0.8rem; font-size: 0.8rem;
text-align: left; text-align: left;
opacity: .75; opacity: 0.75;
} }
} }
</style> </style>
+5 -5
View File
@@ -42,10 +42,10 @@ defineProps<{
object-fit: cover; object-fit: cover;
} }
&:hover { // &:hover {
.artist-image { // .artist-image {
border-radius: 20%; // border-radius: 10%;
} // }
} // }
} }
</style> </style>
+15 -3
View File
@@ -1,17 +1,29 @@
<template> <template>
<div class="ellip" v-if="artists[0] !== ''"> <div v-tooltip="returnArtists()" style="width: auto;">
<span v-for="artist in putCommas(artists)" :key="artist">{{ artist }}</span> <div class="ellip" v-if="artists[0] !== '' && artists.length > 1">
<span v-for="artist in putCommas(artists)" :key="artist">{{
artist
}}</span>
</div> </div>
<div class="ellip" v-else> <div class="ellip" v-else>
<span>{{ albumartist }}</span> <span>{{ albumartist }}</span>
</div> </div>
</div>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { putCommas } from "@/utils"; import { putCommas } from "@/utils";
defineProps<{ const props = defineProps<{
artists: string[]; artists: string[];
albumartist: string | undefined; albumartist: string | undefined;
}>(); }>();
function returnArtists() {
if (props.artists[0] !== "" && props.artists.length > 1) {
return props.artists.join(", ");
} else {
return props.albumartist;
}
}
</script> </script>
+6 -49
View File
@@ -20,7 +20,7 @@
:class="{ last_played: !isPlaying }" :class="{ last_played: !isPlaying }"
></div> ></div>
</div> </div>
<div @mouseover="showToolTip" @mouseleave="hideToolTip"> <div v-tooltip="track.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>
@@ -30,9 +30,6 @@
:albumartist="track.albumartist" :albumartist="track.albumartist"
/> />
</div> </div>
<div class="tooltip" ref="tooltip">
{{ track.title }}
</div>
</div> </div>
</div> </div>
<div class="song-artists"> <div class="song-artists">
@@ -40,6 +37,7 @@
</div> </div>
<router-link <router-link
class="song-album ellip" class="song-album ellip"
v-tooltip="track.album"
:to="{ :to="{
name: 'AlbumView', name: 'AlbumView',
params: { params: {
@@ -64,7 +62,6 @@
<script setup lang="ts"> <script setup lang="ts">
import { ref } from "vue"; import { ref } from "vue";
import { createPopper } from "@popperjs/core";
import OptionSvg from "@/assets/icons/more.svg"; import OptionSvg from "@/assets/icons/more.svg";
@@ -99,38 +96,6 @@ function emitUpdate(track: Track) {
function showMenu(e: Event) { function showMenu(e: Event) {
showContext(e, props.track, options_button_clicked); showContext(e, props.track, options_button_clicked);
} }
let isHovering = false;
function showToolTip() {
isHovering = true;
setTimeout(() => {
if (isHovering) {
const ttip = tooltip.value as HTMLElement;
const atitle = artisttitle.value as HTMLElement;
ttip.style.display = "unset";
createPopper(atitle, ttip, {
placement: "top",
modifiers: [
{
name: "offset",
options: {
offset: [10, 10],
},
},
],
});
}
}, 500);
}
function hideToolTip() {
(tooltip.value as HTMLElement).style.display = "none";
isHovering = false;
}
</script> </script>
<style lang="scss"> <style lang="scss">
@@ -143,17 +108,6 @@ function hideToolTip() {
gap: 1rem; gap: 1rem;
user-select: none; user-select: none;
.tooltip {
background-color: $darkestblue;
border-radius: $smaller;
padding: $smaller;
font-size: 0.85rem;
display: none;
position: absolute;
margin: 1rem;
z-index: 300;
}
&:hover { &:hover {
background-color: $gray4; background-color: $gray4;
@@ -172,6 +126,9 @@ function hideToolTip() {
} }
.song-artists { .song-artists {
width: fit-content;
max-width: 100%;
.artist { .artist {
cursor: pointer; cursor: pointer;
} }
@@ -181,7 +138,7 @@ function hideToolTip() {
opacity: 0.5; opacity: 0.5;
font-size: 0.8rem; font-size: 0.8rem;
width: 100%; width: 100%;
margin-left: $small; // margin-left: $small;
} }
.song-duration { .song-duration {
+8 -2
View File
@@ -19,7 +19,7 @@
></div> ></div>
</div> </div>
<div class="tags"> <div class="tags">
<div class="title ellip"> <div class="title ellip" v-tooltip="track.title">
{{ track.title }} {{ track.title }}
</div> </div>
<hr /> <hr />
@@ -94,6 +94,12 @@ const playThis = (track: Track) => {
align-items: center; align-items: center;
padding: $small 1rem; padding: $small 1rem;
.tags {
.title {
width: fit-content;
}
}
.remove-track { .remove-track {
opacity: 0; opacity: 0;
transition: all 0.25s ease; transition: all 0.25s ease;
@@ -139,7 +145,7 @@ const playThis = (track: Track) => {
.artist { .artist {
font-size: small; font-size: small;
opacity: .67; opacity: 0.67;
} }
} }
</style> </style>
+42
View File
@@ -0,0 +1,42 @@
import { Directive } from "vue";
import { createPopper } from "@popperjs/core";
export default {
mounted(el, binding) {
let isHovered = false;
const tooltip = document.getElementById("tooltip") as HTMLElement;
el.addEventListener("mouseenter", () => {
isHovered = true;
setTimeout(() => {
tooltip.innerText = binding.value;
if (isHovered) {
tooltip.style.display = "unset";
createPopper(el, tooltip, {
placement: "top",
modifiers: [
{
name: "offset",
options: {
offset: [0, 10],
},
},
],
});
}
}, 1000);
});
el.addEventListener("mouseleave", () => {
isHovered = false;
tooltip.style.display = "none";
});
},
beforeUnmount(el: HTMLElement) {
el.removeEventListener("mouseenter", () => {});
el.removeEventListener("mouseleave", () => {});
},
} as Directive;
+2
View File
@@ -3,6 +3,7 @@ import "./assets/scss/index.scss";
import { createPinia } from "pinia"; import { createPinia } from "pinia";
import { createApp } from "vue"; import { createApp } from "vue";
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";
@@ -13,5 +14,6 @@ pinia.use(piniaPluginPersistedstate);
app.use(pinia); app.use(pinia);
app.use(router); app.use(router);
app.directive("tooltip", vTooltip);
app.mount("#app"); app.mount("#app");
-10
View File
@@ -1,7 +1,6 @@
<template> <template>
<div id="p-view"> <div id="p-view">
<div class="grid"> <div class="grid">
<!-- <NewPlaylistCard /> -->
<PlaylistCard <PlaylistCard
v-for="p in pStore.playlists" v-for="p in pStore.playlists"
:key="p.playlistid" :key="p.playlistid"
@@ -14,7 +13,6 @@
<script setup lang="ts"> <script setup lang="ts">
import PlaylistCard from "@/components/PlaylistsList/PlaylistCard.vue"; import PlaylistCard from "@/components/PlaylistsList/PlaylistCard.vue";
// import NewPlaylistCard from "@/components/PlaylistsList/NewPlaylistCard.vue";
import usePStore from "@/stores/pages/playlists"; import usePStore from "@/stores/pages/playlists";
const pStore = usePStore(); const pStore = usePStore();
</script> </script>
@@ -27,14 +25,6 @@ const pStore = usePStore();
.grid { .grid {
grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr)); grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr));
gap: 1rem; gap: 1rem;
// @include for-desktop-down {
// grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr));
// .name {
// font-size: 0.9rem;
// }
// }
} }
} }
</style> </style>
+6 -1
View File
@@ -13,12 +13,17 @@ import Main from "@/components/RightSideBar/Search/Main.vue";
<style lang="scss"> <style lang="scss">
.search-view { .search-view {
height: 100%; height: 100%;
background-color: $black; // background-color: $black;
padding-top: 0; padding-top: 0;
margin-right: -1rem;
.scrollable { .scrollable {
height: 100%; height: 100%;
overflow: auto; overflow: auto;
} }
.search-results-grid {
grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr));
}
} }
</style> </style>