jukebox
All repositories: gitoria
2.0 KB
// components/artist.hl — `/artists/<id>`: one artist, with a switch between their albums and their songs (both are long lists for some artists, so both are virtual lists).parent './main.hl'import { navigate } from 'hl:web'import VirtualList from './virtual-list/virtual-list.hl'import { rowsFor, artistInfo } from '../lib/rows.hl'id = nullinfo = artistInfo(id)__title = info.name + ' · Jukebox'String tab = info.albums > 1 ? 'albums' : 'songs'Hybrid artistCtx = { kind = info.albums > 1 ? 'artist-albums' : 'artist-songs' artist = id sort = 'artist' }Hybrid firstRows = rowsFor({ kind = info.albums > 1 ? 'artist-albums' : 'artist-songs' artist = id sort = 'artist' }, 0, 100)Number listTotal = firstRows.totalHybrid chunk = firstRows.rowsNumber chunkFrom = 0String playingId = ''String albumsClass = tab == 'albums' ? 'on' : ''String songsClass = tab == 'songs' ? 'on' : ''on artistLoad(first, wanted) {let start = first - 20if (start < 0) { start = 0 }r = emit server jbRows(artistCtx, start, 100)listTotal = r.totalchunk = r.rowschunkFrom = r.offsetreturn null}loadRange = (first, wanted) => { emit artistLoad(first, wanted) }picked = (rowId, index) => {if (tab == 'albums') { navigate('/albums/' + rowId) } else {playingId = rowIdemit jbPlay(artistCtx, index)}}on artistTab(e) {tab = e.target.getAttribute('data-tab')artistCtx = { kind = tab == 'albums' ? 'artist-albums' : 'artist-songs' artist = id sort = 'artist' }r = emit server jbRows(artistCtx, 0, 100)listTotal = r.totalchunk = r.rowschunkFrom = 0emit vlTop()return null}View {jbScreen {jbTabs {button { type = "button" class = albumsClass 'data-tab' = "albums" on click(e) { emit artistTab(e) } "Albums" }button { type = "button" class = songsClass 'data-tab' = "songs" on click(e) { emit artistTab(e) } "Songs" }}VirtualList { itemCount = listTotal rowHeight = 56 loaded = chunk loadedFrom = chunkFrom onRange = loadRange onPick = picked selectedId = playingId listLabel = "Artist"jbHead { h1 { id = "name" info.name } p { info.line } }}}}
Branches
Latest commits
- 2a4cfc55jukebox: library screens (songs, artists, albums, artist, album, search, favourites), compact player bar, /stream with Range, thumbnails, virtual list vendored, ui gate and real-library checkmre
- 93a44212jukebox: report, numbers of the full scan, notes on the index key rulemre
- bf5167dajukebox: index keys without commas (mpackdb loses them after a reopen), comma fixture and gate checksmre
- 28a82fa2jukebox: README, STATUS, LOG, DECISIONSmre
- d13987dfjukebox: library scanner, ID3 reader, mpackdb database and JSON API, with fixtures and a gatemre