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
- 956069b8Records: R1 result, mission 007mre
- 3c8a2e12Mission 007: #20 sort scrollmre
- deb8cef5Records: mission 006 startedmre
- 4f0ad42fMission 006: jukebox#20mre
- 800cae06Records: #21 planmre
- 64bc7823Records: #21 causemre
- 76639655Records: B1 questionmre
- d7906b36Records: mission 005 startedmre
- d3df773cMission 005: doc linemre
- 6a5d840aMission 005: jukebox#22mre
- 13e5e748Records: mission 004 startedmre
- a8098271Mission 004: jukebox#21mre
- df8f5205Records: jukebox#19-21, #11 closedmre
- b7a4e692Records: hybriel#298mre
- 9bcbb017Records: day38b waits for day39 fixmre
- f80504e1Records: day38b repro sentmre
- 8048258bRecords: day38b jb3 regression, L1 Chromes stoppedmre
- 68aace7fRecords: mission 003 day38bmre
- d105d8a9Records: mpackdb integrity check cleanmre
- 6e980c53Records: mpackdb rule refinementmre