Add album images
This commit is contained in:
parent
960eaa73f7
commit
ae7e9ee912
1 changed files with 18 additions and 1 deletions
|
@ -5,10 +5,11 @@ import gleam/int
|
|||
import gleam/list
|
||||
import gleam/map
|
||||
import gleam/option
|
||||
import lustre/element/html.{div, h3, p}
|
||||
import lustre/element/html.{div, h3, img, p}
|
||||
import lustre/element.{text}
|
||||
import lustre/attribute
|
||||
import lustre/event
|
||||
import ibroadcast/artwork
|
||||
import elekf/library.{Library}
|
||||
import elekf/library/album.{Album}
|
||||
import elekf/web/components/library_view.{LibraryItem, Model, StartPlay}
|
||||
|
@ -63,6 +64,7 @@ fn item_view(
|
|||
0 -> "Unknown artist"
|
||||
id -> library.assert_artist(model.library, id).name
|
||||
}
|
||||
let assert Ok(first_track) = list.first(tracks)
|
||||
|
||||
div(
|
||||
[
|
||||
|
@ -72,6 +74,21 @@ fn item_view(
|
|||
attribute.attribute("role", "button"),
|
||||
],
|
||||
[
|
||||
case model.settings, { first_track.1 }.artwork_id {
|
||||
option.Some(s), id if id != 0 ->
|
||||
img([
|
||||
attribute.class("artist-image"),
|
||||
attribute.alt("artist.name"),
|
||||
attribute.src(artwork.url(
|
||||
s.artwork_server,
|
||||
int.to_string(id),
|
||||
artwork.S300,
|
||||
)),
|
||||
attribute.attribute("loading", "lazy"),
|
||||
])
|
||||
_, _ ->
|
||||
div([attribute.class("artist-image-placeholder")], [text(album.name)])
|
||||
},
|
||||
h3([attribute.class("album-title")], [text(album.name)]),
|
||||
p([attribute.class("album-artist")], [text(artist_name)]),
|
||||
p(
|
||||
|
|
Loading…
Reference in a new issue