package views

import (
	"fmt"
	"github.com/rramiachraf/dumb/data"
	"github.com/rramiachraf/dumb/utils"
)

templ AlbumPage(a data.Album) {
	@layout(fmt.Sprintf("%s - %s", a.Artist.Name, a.Name)) {
		<div id="container" class="trio-split">
			<div id="metadata">
				<img id="album-artwork" src={ data.ExtractImageURL(a.Image) } alt="Album image"/>
				<div id="metadata-info">
					<a href={ templ.URL(a.Artist.URL) } id="album-artist">
						<h2>{ a.Artist.Name }</h2>
					</a>
					<h1>{ a.Name }</h1>
				</div>
			</div>
			<div id="album-tracklist">
				for _, t := range a.Tracks {
					<a href={ templ.URL(t.Url) } id="album-single-track">
						<small>{ fmt.Sprintf("%d", t.Number) }</small>
						<p>{ t.Title }</p>
					</a>
				}
			</div>
			if a.About != "" {
				<div id="info">
					<div id="description" dir="auto">
						<h1 id="title">About</h1>
						<p class="hidden" id="full">{ a.About }</p>
						<p id="summary">{ utils.TrimText(a.About, 250) }</p>
					</div>
				</div>
			}
		</div>
	}
}
