package views

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

templ ArtistPage(a data.Artist) {
	@layout(a.Name) {
		<div id="container" class="duo-split">
			<div id="metadata">
				<img id="artist-image" src={ data.ExtractImageURL(a.Image) } alt="Artist image"/>
				<div id="metadata-info">
					<h1 id="artist-name">{ a.Name }</h1>
				</div>
			</div>
			<div id="artist-sections">
				if a.Description != "" {
					<div id="artist-section">
						<h2>About { a.Name }</h2>
						<div id="description">
							<p id="summary">
								{ utils.TrimText(a.Description, 500) }
							</p>
							<p id="full" class="hidden">{ a.Description }</p>
						</div>
					</div>
				}
				if len(a.Albums) > 0 {
					<div id="artist-section">
						<h2>Albums</h2>
						<div id="artist-albumlist">
							for _, album := range a.Albums {
								<a href={ templ.URL(album.URL) } id="artist-single-album">
									<img
										id="artwork-preview"
										src={ data.ExtractImageURL(album.Image) }
										alt="Album image"
									/>
									<p>{ album.Name }</p>
								</a>
							}
						</div>
					</div>
				}
			</div>
		</div>
	}
}
