[web] Renaming image control

This commit is contained in:
Alain Nussbaumer 2025-02-15 22:55:01 +01:00
parent 26a03a1219
commit eca8f40afc
11 changed files with 51 additions and 66 deletions

View File

@ -1,5 +1,5 @@
<template> <template>
<figure class="cover has-shadow"> <figure class="figure has-shadow">
<img v-lazy="{ src: url, lifecycle }" @click="$emit('click')" /> <img v-lazy="{ src: url, lifecycle }" @click="$emit('click')" />
</figure> </figure>
</template> </template>
@ -8,14 +8,13 @@
import { renderSVG } from '@/lib/SVGRenderer' import { renderSVG } from '@/lib/SVGRenderer'
export default { export default {
name: 'CoverArtwork', name: 'ControlImage',
props: { props: {
album: { default: '', type: String }, album: { default: '', type: String },
artist: { default: '', type: String }, artist: { default: '', type: String },
url: { default: '', type: String } url: { default: '', type: String }
}, },
emits: ['click'], emits: ['click'],
data() { data() {
return { return {
font: { family: 'sans-serif', weight: 'bold' }, font: { family: 'sans-serif', weight: 'bold' },
@ -27,22 +26,11 @@ export default {
size: 600 size: 600
} }
}, },
computed: {
alt_text() {
return `${this.artist} - ${this.album}`
},
caption() {
return (this.album || this.artist || '').substring(0, 2)
}
},
methods: { methods: {
dataURI() { dataURI() {
return renderSVG({ return renderSVG({
alternate: this.alt_text, alternate: `${this.artist} - ${this.album}`,
caption: this.caption, caption: (this.album || this.artist || '').substring(0, 2),
font: this.font, font: this.font,
size: this.size size: this.size
}) })
@ -54,7 +42,7 @@ export default {
<style lang="scss" scoped> <style lang="scss" scoped>
@use 'bulma/sass/utilities/mixins'; @use 'bulma/sass/utilities/mixins';
.cover { .figure {
align-items: center; align-items: center;
display: flex; display: flex;
justify-content: center; justify-content: center;

View File

@ -12,7 +12,7 @@
class="media is-align-items-center is-clickable mb-0" class="media is-align-items-center is-clickable mb-0"
@click="open(item.item)" @click="open(item.item)"
> >
<cover-artwork <control-image
v-if="settingsStore.show_cover_artwork_in_album_lists" v-if="settingsStore.show_cover_artwork_in_album_lists"
:url="item.item.artwork_url" :url="item.item.artwork_url"
:artist="item.item.artist" :artist="item.item.artist"
@ -69,7 +69,7 @@
</template> </template>
<script> <script>
import CoverArtwork from '@/components/CoverArtwork.vue' import ControlImage from '@/components/ControlImage.vue'
import ModalDialog from '@/components/ModalDialog.vue' import ModalDialog from '@/components/ModalDialog.vue'
import ModalDialogAlbum from '@/components/ModalDialogAlbum.vue' import ModalDialogAlbum from '@/components/ModalDialogAlbum.vue'
import { useSettingsStore } from '@/stores/settings' import { useSettingsStore } from '@/stores/settings'
@ -77,7 +77,7 @@ import webapi from '@/webapi'
export default { export default {
name: 'ListAlbums', name: 'ListAlbums',
components: { CoverArtwork, ModalDialog, ModalDialogAlbum }, components: { ControlImage, ModalDialog, ModalDialogAlbum },
props: { props: {
items: { required: true, type: Object }, items: { required: true, type: Object },
media_kind: { default: '', type: String } media_kind: { default: '', type: String }

View File

@ -4,7 +4,7 @@
class="media is-align-items-center is-clickable mb-0" class="media is-align-items-center is-clickable mb-0"
@click="open(item)" @click="open(item)"
> >
<cover-artwork <control-image
v-if="settingsStore.show_cover_artwork_in_album_lists" v-if="settingsStore.show_cover_artwork_in_album_lists"
:url="item.images?.[0]?.url ?? ''" :url="item.images?.[0]?.url ?? ''"
:artist="item.artist" :artist="item.artist"
@ -39,13 +39,13 @@
</template> </template>
<script> <script>
import CoverArtwork from '@/components/CoverArtwork.vue' import ControlImage from '@/components/ControlImage.vue'
import ModalDialogAlbumSpotify from '@/components/ModalDialogAlbumSpotify.vue' import ModalDialogAlbumSpotify from '@/components/ModalDialogAlbumSpotify.vue'
import { useSettingsStore } from '@/stores/settings' import { useSettingsStore } from '@/stores/settings'
export default { export default {
name: 'ListAlbumsSpotify', name: 'ListAlbumsSpotify',
components: { CoverArtwork, ModalDialogAlbumSpotify }, components: { ControlImage, ModalDialogAlbumSpotify },
props: { items: { required: true, type: Object } }, props: { items: { required: true, type: Object } },
setup() { setup() {
return { settingsStore: useSettingsStore() } return { settingsStore: useSettingsStore() }

View File

@ -3,7 +3,7 @@
<a v-if="item.handler" @click="item.handler" v-text="item.name"></a> <a v-if="item.handler" @click="item.handler" v-text="item.name"></a>
<span v-else v-text="item.name" /> <span v-else v-text="item.name" />
</div> </div>
<cover-artwork <control-image
v-if="item.image" v-if="item.image"
:url="item.image" :url="item.image"
:artist="item.artist" :artist="item.artist"
@ -29,11 +29,11 @@
</template> </template>
<script> <script>
import CoverArtwork from '@/components/CoverArtwork.vue' import ControlImage from '@/components/ControlImage.vue'
export default { export default {
name: 'ListProperties', name: 'ListProperties',
components: { CoverArtwork }, components: { ControlImage },
props: { props: {
item: { required: true, type: Object } item: { required: true, type: Object }
} }

View File

@ -34,17 +34,6 @@
} }
} }
.column {
&.has-cover {
@include mixins.mobile {
margin: auto;
}
@include mixins.tablet {
margin-right: 0;
}
}
}
.overlay-fullscreen { .overlay-fullscreen {
@extend .is-overlay; @extend .is-overlay;
z-index: 25; z-index: 25;

View File

@ -20,7 +20,7 @@
</div> </div>
</template> </template>
<template #heading-right> <template #heading-right>
<cover-artwork <control-image
:url="album.artwork_url" :url="album.artwork_url"
:artist="album.artist" :artist="album.artist"
:album="album.name" :album="album.name"
@ -46,7 +46,7 @@
<script> <script>
import ContentWithHero from '@/templates/ContentWithHero.vue' import ContentWithHero from '@/templates/ContentWithHero.vue'
import CoverArtwork from '@/components/CoverArtwork.vue' import ControlImage from '@/components/ControlImage.vue'
import { GroupedList } from '@/lib/GroupedList' import { GroupedList } from '@/lib/GroupedList'
import ListTracks from '@/components/ListTracks.vue' import ListTracks from '@/components/ListTracks.vue'
import ModalDialogAlbum from '@/components/ModalDialogAlbum.vue' import ModalDialogAlbum from '@/components/ModalDialogAlbum.vue'
@ -74,14 +74,12 @@ const dataObject = {
export default { export default {
name: 'PageAlbum', name: 'PageAlbum',
components: { ContentWithHero, CoverArtwork, ListTracks, ModalDialogAlbum }, components: { ContentWithHero, ControlImage, ListTracks, ModalDialogAlbum },
beforeRouteEnter(to, from, next) { beforeRouteEnter(to, from, next) {
dataObject.load(to).then((response) => { dataObject.load(to).then((response) => {
next((vm) => dataObject.set(vm, response)) next((vm) => dataObject.set(vm, response))
}) })
}, },
data() { data() {
return { return {
album: {}, album: {},
@ -89,7 +87,6 @@ export default {
tracks: new GroupedList() tracks: new GroupedList()
} }
}, },
methods: { methods: {
open_artist() { open_artist() {
this.show_details_modal = false this.show_details_modal = false

View File

@ -20,7 +20,7 @@
</div> </div>
</template> </template>
<template #heading-right> <template #heading-right>
<cover-artwork <control-image
:url="album.images?.[0]?.url ?? ''" :url="album.images?.[0]?.url ?? ''"
:artist="album.artists[0].name" :artist="album.artists[0].name"
:album="album.name" :album="album.name"
@ -48,7 +48,7 @@
<script> <script>
import ContentWithHero from '@/templates/ContentWithHero.vue' import ContentWithHero from '@/templates/ContentWithHero.vue'
import CoverArtwork from '@/components/CoverArtwork.vue' import ControlImage from '@/components/ControlImage.vue'
import ListTracksSpotify from '@/components/ListTracksSpotify.vue' import ListTracksSpotify from '@/components/ListTracksSpotify.vue'
import ModalDialogAlbumSpotify from '@/components/ModalDialogAlbumSpotify.vue' import ModalDialogAlbumSpotify from '@/components/ModalDialogAlbumSpotify.vue'
import SpotifyWebApi from 'spotify-web-api-js' import SpotifyWebApi from 'spotify-web-api-js'
@ -72,7 +72,7 @@ export default {
name: 'PageAlbumSpotify', name: 'PageAlbumSpotify',
components: { components: {
ContentWithHero, ContentWithHero,
CoverArtwork, ControlImage,
ListTracksSpotify, ListTracksSpotify,
ModalDialogAlbumSpotify ModalDialogAlbumSpotify
}, },

View File

@ -20,7 +20,7 @@
</div> </div>
</template> </template>
<template #heading-right> <template #heading-right>
<cover-artwork <control-image
:url="album.artwork_url" :url="album.artwork_url"
:artist="album.artist" :artist="album.artist"
:album="album.name" :album="album.name"
@ -51,7 +51,7 @@
<script> <script>
import ContentWithHero from '@/templates/ContentWithHero.vue' import ContentWithHero from '@/templates/ContentWithHero.vue'
import CoverArtwork from '@/components/CoverArtwork.vue' import ControlImage from '@/components/ControlImage.vue'
import { GroupedList } from '@/lib/GroupedList' import { GroupedList } from '@/lib/GroupedList'
import ListTracks from '@/components/ListTracks.vue' import ListTracks from '@/components/ListTracks.vue'
import ModalDialogAlbum from '@/components/ModalDialogAlbum.vue' import ModalDialogAlbum from '@/components/ModalDialogAlbum.vue'
@ -73,14 +73,12 @@ const dataObject = {
export default { export default {
name: 'PageAudiobooksAlbum', name: 'PageAudiobooksAlbum',
components: { ContentWithHero, CoverArtwork, ListTracks, ModalDialogAlbum }, components: { ContentWithHero, ControlImage, ListTracks, ModalDialogAlbum },
beforeRouteEnter(to, from, next) { beforeRouteEnter(to, from, next) {
dataObject.load(to).then((response) => { dataObject.load(to).then((response) => {
next((vm) => dataObject.set(vm, response)) next((vm) => dataObject.set(vm, response))
}) })
}, },
data() { data() {
return { return {
album: {}, album: {},
@ -88,7 +86,6 @@ export default {
tracks: new GroupedList() tracks: new GroupedList()
} }
}, },
methods: { methods: {
open_artist() { open_artist() {
this.show_details_modal = false this.show_details_modal = false

View File

@ -3,7 +3,7 @@
<div class="hero-body is-flex is-align-items-center"> <div class="hero-body is-flex is-align-items-center">
<div class="container has-text-centered"> <div class="container has-text-centered">
<div v-if="track.id" class="mx-auto" style="max-width: 32rem"> <div v-if="track.id" class="mx-auto" style="max-width: 32rem">
<cover-artwork <control-image
:url="track.artwork_url" :url="track.artwork_url"
:artist="track.artist" :artist="track.artist"
:album="track.album" :album="track.album"
@ -54,8 +54,8 @@
</template> </template>
<script> <script>
import ControlImage from '@/components/ControlImage.vue'
import ControlSlider from '@/components/ControlSlider.vue' import ControlSlider from '@/components/ControlSlider.vue'
import CoverArtwork from '@/components/CoverArtwork.vue'
import LyricsPane from '@/components/LyricsPane.vue' import LyricsPane from '@/components/LyricsPane.vue'
import ModalDialogQueueItem from '@/components/ModalDialogQueueItem.vue' import ModalDialogQueueItem from '@/components/ModalDialogQueueItem.vue'
import { useLyricsStore } from '@/stores/lyrics' import { useLyricsStore } from '@/stores/lyrics'
@ -70,11 +70,10 @@ export default {
name: 'PageNowPlaying', name: 'PageNowPlaying',
components: { components: {
ControlSlider, ControlSlider,
CoverArtwork, ControlImage,
LyricsPane, LyricsPane,
ModalDialogQueueItem ModalDialogQueueItem
}, },
setup() { setup() {
return { return {
lyricsStore: useLyricsStore(), lyricsStore: useLyricsStore(),
@ -83,7 +82,6 @@ export default {
settingsStore: useSettingsStore() settingsStore: useSettingsStore()
} }
}, },
data() { data() {
return { return {
INTERVAL, INTERVAL,
@ -93,7 +91,6 @@ export default {
show_details_modal: false show_details_modal: false
} }
}, },
computed: { computed: {
composer() { composer() {
if (this.settingsStore.show_composer_now_playing) { if (this.settingsStore.show_composer_now_playing) {
@ -140,7 +137,6 @@ export default {
: this.$filters.durationInHours(this.track.length_ms) : this.$filters.durationInHours(this.track.length_ms)
} }
}, },
watch: { watch: {
'playerStore.state'(newState) { 'playerStore.state'(newState) {
if (this.interval_id > 0) { if (this.interval_id > 0) {
@ -152,7 +148,6 @@ export default {
} }
} }
}, },
created() { created() {
webapi.player_status().then(({ data }) => { webapi.player_status().then(({ data }) => {
this.playerStore.$state = data this.playerStore.$state = data
@ -161,14 +156,12 @@ export default {
} }
}) })
}, },
unmounted() { unmounted() {
if (this.interval_id > 0) { if (this.interval_id > 0) {
window.clearTimeout(this.interval_id) window.clearTimeout(this.interval_id)
this.interval_id = 0 this.interval_id = 0
} }
}, },
methods: { methods: {
end_dragging() { end_dragging() {
this.is_dragged = false this.is_dragged = false

View File

@ -20,7 +20,7 @@
</div> </div>
</template> </template>
<template #heading-right> <template #heading-right>
<cover-artwork <control-image
:url="album.artwork_url" :url="album.artwork_url"
:artist="album.artist" :artist="album.artist"
:album="album.name" :album="album.name"
@ -71,7 +71,7 @@
<script> <script>
import ContentWithHero from '@/templates/ContentWithHero.vue' import ContentWithHero from '@/templates/ContentWithHero.vue'
import CoverArtwork from '@/components/CoverArtwork.vue' import ControlImage from '@/components/ControlImage.vue'
import { GroupedList } from '@/lib/GroupedList' import { GroupedList } from '@/lib/GroupedList'
import ListTracks from '@/components/ListTracks.vue' import ListTracks from '@/components/ListTracks.vue'
import ModalDialog from '@/components/ModalDialog.vue' import ModalDialog from '@/components/ModalDialog.vue'
@ -96,7 +96,7 @@ export default {
name: 'PagePodcast', name: 'PagePodcast',
components: { components: {
ContentWithHero, ContentWithHero,
CoverArtwork, ControlImage,
ListTracks, ListTracks,
ModalDialog, ModalDialog,
ModalDialogAlbum ModalDialogAlbum

View File

@ -5,7 +5,7 @@
<div class="columns is-centered"> <div class="columns is-centered">
<div class="column is-four-fifths"> <div class="column is-four-fifths">
<div class="columns is-flex-direction-row-reverse"> <div class="columns is-flex-direction-row-reverse">
<div class="column has-cover"> <div class="column has-image">
<slot name="heading-right" /> <slot name="heading-right" />
</div> </div>
<div <div
@ -30,3 +30,24 @@
</div> </div>
</section> </section>
</template> </template>
<script>
export default {
name: 'ContentWithHero'
}
</script>
<style lang="scss" scoped>
@use 'bulma/sass/utilities/mixins';
.column {
&.has-image {
@include mixins.mobile {
margin: auto;
}
@include mixins.tablet {
margin-right: 0;
}
}
}
</style>