jukebox
All repositories: gitoria
2.3 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, rowId)emit artistLoad(index, 0)}}on artistShuffle(e) {emit jbShuffle({ kind = 'list' ctx = { kind = 'artist-songs' artist = id sort = 'artist' } })return null}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" }button { id = "shuffle" type = "button" on click(e) { emit artistShuffle(e) } "Shuffle" }}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
- 7eb2898dRecords: mpackdb second-opener rule until day38mre
- b011f98eRecords: style form live on day35mre
- 60d90cb2Records: L1 woken for the restartmre
- 75ae544fRecords: restart waits for the connection to closemre
- e0b75951Records: L1 merged and pushed, restart waits for an open connectionmre
- f2b5db98styles: format styles with nested rules and bare queriesmre
- f036bab4search: format styles with nested rules and bare queriesmre
- ef9a9d4asongs: format styles with nested rules and bare queriesmre
- f22f9aacmain: format styles with nested rules and bare queriesmre
- f56cd7c7Sync icons from 8176eb1 and verify mixed component sourcesmre
- d56e5054Sync theme and shared tokens from layouts 17e0f03mre
- b1362547Re-vendor to Hybriel set day35mre
- 89e10f08Records: mission 002 rollback wordingmre
- 9485dee7Records: mission 002 brief (live step)mre
- 9ba68fe7Records: S1b reviewedmre
- 193dfff1Records: S1 result, S1b startedmre
- 028ed776Records: mission 001 continuation S1bmre
- 1838d7e8Records: S1 startedmre
- a43fca3fRecords: mission 001 decided pointsmre
- 41773828Records: statusmre